Fix merge email confirmation when git config fails#6797
Merged
alexr00 merged 3 commits intomicrosoft:mainfrom Apr 22, 2025
Merged
Fix merge email confirmation when git config fails#6797alexr00 merged 3 commits intomicrosoft:mainfrom
alexr00 merged 3 commits intomicrosoft:mainfrom
Conversation
Centralizes the preferred email logic for a `PullRequestModel` in the `FolderRepositoryManager`. `PullRequestGitHelper.getEmail` can return an empty string when it is unable to find `user.email` in the local or global config. This can occur when the `user.email` config is set in a different scope (system, worktree) or its in an include file of the requested (local, global) scope (`git config` is not run with the `--includes` argument). Ideally there would be an API method to get config from _any_ scope, sadly this is not exposed on the `Repository` interface from the core git extension. If we are unable to get the email from git config, continue to default to the primary GitHub email and allow users to manually select the correct address to use. Use this same default email logic in the Activity Bar View so that the merge buttons behave in a similar manner with regard to what email is used for merge commits. See microsoft#6593, microsoft#6696
kabel
added a commit
to kabel/vscode
that referenced
this pull request
Apr 17, 2025
This allows extensions to get able to get configuration for any scope. This should prevent confusion when configuration can be excluded when requesting a specific scope. See microsoft/vscode-pull-request-github#6797
This state will be used when the email address from git config is unavailable or doesn't match any of the GitHub user's emails.
Contributor
Author
|
Additional log context on why the email is blank: So email got evaluated to |
alexr00
reviewed
Apr 22, 2025
| } | ||
|
|
||
| const gitHubEmails = await pullRequest.githubRepository.getAuthenticatedUserEmails(); | ||
| const getMatch = (match: string | undefined) => match && gitHubEmails.find(email => email.toLowerCase() === match.toLowerCase()); |
Member
There was a problem hiding this comment.
Can use compareIgnoreCase instead of toLowerCaseing both values.
alexr00
approved these changes
Apr 22, 2025
DonJayamanne
approved these changes
Apr 22, 2025
DonJayamanne
approved these changes
Apr 22, 2025
Member
|
/azp run |
|
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Centralizes the preferred email logic for a
PullRequestModelin theFolderRepositoryManager.PullRequestGitHelper.getEmailcan return an empty string when it is unable to finduser.emailin the local or global config. This can occur when theuser.emailconfig is set in a different scope (system, worktree) or its in an include file of the requested (local, global) scope (git configis not run with the--includesargument). Ideally there would be an API method to get config from any scope, sadly this is not exposed on theRepositoryinterface from the core git extension. If we are unable to get the email from git config, continue to default to the primary GitHub email and allow users to manually select the correct address to use.Use this same default email logic in the Activity Bar View so that the merge buttons behave in a similar manner with regard to what email is used for merge commits.
See #6593, #6696