Skip to content

Commit 4a897cf

Browse files
committed
Fix missing contributor dates for commits without linked GitHub accounts
When a commit author's email isn't linked to a GitHub account, the API returns author: null. The fetcher was filtering these out entirely, causing pages with only such commits to have no contributor data. Now uses the git commit author name as a fallback identity and preserves the commit date.
1 parent 180b01b commit 4a897cf

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/data-layer/fetchers/fetchGitHubContributors.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,21 @@ async function fetchCommitsForPath(
115115
return []
116116
}
117117

118-
// Transform to FileContributor format and deduplicate
119-
const contributors = commits
120-
.filter((commit: { author?: unknown }) => !!commit.author)
121-
.map(
122-
(commit: {
123-
author: { login: string; avatar_url: string; html_url: string }
124-
commit: { author: { date: string } }
125-
}) => ({
126-
login: commit.author.login,
127-
avatar_url: commit.author.avatar_url,
128-
html_url: commit.author.html_url,
129-
date: commit.commit.author.date,
130-
})
131-
)
118+
// Transform to FileContributor format and deduplicate.
119+
// When a commit author email isn't linked to a GitHub account, the API
120+
// returns `author: null`. We still include these commits so their date
121+
// is captured, using the git commit author name as a fallback identity.
122+
const contributors = commits.map(
123+
(commit: {
124+
author?: { login: string; avatar_url: string; html_url: string } | null
125+
commit: { author: { name: string; date: string } }
126+
}) => ({
127+
login: commit.author?.login ?? commit.commit.author.name,
128+
avatar_url: commit.author?.avatar_url ?? "",
129+
html_url: commit.author?.html_url ?? "",
130+
date: commit.commit.author.date,
131+
})
132+
)
132133

133134
// Remove duplicates by login (keep first = most recent)
134135
const seen = new Set<string>()

0 commit comments

Comments
 (0)