From 77da32b99a6e96431d8cf65508f44a19bd5133d8 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 20 Feb 2025 09:37:42 -0600 Subject: new autogen --- Makefile | 2 +- doCommit.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e279b83..c26322b 100644 --- a/Makefile +++ b/Makefile @@ -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 +} -- cgit v1.2.3