Skip to content

gh pr merge: default to git user.email for merge commit #8590

Open

Description

@sophec

Describe the feature or problem you’d like to solve

With multiple emails on my GitHub account, I have git configured to automatically change the email address used for commits to work repos to my work email and vice versa. However, gh pr merge uses my account's primary email address rather than respecting my git configuration. For example, if the primary email on the account is [email protected] and git config user.email returns [email protected], gh pr merge will still create the merge commit with [email protected] as the email address. On the GitHub website, merging a PR defaults to my default email for the organization/repository, I think.

Proposed solution

Perhaps gh pr merge could check if the email address for the current repo is configured to something other than the default?

Additional context

If it matters, my email is sometimes specified in .git/config, but other times it is not--I have git configured globally to automatically change the email address used for repositories matching work URL patterns. In either case, git config user.email would return the correct one for the local repository.

Activity

  1. added
    enhancement
    on Jan 17, 2024
  2. added
    needs-triage
    on Jan 17, 2024
  3. sophec commented on Jan 17, 2024

    @sophec
    Author

    Alas, in my ideal world, the commit would be made locally (as if I had manually done the merge), but it does make sense that it's not, I just wish I didn't have to specify -A all the time for this.

  4. added
    gh-pr
    on Feb 9, 2024
  5. williammartin commented on Feb 21, 2024

    @williammartin
    Member

    Hey @willeccles thanks for opening this issue and sorry for the delay in responding after Christmas vacation. Some team changes and a large backlog. There's definitely room for improvement in this flow, particularly with the multi-account support that landed before Christmas.

    There have been a few discussions around email linked below but most specifically there has been a PR closed by previous maintainers that tried to add this support: #5229

    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 pr merge for setting author info.

    Sadly, none of the maintainers that were around when that decision was made are still involved the project, so I'm not sure what their discomfort really involved. If I were to guess, I would say that the issue relates to potentially having a global git configuration set, or even a conditional configuration set (e.g. work vs personal) that has a totally different email to what you might expect. It could additionally be surprising behaviour for everyone if their emails suddenly changed under their feet.

    However, it's clearly a desired feature. I wonder whether there might be a path to support this with a gh specific configuration so that it could be opted into. What do you think?

    Some further reading:

  6. added
    more-info-needed
    and removed
    needs-triage
    on Feb 21, 2024
  7. sophec commented on Feb 21, 2024

    @sophec
    Author

    Hi @williammartin, I agree that it sounds like perhaps a gh specific configuration option might be a good solution--perhaps an option to enable it to fall back to git configuration to determine the email address? From the issues you linked, it seems that this is indeed desired behavior, but it sounds like perhaps the original maintainers were also correct that this should not be default behavior.

  8. added
    core
    and removed
    more-info-needed
    on Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreenhancementgh-pr

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions