CountCommits: Add support for pseudo-revisions

Contributes to CountCommits RPC doesn't support pseudo-revisio... (#7030 - closed)

Summary

The CountCommits RPC currently only supports a single revision via the revision field (or the --all flag), while ListCommits supports multiple revisions including pseudo-revisions like --branches, --tags, --not, and --glob through its revisions array field. This creates an inconsistency in the API and limits the functionality of CountCommits.

Proposal

Extend CountCommits RPC to support pseudo-revisions like --branches, --tags, --not, --all, and --glob by introducing a new revisions field that accepts multiple revisions.

This brings CountCommits in line with ListCommits functionality, allowing users to count commits across multiple refs and use Git's pseudo-revision syntax for more flexible queries.

The implementation:

  • Adds a repeated string revisions field to CountCommitsRequest
  • Updates validation to allow pseudo-revisions using AllowPseudoRevision()
  • Maintains backward compatibility with existing revision and all fields
  • The new revisions field takes precedence when provided

Example usage:

  • Count commits in all branches: revisions=["--branches"]
  • Count commits excluding a ref: revisions=["HEAD", "--not", "main"]

Merge request reports

Loading