From b57144e6bfe8a6b63d2d2f8ffb47af04a926ae8b Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 29 Jan 2025 20:01:07 -0600 Subject: some useful helper functions --- shell.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'shell.go') diff --git a/shell.go b/shell.go index d14960d..c8131f6 100644 --- a/shell.go +++ b/shell.go @@ -193,3 +193,14 @@ func (repo *Repo) ConstructGitDiffLog(branch1, branch2 string) []string { cmd = append(cmd, branch2) return cmd } + +// count all objects only in branch1 +func (repo *Repo) CountDiffObjects(branch1, branch2 string) int { + cmd := repo.ConstructGitDiffLog(branch1, branch2) + r, err := repo.RunVerboseOnError(cmd) + if err != nil { + return -1 + } + // log.Info("countDiffObjects()", cmd, len(r.Stdout), strings.Join(r.Stdout, " ")) + return len(r.Stdout) +} -- cgit v1.2.3