From 25b2e50f6b1a15f887416479cd0df583cc6d4e19 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 20 Jan 2025 01:47:27 -0600 Subject: git commit --all works --- doCommit.go | 38 +++++++++++++ doPatches.go | 13 +++++ doSubmitPatch.go | 13 ----- main.go | 24 +------- windowPatches.go | 161 ---------------------------------------------------- windowPatchesBox.go | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 213 insertions(+), 197 deletions(-) create mode 100644 doCommit.go create mode 100644 doPatches.go delete mode 100644 doSubmitPatch.go delete mode 100644 windowPatches.go create mode 100644 windowPatchesBox.go 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/doPatches.go b/doPatches.go new file mode 100644 index 0000000..8f7b6dd --- /dev/null +++ b/doPatches.go @@ -0,0 +1,13 @@ +package main + +import ( + "go.wit.com/log" +) + +func doSubmit(name string) { + if err := sendDevelDiff(name); err != nil { + log.Info("sending patches failed", err) + } else { + log.Info("sent patch set ok") + } +} diff --git a/doSubmitPatch.go b/doSubmitPatch.go deleted file mode 100644 index 8f7b6dd..0000000 --- a/doSubmitPatch.go +++ /dev/null @@ -1,13 +0,0 @@ -package main - -import ( - "go.wit.com/log" -) - -func doSubmit(name string) { - if err := sendDevelDiff(name); err != nil { - log.Info("sending patches failed", err) - } else { - log.Info("sent patch set ok") - } -} 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/windowPatches.go deleted file mode 100644 index eeae1e8..0000000 --- a/windowPatches.go +++ /dev/null @@ -1,161 +0,0 @@ -package main - -import ( - "fmt" - "strconv" - - "go.wit.com/gui" - "go.wit.com/lib/gadgets" - "go.wit.com/log" -) - -type patchSummary struct { - grid *gui.Node - updateB *gui.Node - docsB *gui.Node - gitPushB *gui.Node - gitPullB *gui.Node - checkB *gui.Node - totalOL *gadgets.OneLiner - dirtyOL *gadgets.OneLiner - readonlyOL *gadgets.OneLiner - rw *gadgets.OneLiner - totalPatchesOL *gadgets.OneLiner - totalUserRepos *gui.Node - totalDevelRepos *gui.Node - totalMasterRepos *gui.Node - totalUserPatches *gui.Node - totalDevelPatches *gui.Node - totalMasterPatches *gui.Node - fileCount *gui.Node - unknownOL *gadgets.BasicEntry - unknownSubmitB *gui.Node - reason *gadgets.BasicEntry - submitB *gui.Node - // allp []*repolist.Patch -} - -func submitPatchesBox(box *gui.Node) *patchSummary { - s := new(patchSummary) - group1 := box.NewGroup("Patch Summary") - s.grid = group1.RawGrid() - - s.totalOL = gadgets.NewOneLiner(s.grid, "Total") - _ = s.grid.NewLabel("total changes") - _ = s.grid.NewLabel("user to devel") - s.grid.NextRow() - - s.dirtyOL = gadgets.NewOneLiner(s.grid, "dirty") - _ = s.grid.NewLabel("") // skip a column - s.totalUserRepos = s.grid.NewLabel("x go repos") - s.grid.NextRow() - - s.readonlyOL = gadgets.NewOneLiner(s.grid, "read-only") - _ = s.grid.NewLabel("") // skip a column - s.totalUserPatches = s.grid.NewLabel("x patches") - s.grid.NextRow() - - s.rw = gadgets.NewOneLiner(s.grid, "r/w") - _ = s.grid.NewLabel("") // skip a column - s.fileCount = s.grid.NewLabel("x files") - s.grid.NextRow() - - group1 = box.NewGroup("Submit Patch Set") - s.grid = group1.RawGrid() - s.reason = gadgets.NewBasicEntry(s.grid, "set name:") - s.reason.Custom = func() { - if s.reason.String() != "" { - s.submitB.Enable() - } else { - s.submitB.Disable() - } - } - s.submitB = s.grid.NewButton("Submit", func() { - doSubmit(s.reason.String()) - }) - - s.grid.NewButton("List Patchsets", func() { - if err := listPatches(); err != nil { - log.Info(err) - } - }) - - s.grid.NewButton("Show Latest Patchset", func() { - lastp := lastPatch() - pset, err := getPatch(lastp) - if err != nil { - return - } - - if !dumpPatchset(pset) { - log.Info("some patches are bad") - return - } - if IsAnythingDirty() { - log.Info("You can't apply patches when repos are dirty") - me.forge.PrintHumanTable(me.found) - return - } - }) - - s.grid.NewButton("Apply Latest Patchset", func() { - lastp := lastPatch() - pset, err := getPatch(lastp) - if err != nil { - return - } - if _, _, err := IsEverythingOnDevel(); err != nil { - log.Info("You can only apply patches to the devel branch") - return - } - if IsAnythingDirty() { - log.Info("You can't apply patches when repos are dirty") - me.forge.PrintHumanTable(me.found) - return - } - applyPatchset(pset) - }) - - s.grid.NewButton("Show Repos", func() { - s.Update() - if me.repos.Hidden() { - me.repos.Show() - } else { - me.repos.Hide() - } - }) - - // disable these until there are not dirty repos - // s.reason.Disable() - s.submitB.Disable() - s.grid.NextRow() - - return s -} - -// does not run any commands -func (s *patchSummary) Update() { - var total, dirty, readonly, rw int - var userT int // , develT, masterT int - // var userP, develP, masterP int - // broken after move to forge protobuf - all := me.forge.Repos.SortByFullPath() - for all.Scan() { - repo := all.Next() - total += 1 - if repo.IsDirty() { - dirty += 1 - } - if me.forge.Config.IsReadOnly(repo.GetGoPath()) { - readonly += 1 - } else { - rw += 1 - } - } - s.totalOL.SetText(strconv.Itoa(total) + " repos") - s.dirtyOL.SetText(strconv.Itoa(dirty) + " repos") - s.readonlyOL.SetText(strconv.Itoa(readonly) + " repos") - s.rw.SetText(fmt.Sprintf("%d repos", rw)) - - s.totalUserRepos.SetText(strconv.Itoa(userT) + " repos") -} diff --git a/windowPatchesBox.go b/windowPatchesBox.go new file mode 100644 index 0000000..eeae1e8 --- /dev/null +++ b/windowPatchesBox.go @@ -0,0 +1,161 @@ +package main + +import ( + "fmt" + "strconv" + + "go.wit.com/gui" + "go.wit.com/lib/gadgets" + "go.wit.com/log" +) + +type patchSummary struct { + grid *gui.Node + updateB *gui.Node + docsB *gui.Node + gitPushB *gui.Node + gitPullB *gui.Node + checkB *gui.Node + totalOL *gadgets.OneLiner + dirtyOL *gadgets.OneLiner + readonlyOL *gadgets.OneLiner + rw *gadgets.OneLiner + totalPatchesOL *gadgets.OneLiner + totalUserRepos *gui.Node + totalDevelRepos *gui.Node + totalMasterRepos *gui.Node + totalUserPatches *gui.Node + totalDevelPatches *gui.Node + totalMasterPatches *gui.Node + fileCount *gui.Node + unknownOL *gadgets.BasicEntry + unknownSubmitB *gui.Node + reason *gadgets.BasicEntry + submitB *gui.Node + // allp []*repolist.Patch +} + +func submitPatchesBox(box *gui.Node) *patchSummary { + s := new(patchSummary) + group1 := box.NewGroup("Patch Summary") + s.grid = group1.RawGrid() + + s.totalOL = gadgets.NewOneLiner(s.grid, "Total") + _ = s.grid.NewLabel("total changes") + _ = s.grid.NewLabel("user to devel") + s.grid.NextRow() + + s.dirtyOL = gadgets.NewOneLiner(s.grid, "dirty") + _ = s.grid.NewLabel("") // skip a column + s.totalUserRepos = s.grid.NewLabel("x go repos") + s.grid.NextRow() + + s.readonlyOL = gadgets.NewOneLiner(s.grid, "read-only") + _ = s.grid.NewLabel("") // skip a column + s.totalUserPatches = s.grid.NewLabel("x patches") + s.grid.NextRow() + + s.rw = gadgets.NewOneLiner(s.grid, "r/w") + _ = s.grid.NewLabel("") // skip a column + s.fileCount = s.grid.NewLabel("x files") + s.grid.NextRow() + + group1 = box.NewGroup("Submit Patch Set") + s.grid = group1.RawGrid() + s.reason = gadgets.NewBasicEntry(s.grid, "set name:") + s.reason.Custom = func() { + if s.reason.String() != "" { + s.submitB.Enable() + } else { + s.submitB.Disable() + } + } + s.submitB = s.grid.NewButton("Submit", func() { + doSubmit(s.reason.String()) + }) + + s.grid.NewButton("List Patchsets", func() { + if err := listPatches(); err != nil { + log.Info(err) + } + }) + + s.grid.NewButton("Show Latest Patchset", func() { + lastp := lastPatch() + pset, err := getPatch(lastp) + if err != nil { + return + } + + if !dumpPatchset(pset) { + log.Info("some patches are bad") + return + } + if IsAnythingDirty() { + log.Info("You can't apply patches when repos are dirty") + me.forge.PrintHumanTable(me.found) + return + } + }) + + s.grid.NewButton("Apply Latest Patchset", func() { + lastp := lastPatch() + pset, err := getPatch(lastp) + if err != nil { + return + } + if _, _, err := IsEverythingOnDevel(); err != nil { + log.Info("You can only apply patches to the devel branch") + return + } + if IsAnythingDirty() { + log.Info("You can't apply patches when repos are dirty") + me.forge.PrintHumanTable(me.found) + return + } + applyPatchset(pset) + }) + + s.grid.NewButton("Show Repos", func() { + s.Update() + if me.repos.Hidden() { + me.repos.Show() + } else { + me.repos.Hide() + } + }) + + // disable these until there are not dirty repos + // s.reason.Disable() + s.submitB.Disable() + s.grid.NextRow() + + return s +} + +// does not run any commands +func (s *patchSummary) Update() { + var total, dirty, readonly, rw int + var userT int // , develT, masterT int + // var userP, develP, masterP int + // broken after move to forge protobuf + all := me.forge.Repos.SortByFullPath() + for all.Scan() { + repo := all.Next() + total += 1 + if repo.IsDirty() { + dirty += 1 + } + if me.forge.Config.IsReadOnly(repo.GetGoPath()) { + readonly += 1 + } else { + rw += 1 + } + } + s.totalOL.SetText(strconv.Itoa(total) + " repos") + s.dirtyOL.SetText(strconv.Itoa(dirty) + " repos") + s.readonlyOL.SetText(strconv.Itoa(readonly) + " repos") + s.rw.SetText(fmt.Sprintf("%d repos", rw)) + + s.totalUserRepos.SetText(strconv.Itoa(userT) + " repos") +} -- cgit v1.2.3