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 revisionsfield to CountCommitsRequest - Updates validation to allow pseudo-revisions using AllowPseudoRevision()
- Maintains backward compatibility with existing
revisionandallfields - The new
revisionsfield takes precedence when provided
Example usage:
- Count commits in all branches: revisions=["--branches"]
- Count commits excluding a ref: revisions=["HEAD", "--not", "main"]