Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions resources/js/lib/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function changelogDays(
timeZone: string,
): ChangelogDay[] {
const days: ChangelogDay[] = [];
let seenAuthors = new Set<string>();

for (const commit of commits) {
const date = new Date(commit.committed_at).toLocaleDateString('en-CA', {
Expand All @@ -53,13 +54,13 @@ export function changelogDays(
if (day?.date !== date) {
day = { date, commits: [], authors: [] };
days.push(day);
seenAuthors = new Set();
}

day.commits.push(commit);

if (
!day.authors.some((author) => author.login === commit.author.login)
) {
if (!seenAuthors.has(commit.author.login)) {
seenAuthors.add(commit.author.login);
day.authors.push(commit.author);
}
}
Expand Down
11 changes: 11 additions & 0 deletions tests/Unit/Changelog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,14 @@ void test('names the day relative to today in the reader’s time zone', () => {
assert.deepEqual(changelogDayHeading('2026-10-14', 'Europe/Budapest', now), { title: 'Wednesday', date: 'Oct 14' });
assert.deepEqual(changelogDayHeading('2025-12-31', 'Europe/Budapest', now), { title: 'Wednesday', date: 'Dec 31, 2025' });
});

void test('keeps the first author occurrence even for many commits on the same day', () => {
const commits = Array.from({ length: 200 }, (_, index) =>
commit(index, '2026-10-18T12:00:00Z', index % 2 === 0 ? 'alice' : 'bob'),
);
const days = changelogDays(commits, 'UTC');

assert.equal(days.length, 1);
assert.equal(days[0].commits.length, 200);
assert.deepEqual(days[0].authors.map(({ login }) => login), ['alice', 'bob']);
});