early common things for branch handling

This commit is contained in:
Jeff Carr 2025-01-18 03:59:44 -06:00
parent 803f0cf98e
commit d014dbe3d4
1 changed files with 44 additions and 0 deletions

View File

@ -149,3 +149,47 @@ func (repo *Repo) RunStrictAll(all [][]string) (*cmd.Status, error) {
}
return nil, nil
}
func (repo *Repo) RunVerbose(cmd []string) (*cmd.Status, error) {
log.Info("Running:", repo.GetGoPath(), cmd)
r, err := repo.RunStrictNew(cmd)
if err != nil {
log.Info("Error", cmd, err)
}
for _, line := range r.Stdout {
log.Info(line)
}
for _, line := range r.Stderr {
log.Info(line)
}
return r, err
}
func (repo *Repo) RunVerboseOnError(cmd []string) (*cmd.Status, error) {
r, err := repo.RunStrictNew(cmd)
if err == nil {
return r, err
}
log.Info("Run Error:", repo.GetGoPath(), cmd, err)
for _, line := range r.Stdout {
log.Info(line)
}
for _, line := range r.Stderr {
log.Info(line)
}
return r, err
}
// only safe to run len() on STDOUT
// DO NOT TRY TO PARSE THIS EXCEPT HASH AS FIRST VALUE
// Intended to be human readable
func (repo *Repo) ConstructGitDiffLog(branch1, branch2 string) []string {
var cmd []string
cmd = append(cmd, "git")
cmd = append(cmd, "log")
cmd = append(cmd, "--format=\"%H %ae %as %s\"")
cmd = append(cmd, branch1)
cmd = append(cmd, "--not")
cmd = append(cmd, branch2)
return cmd
}