···
···
60
-
func (g *GitRepo) RefUpdateMeta(line PostReceiveLine) RefUpdateMeta {
62
+
func (g *GitRepo) RefUpdateMeta(line PostReceiveLine) (RefUpdateMeta, error) {
commitCount, err := g.newCommitCount(line)
66
+
errors.Join(errs, err)
isDefaultRef, err := g.isDefaultBranch(line)
69
+
errors.Join(errs, err)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
breakdown, err := g.AnalyzeLanguages(ctx)
74
+
errors.Join(errs, err)
CommitCount: commitCount,
IsDefaultRef: isDefaultRef,
LangBreakdown: breakdown,
func (g *GitRepo) newCommitCount(line PostReceiveLine) (CommitCount, error) {
···
args := []string{fmt.Sprintf("--max-count=%d", 100)}
if line.OldSha.IsZero() {
98
-
// just git rev-list <newsha>
96
+
// git rev-list <newsha> ^other-branches --not ^this-branch
args = append(args, line.NewSha.String())
99
+
branches, _ := g.Branches()
100
+
for _, b := range branches {
101
+
if !strings.Contains(line.Ref, b.Name) {
102
+
args = append(args, fmt.Sprintf("^%s", b.Name))
106
+
args = append(args, "--not")
107
+
args = append(args, fmt.Sprintf("^%s", line.Ref))
// git rev-list <oldsha>..<newsha>
args = append(args, fmt.Sprintf("%s..%s", line.OldSha.String(), line.NewSha.String()))