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
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
@ -142,22 +143,39 @@ func (rl *RepoList) ArgCheckoutUser() bool {
}
func (rl *RepoList) ArgGitPull() bool {
var localonly int
var badmap int
log.Log(REPOWARN, "running git pull everywhere")
cmd := []string{"git", "pull"}
var failed int = 0
for _, repo := range rl.AllRepos() {
log.Log(REPOWARN, "Running:", repo.Status.Path(), cmd)
err, output := repo.RunCmd(cmd)
if err == nil {
log.Log(REPOWARN, output)
log.Log(REPOWARN, "Running:", repo.Status.Path())
if err := repo.Status.GitPull(); err == nil {
} else {
failed += 1
log.Log(REPOWARN, "Something went wrong. Got err", err)
log.Log(REPOWARN, "output =", output)
repo.Status.DumpTags()
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
}
}
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
}

View File

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