Repository navigation
Use git config user.email to determine the author email used when merging with gh pr merge - #5229
jtaylor100 wants to merge 2 commits into
Conversation
mislav
left a comment
There was a problem hiding this comment.
Thanks, this looks good so far!
Note that we will have to discuss this feature with our team to make sure we're not introducing too much "magic" by respecting user.email of the current repo. Please allow us some time ponder about this.
In the meantime, could you also add a flag to pr merge so that the user can also explicitly set the email address to be able to opt out of the behavior of reading git config? The flag could be called --author-email for now. Thank you!
|
|
||
| // ignore error, since git.Config will return "" for | ||
| // authorEmail if any error occurs | ||
| authorEmail, _ := git.Config("user.email") |
There was a problem hiding this comment.
This respects the global setting, but also respects the per-checkout setting when inside of a git checkout of a repo. Should we respect the local setting even when merging a PR in another repository?
For example: I'm in the local directory of repoA, but I'm merging a PR in repoB: gh pr merge --repo mislav/repoB 123. Even though I've explicitly selected the repository to be another repository, git config user.email will read and apply the setting for repoA to my merge, ending in a potentially unwanted result.
There was a problem hiding this comment.
Ahh, yes that is an interesting case. Intuitively I believe the behaviour should be: if a repo is specified other than the current directory's repo, then always fall back to the GitHub default email.
|
@mislav Would you advise putting the work to create a flag in a different PR? |
|
@jtaylor100 No, I would put it all together because it closely relates to the issue this is all aiming to address. |
|
Given the discomfort with introducing implicit coupling with a git config value, we've decided to close this; however, we'd consider a new PR adding a flag to |
This was done because, as of the 1b5df39 commit, merge commits are now authored by me instead of the GitHub Actions user. Which isn't desirable. Unfortunately, the GitHub (gh) CLI client doesn't seem to respect Git's user.email configuration, and the client maintainers haven't been comfortable adding support in the past (at least when reading this pull request: cli/cli#5229). Hence, I've decided to use the git CLI client instead. The fetch-depth parameter is set to 0 to prevent the 'fatal: refusing to merge unrelated histories' error from occurring. Also, then token parameter was set so the CLI client would use the fine-grained access token. Documentation for the GitHub Actions user can be seen here: https://github.com/actions/checkout#push-a-commit-using-the-built-in-token.
This was done because, as of the 1b5df39 commit, merge commits are now authored by me instead of the GitHub Actions user. Which isn't desirable. Unfortunately, the GitHub (gh) CLI client doesn't seem to respect Git's user.email configuration, and the client maintainers haven't been comfortable adding support in the past (at least when reading this pull request: cli/cli#5229). Hence, I've decided to use the Git CLI client instead. The fetch-depth parameter is set to 0 to prevent the 'fatal: refusing to merge unrelated histories' error from occurring. Also, then token parameter was set so the CLI client would use the fine-grained access token. Documentation for the GitHub Actions user can be seen here: https://github.com/actions/checkout#push-a-commit-using-the-built-in-token.
Fixes #1450
Tested on https://github.com/jtaylor100/test-repo
git config user.emailfrom the repo as the author email.git config user.emailwas empty, so the default GitHub email is used.