-
Notifications
You must be signed in to change notification settings - Fork 705
Fix merge email confirmation when git config fails #6797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
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.
|
Additional log context on why the email is blank: So email got evaluated to |
alexr00
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR
| } | ||
|
|
||
| const gitHubEmails = await pullRequest.githubRepository.getAuthenticatedUserEmails(); | ||
| const getMatch = (match: string | undefined) => match && gitHubEmails.find(email => email.toLowerCase() === match.toLowerCase()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use compareIgnoreCase instead of toLowerCaseing both values.
|
/azp run |
|
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
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