Skip to content

insights: fix FirstEverCommit returning wrong commit

Warren Gifford requested to merge insights/fix-first-commit into main

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:

  1. Created an initial commit
  2. Created an orphan branch, and committed a different file (to simulate divergent histories)
  3. 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.

CleanShot 2022-01-31 at 15 46 46@2x

Merge request reports

Loading