From bba1eda899daeb081d2524760968eca1e0e52dd7 Mon Sep 17 00:00:00 2001 From: kellda <59569234+kellda@users.noreply.github.com> Date: Thu, 9 Sep 2021 19:09:03 +0200 Subject: [PATCH] Read authorship information from last commit when squashing --- homu/main.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/homu/main.py b/homu/main.py index e90723b..57b5858 100644 --- a/homu/main.py +++ b/homu/main.py @@ -1027,6 +1027,15 @@ def create_merge(state, repo_cfg, branch, logger, git_cfg, ok = False if state.squash: try: + first_commit = subprocess.check_output( + git_cmd('cherry', 'origin/master', + state.head_sha))[2:42].decode('ascii') + author_name = subprocess.check_output( + git_cmd('log', '-1', '--format="%an"', + first_commit)).decode('ascii').strip() + author_email = subprocess.check_output( + git_cmd('log', '-1', '--format="%ae"', + first_commit)).decode('ascii').strip() merge_base_sha = subprocess.check_output( git_cmd( 'merge-base', @@ -1038,9 +1047,9 @@ def create_merge(state, repo_cfg, branch, logger, git_cfg, merge_base_sha)) utils.logged_call(git_cmd( '-c', - 'user.name=' + git_cfg['name'], + 'user.name=' + author_name, '-c', - 'user.email=' + git_cfg['email'], + 'user.email=' + author_email, 'commit', '-m', squash_msg))