summaryrefslogtreecommitdiff
path: root/doCommit.go
diff options
context:
space:
mode:
Diffstat (limited to 'doCommit.go')
-rw-r--r--doCommit.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/doCommit.go b/doCommit.go
index e7ed01c..95c844a 100644
--- a/doCommit.go
+++ b/doCommit.go
@@ -7,10 +7,27 @@ import (
"os"
"go.wit.com/lib/gui/shell"
+ "go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
func doCommit() {
+ if argv.All {
+ log.Info("do a commit everywhere")
+ doCheckDirtyAndConfigSave()
+ me.found = new(gitpb.Repos)
+ findDirty()
+ all := me.found.All()
+ for all.Scan() {
+ repo := all.Next()
+ log.Info("do a commit on repo", repo.GetGoPath())
+ if err := doCommitRepo(repo); err != nil {
+ badExit(err)
+ }
+ }
+ okExit("")
+ }
+
pwd, _ := os.Getwd()
repo := me.forge.Repos.FindByFullPath(pwd)
if repo == nil {
@@ -43,3 +60,31 @@ func doCommit() {
}
log.Info("git commit ok. forge done")
}
+
+func doCommitRepo(repo *gitpb.Repo) error {
+ if repo.GetCurrentBranchName() != repo.GetUserBranchName() {
+ me.found.Append(repo)
+ me.forge.PrintHumanTable(me.found)
+ log.Info("")
+ log.Info("wrong branch. Can not commit on", repo.GetCurrentBranchName())
+ log.Info("")
+ return nil
+ }
+
+ os.Setenv("LESS", "-XR")
+ if err := shell.Exec([]string{"git", "diff"}); err != nil {
+ return err
+ }
+
+ if argv.All {
+ if err := shell.ExecCheck([]string{"git", "add", "--all"}); err != nil {
+ return err
+ }
+ }
+
+ if err := shell.ExecCheck([]string{"git", "commit", "--all"}); err != nil {
+ return err
+ }
+ log.Info("git commit ok. forge done")
+ return nil
+}