diff options
| author | Jeff Carr <[email protected]> | 2024-02-19 21:11:32 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-02-19 21:11:32 -0600 |
| commit | 5bf1c5ff359e2546925bb2de2bd2a3f887d252ab (patch) | |
| tree | 581613519f6975318f6c830b71750ac21fb7bfc8 | |
| parent | 47d27e4166b960d7b84c9f6d974cc580843d59e9 (diff) | |
get patches moved here from autotypist
| -rw-r--r-- | common.go | 2 | ||||
| -rw-r--r-- | getPatches.go | 132 | ||||
| -rw-r--r-- | scan.go | 2 |
3 files changed, 134 insertions, 2 deletions
@@ -1,8 +1,8 @@ package repolist import ( - "go.wit.com/lib/gui/repostatus" "go.wit.com/gui" + "go.wit.com/lib/gui/repostatus" "go.wit.com/log" ) diff --git a/getPatches.go b/getPatches.go new file mode 100644 index 0000000..2916cea --- /dev/null +++ b/getPatches.go @@ -0,0 +1,132 @@ +package repolist + +import ( + "path/filepath" + "strings" + + "go.wit.com/lib/gui/repostatus" + "go.wit.com/lib/gui/shell" + "go.wit.com/log" +) + +type Patch struct { + Ref string + giturl string + comment string + RS *repostatus.RepoStatus +} + +/* move all this to repolist and gowit repos +p, allp := s.GetPatches() +if s.allp == nil { + s.allp = make([]*patch, 0, 0) + s.allp = append(s.allp, allp...) +} +if dirty == 0 { + s.totalPatchesOL.SetText(strconv.Itoa(p) + " patches") + s.reason.Enable() + // force the user to submit a reason to enable the submit button + // s.submitB.Enable() +} else { + s.totalPatchesOL.SetText(strconv.Itoa(p) + " patches + ? dirty") +} +*/ + +// move all this to repolist and gowit repos + +func (repo *Repo) GetPatches(oldname string, newname string) (int, []*Patch) { + var patchcount int + patches := make([]*Patch, 0, 0) + + // git log --oneline devel..jcarr + // userv := repo.Status.GetUserVersion() + // develv := repo.Status.GetDevelVersion() + // usern := repo.Status.GetUserBranchName() + // develn := repo.Status.GetDevelBranchName() + if oldname == newname { + return 0, nil + } + // log.Info("repo userv, develv", userv, develv) + gitcmd := []string{"git", "log", "--oneline", oldname + ".." + newname} + log.Info("Run:", gitcmd) + err, output := repo.Status.RunCmd(gitcmd) + if err != nil { + log.Info("git failed ", repo.GoPath(), "err =", err) + return 0, nil + } + + // patches = strings.Split(output, "\n") + log.Info("Run:", output) + for _, line := range strings.Split(output, "\n") { + line = strings.TrimSpace(line) + if line == "" { + continue + } + parts := strings.Split(line, " ") + newp := new(Patch) + newp.RS = repo.Status + newp.Ref = parts[0] + newp.comment = strings.Join(parts[1:], " ") + log.Info("Patch line:", line, newp.RS.String()) + patchcount += 1 + patches = append(patches, newp) + } + return patchcount, patches +} + +func (repo *Repo) GetUserPatches() (int, []*Patch) { + usern := repo.Status.GetUserBranchName() + develn := repo.Status.GetDevelBranchName() + userv := repo.Status.GetUserVersion() + develv := repo.Status.GetDevelVersion() + + if userv == develv { + return 0, nil + } + + c, all := repo.GetPatches(develn, usern) + log.Info("GetPatches() guireleaser", develn, usern, "count =", c) + return c, all +} + +func (repo *Repo) GetMasterPatches() (int, []*Patch) { + lasttag := repo.LastTag() + mastern := repo.Status.GetMasterBranchName() + masterv := repo.Status.GetMasterVersion() + + if lasttag == masterv { + return 0, nil + } + + c, all := repo.GetPatches(lasttag, mastern) + log.Info("GetPatches() guireleaser", lasttag, mastern, "count =", c) + return c, all +} + +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.GoPath()) + 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.GoPath()) + continue + } + log.Info("patches failed for:", repo.GoPath()) + return false + } + return true +} @@ -12,7 +12,7 @@ func (r *RepoList) SetAutoScan(b bool) { me.autoScan = b } -func (r *RepoList) RegisterHideFunction(f func (* Repo)) { +func (r *RepoList) RegisterHideFunction(f func(*Repo)) { me.hideFunction = f } |
