insights: fix FirstEverCommit returning wrong commit
Created by: coury-clark
Fixes #30433 (closed)
The behavior of FirstEverCommit
would return the wrong commit if there were multiple parent-less commits. This modifies the behavior to always return the oldest
commit. Note: we can't use --max-count=1
in combination with --reverse
, since git performs the reverse after the count filter.
To test this I created a fake repository locally, served it with src-cli
, and did the following:
- Created an initial commit
- Created an orphan branch, and committed a different file (to simulate divergent histories)
- Merged the branches together
The result in logs (over a backfill) is:
[enterprise-worker] INFO FirstEverCommit, lines: 521a8294b0f1ec5ebd8ba9b5922d83a556ac4a09
[enterprise-worker] 40c237ff816691e28a26202854c99bd0e023c14b, first: 521a8294b0f1ec5ebd8ba9b5922d83a556ac4a09
And you can see from the history page that this is indeed the oldest commit.