summaryrefslogtreecommitdiff
path: root/shell.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-06 04:27:49 -0500
committerJeff Carr <[email protected]>2025-10-06 04:27:49 -0500
commitc7c54de39149e07c5cb03e8d8aa49793f32047de (patch)
tree63065a4c532b0599f7fd111c545c1169de22e3e4 /shell.go
parentd9ed0838c403e982f572d108542bcc16705049d9 (diff)
cleanup code further
Diffstat (limited to 'shell.go')
-rw-r--r--shell.go31
1 files changed, 21 insertions, 10 deletions
diff --git a/shell.go b/shell.go
index ace3482..6230a2b 100644
--- a/shell.go
+++ b/shell.go
@@ -170,7 +170,9 @@ func (repo *Repo) ConstructGitDiffLog(branch1, branch2 string) []string {
var cmd []string
cmd = append(cmd, "git")
cmd = append(cmd, "log")
- cmd = append(cmd, "--format=\"%H%00%ae%00%as%00%s\"")
+ sfmt := strings.Join([]string{"%H", "%ae", "%as", "%s"}, "%00")
+ // cmd = append(cmd, "--format=%H%00%ae%00%as%00%s") // git log doesn't convert %00 to NULL
+ cmd = append(cmd, "--format="+sfmt) // git log doesn't convert %00 to NULL
cmd = append(cmd, branch1)
cmd = append(cmd, "--not")
cmd = append(cmd, branch2)
@@ -178,25 +180,34 @@ func (repo *Repo) ConstructGitDiffLog(branch1, branch2 string) []string {
}
// count all objects only in branch1
-func (repo *Repo) CountDiffObjects(branch1, branch2 string) (int, error) {
+func (repo *Repo) CountDiffObjectsNEWNEW(branch1, branch2 string) ([]string, []string, error) {
cmd := repo.ConstructGitDiffLog(branch1, branch2)
- r, err := repo.RunVerboseOnError(cmd)
- if err != nil {
- return -1, err
+ os.Chdir(repo.FullPath)
+ result := shell.RunQuiet(cmd)
+ var err error
+ if result.Exit != 0 {
+ err = fmt.Errorf("probably os.Exit(-1)")
+ }
+ if result.Error != nil {
+ err = result.Error
}
+ //for i, line := range result.Stdout {
+ // parts := strings.Split(line, "\x00")
+ // log.Infof("LINE: %d len(%d) %v\n", i, len(parts), parts)
+ //}
// log.Info("countDiffObjects()", cmd, len(r.Stdout), strings.Join(r.Stdout, " "))
- return len(r.Stdout), err
+ return result.Stdout, cmd, err
}
// count all objects only in branch1
-func (repo *Repo) CountDiffObjectsNew(branch1, branch2 string) ([]string, error) {
+func (repo *Repo) CountDiffObjects(branch1, branch2 string) (int, error) {
cmd := repo.ConstructGitDiffLog(branch1, branch2)
r, err := repo.RunVerboseOnError(cmd)
if err != nil {
- return nil, err
+ return -1, err
}
// log.Info("countDiffObjects()", cmd, len(r.Stdout), strings.Join(r.Stdout, " "))
- return r.Stdout, err
+ return len(r.Stdout), err
}
func (repo *Repo) CountDiffObjectsVerbose(branch1, branch2 string) ([]string, error) {
@@ -205,7 +216,7 @@ func (repo *Repo) CountDiffObjectsVerbose(branch1, branch2 string) ([]string, er
if err != nil {
return nil, err
}
- log.Info("Run:", cmd)
+ log.Info("Ran:", cmd)
for _, line := range r.Stdout {
log.Info(line, branch1, branch2, repo.FullPath)
}