Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/github/githubRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,10 @@ export class GitHubRepository extends Disposable {
const { data } = await octokit.call(octokit.api.users.listEmailsForAuthenticatedUser, {});
Logger.debug(`Fetch authenticated user emails - done`, this.id);
// sort the primary email to the first index
return data.filter(email => email.visibility === 'public' || email.email.toLowerCase().endsWith('@users.noreply.github.com')).sort((a, b) => +b.primary - +a.primary).map(email => email.email);
const hasPrivate = data.some(email => email.visibility === 'private');
return data.filter(email => hasPrivate ? email.email.endsWith('@users.noreply.github.com') : email.verified)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GitHub API is unclear, but I think this fix makes sense.

.sort((a, b) => +b.primary - +a.primary)
.map(email => email.email);
} catch (e) {
Logger.error(`Unable to fetch authenticated user emails: ${e}`, this.id);
return [];
Expand Down