Skip to content

Commit bba1eda

Browse files
committed
Read authorship information from last commit when squashing
1 parent 2ee9234 commit bba1eda

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

homu/main.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,15 @@ def create_merge(state, repo_cfg, branch, logger, git_cfg,
10271027
ok = False
10281028
if state.squash:
10291029
try:
1030+
first_commit = subprocess.check_output(
1031+
git_cmd('cherry', 'origin/master',
1032+
state.head_sha))[2:42].decode('ascii')
1033+
author_name = subprocess.check_output(
1034+
git_cmd('log', '-1', '--format="%an"',
1035+
first_commit)).decode('ascii').strip()
1036+
author_email = subprocess.check_output(
1037+
git_cmd('log', '-1', '--format="%ae"',
1038+
first_commit)).decode('ascii').strip()
10301039
merge_base_sha = subprocess.check_output(
10311040
git_cmd(
10321041
'merge-base',
@@ -1038,9 +1047,9 @@ def create_merge(state, repo_cfg, branch, logger, git_cfg,
10381047
merge_base_sha))
10391048
utils.logged_call(git_cmd(
10401049
'-c',
1041-
'user.name=' + git_cfg['name'],
1050+
'user.name=' + author_name,
10421051
'-c',
1043-
'user.email=' + git_cfg['email'],
1052+
'user.email=' + author_email,
10441053
'commit',
10451054
'-m',
10461055
squash_msg))

0 commit comments

Comments
 (0)