From 3cbc070c2f0eba79d3c4eb4ae947c7249a357f20 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Sun, 10 Aug 2025 23:12:58 +0100 Subject: [PATCH] knotserver: fix commit counting for branch creation Change-Id: ytkuzknmmrmnzunokyqknzzylwtwopmn rev-list was over-counting Signed-off-by: oppiliappan --- knotserver/git/post_receive.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/knotserver/git/post_receive.go b/knotserver/git/post_receive.go index 1b3ea94..9bf560d 100644 --- a/knotserver/git/post_receive.go +++ b/knotserver/git/post_receive.go @@ -95,8 +95,16 @@ func (g *GitRepo) newCommitCount(line PostReceiveLine) (CommitCount, error) { args := []string{fmt.Sprintf("--max-count=%d", 100)} if line.OldSha.IsZero() { - // just git rev-list + // git rev-list ^other-branches --not ^this-branch args = append(args, line.NewSha.String()) + + branches, _ := g.Branches() + for _, b := range branches { + args = append(args, fmt.Sprintf("^%s", b.Name)) + } + + args = append(args, "--not") + args = append(args, fmt.Sprintf("^%s", line.Ref)) } else { // git rev-list .. args = append(args, fmt.Sprintf("%s..%s", line.OldSha.String(), line.NewSha.String())) -- 2.43.0