MCPcopy Create free account
hub / github.com/MiniCodeMonkey/chief / CommitCount

Function CommitCount

internal/git/git.go:54–70  ·  view source on GitHub ↗

CommitCount returns the number of commits on branch that are not on the default branch. Returns 0 if the count cannot be determined.

(repoDir, branch string)

Source from the content-addressed store, hash-verified

52// CommitCount returns the number of commits on branch that are not on the default branch.
53// Returns 0 if the count cannot be determined.
54func CommitCount(repoDir, branch string) int {
55 defaultBranch, err := GetDefaultBranch(repoDir)
56 if err != nil {
57 return 0
58 }
59 cmd := exec.Command("git", "rev-list", "--count", defaultBranch+".."+branch)
60 cmd.Dir = repoDir
61 out, err := cmd.Output()
62 if err != nil {
63 return 0
64 }
65 count, err := strconv.Atoi(strings.TrimSpace(string(out)))
66 if err != nil {
67 return 0
68 }
69 return count
70}
71
72// GetDiff returns the git diff output for the working directory.
73// It shows the diff between the current branch and its merge base with the default branch.

Callers 1

showCompletionScreenMethod · 0.92

Calls 1

GetDefaultBranchFunction · 0.85

Tested by

no test coverage detected