diff options
| author | Jeff Carr <[email protected]> | 2025-02-20 09:37:42 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-02-20 09:37:42 -0600 |
| commit | 77da32b99a6e96431d8cf65508f44a19bd5133d8 (patch) | |
| tree | 3ad93783af61169ffe427b0e2c83dd38b77fbb55 | |
| parent | 5db0b57b311570f4fffe84427c795bdc32894e62 (diff) | |
new autogen
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | doCommit.go | 45 |
2 files changed, 46 insertions, 1 deletions
@@ -7,7 +7,7 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M) # make andlabs # try the andlabs gui plugin (uses GTK) default: install - forge + forge commit --all vet: @GO111MODULE=off go vet 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 +} |
