more rill improvements

This commit is contained in:
Jeff Carr 2025-01-19 16:08:06 -06:00
parent 53acead41e
commit 3b17710c1a
1 changed files with 19 additions and 38 deletions

57
rill.go
View File

@ -5,7 +5,6 @@ package gitpb
import ( import (
"errors" "errors"
"strings"
sync "sync" sync "sync"
"github.com/destel/rill" "github.com/destel/rill"
@ -17,46 +16,28 @@ var ErrorMissingGitConfig error = errors.New("missing .git/config")
var ErrorGitPullOnLocal error = errors.New("git pull on local only branch") var ErrorGitPullOnLocal error = errors.New("git pull on local only branch")
var ErrorGitPullOnDirty error = errors.New("cannot git pull on dirty repo") var ErrorGitPullOnDirty error = errors.New("cannot git pull on dirty repo")
func (repo *Repo) GitPull() cmd.Status { func (repo *Repo) GitPull() (*cmd.Status, error) {
currentName := repo.GetCurrentBranchName() /*
if repo.IsOnlyLocalTag(currentName) { currentName := repo.GetCurrentBranchName()
var result cmd.Status if repo.IsOnlyLocalTag(currentName) {
result.Exit = 21 var result cmd.Status
result.Error = ErrorGitPullOnLocal result.Exit = 21
// log.Info("git pull skipped on local only branch", repo.GetGoPath()) result.Error = ErrorGitPullOnLocal
return result // log.Info("git pull skipped on local only branch", repo.GetGoPath())
} return result
}
*/
var cmd []string var cmd []string
cmd = append(cmd, "git", "pull") cmd = append(cmd, "git", "pull")
r := repo.Run(cmd) return repo.RunVerbose(cmd)
// output := strings.Join(r.Stdout, "\n")
/* notsure why I had this. I think from a long time ago
if r.Error != nil {
output = "git error_,,,_a_,,,_b_,,,c"
}
*/
/*
if r.Error == nil {
if r.Exit == 0 {
log.Log(WARN, "git pull ran ", repo.GetGoPath())
// log.Log(WARN, "git pull output", output)
return r
} else {
log.Log(WARN, "git pull error", repo.GetGoPath(), strings.Join(r.Stderr, "\n"))
return r
}
}
log.Log(WARN, "git pull error", repo.GetGoPath(), r.Error)
*/
return r
} }
// rill is awesome. long live rill // rill is awesome. long live rill
// attempt scan with rill // attempt scan with rill
func (all *Repos) RillGitPull(part1 int, part2 int) map[*Repo]cmd.Status { func (all *Repos) RillGitPull(part1 int, part2 int) map[*Repo]*cmd.Status {
var lock sync.Mutex var lock sync.Mutex
var allerr map[*Repo]cmd.Status var allerr map[*Repo]*cmd.Status
allerr = make(map[*Repo]cmd.Status) allerr = make(map[*Repo]*cmd.Status)
// Convert a slice of user IDs into a channel // Convert a slice of user IDs into a channel
ids := rill.FromSlice(all.Repos, nil) ids := rill.FromSlice(all.Repos, nil)
@ -72,7 +53,7 @@ func (all *Repos) RillGitPull(part1 int, part2 int) map[*Repo]cmd.Status {
counter += 1 counter += 1
if repo.CheckDirty() { if repo.CheckDirty() {
// log.Info("git pull skipped on dirty repo", repo.GoPath) // log.Info("git pull skipped on dirty repo", repo.GoPath)
var result cmd.Status result := new(cmd.Status)
result.Error = ErrorGitPullOnDirty result.Error = ErrorGitPullOnDirty
lock.Lock() lock.Lock()
defer lock.Unlock() defer lock.Unlock()
@ -85,10 +66,10 @@ func (all *Repos) RillGitPull(part1 int, part2 int) map[*Repo]cmd.Status {
dur = time.Duration((1+rand.Intn(50))*20) * time.Millisecond dur = time.Duration((1+rand.Intn(50))*20) * time.Millisecond
time.Sleep(dur) time.Sleep(dur)
*/ */
var result cmd.Status var result *cmd.Status
result = repo.GitPull() result, _ = repo.GitPull()
log.Info("git pull", repo.GetGoPath()) log.Info("git pull", repo.GetGoPath())
log.Info(strings.Join(result.Stdout, "\n")) // log.Info(strings.Join(result.Stdout, "\n"))
lock.Lock() lock.Lock()
defer lock.Unlock() defer lock.Unlock()
allerr[repo] = result allerr[repo] = result