diff --git a/doCommit.go b/doCommit.go new file mode 100644 index 0000000..ae8af1a --- /dev/null +++ b/doCommit.go @@ -0,0 +1,38 @@ +package main + +import ( + "os" + + "go.wit.com/lib/gui/shell" + "go.wit.com/log" +) + +func doCommit() { + pwd, _ := os.Getwd() + repo := me.forge.Repos.FindByFullPath(pwd) + if repo == nil { + log.Info("what branch are you on?: todo: examine this") + okExit("") + } + 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("") + okExit("") + } + os.Setenv("LESS", "-XR") + if err := shell.Exec([]string{"git", "diff"}); err != nil { + badExit(err) + } + if argv.All { + if err := shell.ExecCheck([]string{"git", "add", "--all"}); err != nil { + badExit(err) + } + } + if err := shell.ExecCheck([]string{"git", "commit", "--all"}); err != nil { + badExit(err) + } + log.Info("git commit ok. forge done") +} diff --git a/doSubmitPatch.go b/doPatches.go similarity index 100% rename from doSubmitPatch.go rename to doPatches.go diff --git a/main.go b/main.go index eb25299..49dcb8d 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,6 @@ import ( "go.wit.com/dev/alexflint/arg" "go.wit.com/gui" - "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" @@ -62,28 +61,7 @@ func main() { } if argv.Commit != nil { - pwd, _ := os.Getwd() - repo := me.forge.Repos.FindByFullPath(pwd) - if repo == nil { - log.Info("what branch are you on?: todo: examine this") - okExit("") - } - 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("") - okExit("") - } - os.Setenv("LESS", "-XR") - if err := shell.Exec([]string{"git", "diff"}); err != nil { - badExit(err) - } - if err := shell.ExecCheck([]string{"git", "commit", "--all"}); err != nil { - badExit(err) - } - log.Info("git commit ok. forge done") + doCommit() okExit("") } diff --git a/windowPatches.go b/windowPatchesBox.go similarity index 100% rename from windowPatches.go rename to windowPatchesBox.go