Skip to content

Commit 0cb8c9b

Browse files
committed
Merge #147: github-merge: Add option to overwrite user email
8d229f8 github-merge: Add option to overwrite user email (MarcoFalke) 05df58e github-merge: Set git user name to merge-script (MarcoFalke) Pull request description: The merge script claims authorship of the merge commit, which is confusing: * The maintainer didn't author the merged code, nor the merge commit. Everything is done by the script. * In case of breach of a git hosting platform, such as GitHub, or the account of a maintainer, the hosting platform would allow a signed commit (signed by the hosting platform) to be pushed in the name of the maintainer. Thus, ... * ... the important thing to check for is the commit signature or the actual code changes, not the name (or email) of the maintainer. * Most modern software projects attribute their merges to a "merge" account, regardless of who triggered the merge. (For example, rust-lang) Solve this issue by: * Setting the git user name (committer and author) to "merge-script". * (optional) Allowing the maintainer to provide an email to use for the merge commit. Just as before, the merge commit is still required to be signed by the maintainer. Just as before, the git hosting platform will still denote which account was used to push the changes. ACKs for top commit: hebasto: ACK 8d229f8, I have reviewed the code and it looks OK. Tree-SHA512: 96b8468191d626cd54fab4aec26ae53109ca2967c7a1a19cd88fcb7bf6c7b43768b5e4d0677ec2228da856c75242fa3cabbc9cb7fdd5514f79af9dbe176a6a52
2 parents c4bef91 + 8d229f8 commit 0cb8c9b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

github-merge.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ def parse_arguments():
264264
githubmerge.pushmirrors (default: none, comma-separated list of mirrors to push merges of the master development branch to, e.g. `git@gitlab.com:<owner>/<repo>.git,git@github.com:<owner>/<repo>.git`),
265265
user.signingkey (mandatory),
266266
user.ghtoken (default: none).
267+
githubmerge.merge-author-email (default: Email from git config),
267268
githubmerge.host (default: git@github.com),
268269
githubmerge.branch (no default),
269270
githubmerge.testcmd (default: none).
@@ -283,6 +284,7 @@ def main():
283284
repo = git_config_get('githubmerge.repository')
284285
host = git_config_get('githubmerge.host','git@github.com')
285286
opt_branch = git_config_get('githubmerge.branch',None)
287+
merge_author_email = git_config_get('githubmerge.merge-author-email',None)
286288
testcmd = git_config_get('githubmerge.testcmd')
287289
ghtoken = git_config_get('user.ghtoken')
288290
signingkey = git_config_get('user.signingkey')
@@ -456,7 +458,10 @@ def main():
456458
reply = ask_prompt("Type 's' to sign off on the above merge, or 'x' to reject and exit.").lower()
457459
if reply == 's':
458460
try:
459-
subprocess.check_call([GIT,'commit','-q','--gpg-sign','--amend','--no-edit'])
461+
config = ['-c', 'user.name=merge-script']
462+
if merge_author_email:
463+
config += ['-c', f'user.email={merge_author_email}']
464+
subprocess.check_call([GIT] + config + ['commit','-q','--gpg-sign','--amend','--no-edit','--reset-author'])
460465
break
461466
except subprocess.CalledProcessError:
462467
print("Error while signing, asking again.",file=stderr)

0 commit comments

Comments
 (0)