fixes to GitPull() block non userbranch merge

This commit is contained in:
Jeff Carr 2024-02-24 04:49:31 -06:00
parent ab7c8717a3
commit bf794cab23
2 changed files with 29 additions and 7 deletions

View File

@ -1,6 +1,7 @@
package repolist package repolist
import ( import (
"fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@ -142,22 +143,39 @@ func (rl *RepoList) ArgCheckoutUser() bool {
} }
func (rl *RepoList) ArgGitPull() bool { func (rl *RepoList) ArgGitPull() bool {
var localonly int
var badmap int
log.Log(REPOWARN, "running git pull everywhere") log.Log(REPOWARN, "running git pull everywhere")
cmd := []string{"git", "pull"}
var failed int = 0 var failed int = 0
for _, repo := range rl.AllRepos() { for _, repo := range rl.AllRepos() {
log.Log(REPOWARN, "Running:", repo.Status.Path(), cmd) log.Log(REPOWARN, "Running:", repo.Status.Path())
err, output := repo.RunCmd(cmd) if err := repo.Status.GitPull(); err == nil {
if err == nil {
log.Log(REPOWARN, output)
} else { } else {
failed += 1 failed += 1
log.Log(REPOWARN, "Something went wrong. Got err", err) repo.Status.DumpTags()
log.Log(REPOWARN, "output =", output) name := repo.Status.GetCurrentBranchName()
if repo.Status.IsOnlyLocalTag(name) {
log.Log(REPOWARN, repo.Status.Path(), "can not git pull on local only branch", name, err)
} else {
log.Log(REPOWARN, repo.Status.Path(), "this branch should have worked", name, err)
}
if fmt.Sprint(err) == "git config error" {
badmap += 1
continue
}
if fmt.Sprint(err) == "local only" {
localonly += 1
continue
}
return false return false
} }
} }
log.Log(REPOWARN, "Ran git pull in all repos. failure count =", failed) log.Log(REPOWARN, "Ran git pull in all repos. failure count =", failed)
log.Log(REPOWARN, "Ran git pull in all repos. git config map errors =", badmap)
if localonly != 0 {
log.Log(REPOWARN, "Ran git pull in all repos. ignored local only branches =", localonly)
}
return true return true
} }

View File

@ -119,6 +119,10 @@ func (r *RepoList) makeAutotypistView(newRepo *RepoRow) {
}) })
newRepo.endBox.NewButton("commit all", func() { newRepo.endBox.NewButton("commit all", func() {
if ! newRepo.Status.IsUserBranch() {
log.Log(REPOWARN, "can not commit on non user branch")
return
}
r.reposbox.Disable() r.reposbox.Disable()
// restore anything staged so everything can be reviewed // restore anything staged so everything can be reviewed
newRepo.Status.RunCmd([]string{"git", "restore", "--staged", "."}) newRepo.Status.RunCmd([]string{"git", "restore", "--staged", "."})