write out the patch files

This commit is contained in:
Jeff Carr 2024-02-13 21:18:33 -06:00
parent e30194627e
commit 82471f83f4
1 changed files with 48 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package main
import (
"path/filepath"
"strconv"
"strings"
@ -8,6 +9,7 @@ import (
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/gowit"
"go.wit.com/lib/gui/repostatus"
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
)
@ -172,8 +174,18 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
}
}
s.submitB = s.grid.NewButton("Submit Patches", func() {
for i, p := range s.allp {
log.Info(i, p.ref, p.rs.String())
patchdir := filepath.Join(me.userHomePwd.String(), "autotypist.patchset")
if shell.Exists(patchdir) {
log.Info("patchset dir already exists", patchdir)
return
} else {
shell.Mkdir(patchdir)
}
if !shell.Exists(patchdir) {
log.Info("something went wrong making", patchdir)
return
}
if makePatchset(patchdir) {
}
})
// disable these until there are not dirty repos
@ -188,7 +200,12 @@ func (s *patchSummary) Update() {
for _, repo := range me.allrepos {
total += 1
if repo.status.CheckDirty() {
dirty += 1
if repo.String() == "go.wit.com/apps/autotypist" {
// log.Info("ignoring dirty autotypist for now")
dirty += 1
} else {
dirty += 1
}
}
if repo.status.ReadOnly() {
readonly += 1
@ -248,3 +265,31 @@ func (s *patchSummary) GetPatches() (int, []*patch) {
}
return patchcount, patches
}
func makePatchset(setdir string) bool {
for _, repo := range me.allrepos {
userv := repo.status.GetUserVersion()
develv := repo.status.GetDevelVersion()
usern := repo.status.GetUserBranchName()
develn := repo.status.GetDevelBranchName()
if userv == develv {
// this repo is unchanged
continue
}
repodir := filepath.Join(setdir, repo.String())
shell.Mkdir(repodir)
// git format-patch branch1..branch2
gitcmd := []string{"git", "format-patch", "-o", repodir, develn + ".." + usern}
log.Info("Run:", gitcmd)
err, output := repo.status.RunCmd(gitcmd)
log.Info("output =", output)
if err == nil {
log.Info("patches made okay for:", repo.String())
continue
}
log.Info("patches failed for:", repo.String())
return false
}
return true
}