Preserve git log order in commit list date grouping

What does this MR do and why?

The new Vue-based repository commit list groups commits under date headers using a JavaScript Map keyed by calendar day (groupCommitsByDay in app/assets/javascripts/projects/commits/utils/commit_grouping.js). A Map merges all same-day commits into a single bucket at the day's first occurrence. Because git log orders commits by committer date constrained by topology (a child always precedes its parent, and committer dates can be arbitrary), its output is not necessarily strictly date-ordered — so non-adjacent same-day commits got pulled together, reordering commits relative to git log and showing date headers out of chronological order. A user reported this after comparing the page with git log output.

This MR changes the grouping to chunk only consecutive same-day commits: a new group starts whenever the day changes from the previous commit. This preserves git log order exactly and repeats the date header when a day reappears — identical to the legacy HAML page behavior, which used Ruby's chunk (app/views/projects/commits/_commits.html.haml) and is still used today by the MR commits tab. The grouping already used the committer date; the bug was purely the grouping strategy. Since a day can now legitimately appear more than once, the v-for :key for date groups changed from group.day to group.commits[0].id. A regression test replicates the reporter's repo: commits in git log order [3 (Sep 15), 2 (Sep 16), 1 (Sep 15)] must yield three groups instead of merging commits 3 and 1.

Date headers now repeat for such histories, matching the legacy HAML page and the MR commits tab. UX input will be requested on the draft MR. The screen-reader implications of repeated headers are addressed by the accessibility change below.

Accessibility

Repeated date headers create a screen-reader concern, raised in !256836 (comment 3884657160): a user navigating by heading hears the same date twice with a different date in between and cannot tell whether it is a new section, a re-announcement of the heading they were just on, or a rendering error.

groupCommitsByDay now returns an isRepeatedDay boolean on each group — true when the day already appeared in an earlier, non-adjacent group. The date heading uses this flag to append a visually hidden clarifier on repeat occurrences only:

<span class="gl-sr-only">another group from this date</span>

The repeated heading is announced as e.g. "Sep 15, 2026 another group from this date". Sighted users see no change — the span is clipped to a 1px box via gl-sr-only. The other two suggestions from that thread were already satisfied by this MR: unique DOM identity per group (:key="group.commits[0].id") and machine-readable dates (<time :datetime="group.day">). Verified locally with VoiceOver heading navigation (VO+Cmd+H).

Two accepted limitations:

  • Repeat occurrences are distinguished from the first occurrence but not from each other. Adding ordinals or counts ("second", "2 of 3") is impractical to translate, and the triple-repeat case requires two separate date inversions on a single page, which is vanishingly rare in practice. WCAG 2.4.6 requires headings to be descriptive, not unique.
  • The flag is computed client-side per page of results. A repeat that lands on the next page is not flagged, because the page boundary resets the seen-days set. This is the same information a sighted user has per page.

References

Screenshots or screen recordings

Before After
01-before-fix-wrong-order 02-after-fix-matches-git-log

Verification recording:

How to set up and validate locally

  1. Create a test repo where committer dates are deliberately out of order relative to topology, using GIT_COMMITTER_DATE:

    • commit "1" at 2026-09-15T10:00+02:00
    • commit "2" at 2026-09-16T10:00+02:00
    • commit "3" at 2026-09-15T11:00+02:00

    (A public reproduction repo exists at https://gitlab.com/zdenekdrahos/gitlab-commit-history-test.)

  2. Push it to a project on your instance.

  3. Open the project's commit list page at /-/commits/main.

  4. Verify the order shown matches git log exactly: a Sep 15 header with commit 3, then a Sep 16 header with commit 2, then a repeated Sep 15 header with commit 1.

  5. Inspect the repeated Sep 15 heading in DevTools and confirm it contains a <span class="gl-sr-only"> reading "another group from this date", while the first Sep 15 heading does not. Optionally navigate headings with a screen reader (VoiceOver: VO+Cmd+H) and confirm the repeated heading is announced as "Sep 15, 2026 another group from this date".

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Chaoyue Zhao

Merge request reports

Loading
Loading