starting on the commit logic
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
|
||||
clientconfig "github.com/deranjer/gvc/client/clientconfig"
|
||||
"github.com/deranjer/gvc/common/database"
|
||||
"github.com/deranjer/gvc/common/engine"
|
||||
"github.com/deranjer/gvc/common/manager"
|
||||
)
|
||||
@@ -15,6 +16,7 @@ func Commit(conf *clientconfig.Gvcconfig, commitMessage string, m *manager.Manag
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var filesToDiff []database.File // Contains the list of files that have changed
|
||||
for _, trackedFile := range trackedFiles {
|
||||
currentFile, err := os.Stat(trackedFile.Path)
|
||||
if err != nil {
|
||||
@@ -24,10 +26,15 @@ func Commit(conf *clientconfig.Gvcconfig, commitMessage string, m *manager.Manag
|
||||
currentFileHash, err := engine.UniqueFileHash(trackedFile.Path)
|
||||
if err != nil {
|
||||
fmt.Printf("unable to create hash for file: %s error: %s\n", currentFile.Name(), err)
|
||||
continue
|
||||
}
|
||||
if currentFileHash == trackedFile.CurrentHash {
|
||||
fmt.Printf("No changes found in file: %s when compared to file: %s\n", currentFile.Name(), trackedFile.Name)
|
||||
continue
|
||||
}
|
||||
filesToDiff = append(filesToDiff, trackedFile)
|
||||
}
|
||||
m.BeginCommit(filesToDiff, conf.CurrentBranch)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user