Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read authorship information from last commit when squashing #152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions homu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Copy link
Member

@Alexendoo Alexendoo Jul 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ran into this again in clippy recently so it'd be nice to take another look at this (rust-lang/rust-clippy#8356)

I believe this should be merge_base_sha rather than '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',
Expand All @@ -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,
Comment on lines -1041 to +1052
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't these need to be escaped?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, I'll check. Probably not since we already give a list of arguments and not a single command line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it doesn't: arguments are passed as-is. Also note that squash_msg isn't escaped either.

'commit',
'-m',
squash_msg))
Expand Down