Skip to content

Fix Git::Lib#commit_data for GPG-signed commits #610

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

Merged
merged 9 commits into from
Feb 2, 2023
Merged
Prev Previous commit
Next Next commit
Remove #process_commmit_data indent parameter
This was introduced in [1] to handle variance in indentation when
parsing commit messages; at the time the #process_commit_data method had
two callers, one which used it to process log lines, and the other which
used it to process the output of `git cat-file commit <SHA>`. The former
sees a 4-space indent, the latter, zero.

Since [2], however, the log processing has been handled by
the #process_commit_log_data method, so #process_commit_data exclusively
handles un-indented inputs, and we can remove the indent parameter.

[1] 05117d4
[2] 97e1fff

Signed-off-by: Simon Coffey <simon.coffey@futurelearn.com>
  • Loading branch information
Simon Coffey committed Jan 17, 2023
commit 59dd023f5c8d9c412eca72878657fdeb86cf15db
6 changes: 3 additions & 3 deletions lib/git/lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ def object_size(sha)
def commit_data(sha)
sha = sha.to_s
cdata = command_lines('cat-file', 'commit', sha)
process_commit_data(cdata, sha, 0)
process_commit_data(cdata, sha)
end

def process_commit_data(data, sha = nil, indent = 4)
def process_commit_data(data, sha = nil)
hsh = {
'sha' => sha,
'parent' => []
Expand All @@ -238,7 +238,7 @@ def process_commit_data(data, sha = nil, indent = 4)
end
end

hsh['message'] = data.collect {|line| line[indent..-1]}.join("\n") + "\n"
hsh['message'] = data.join("\n") + "\n"

return hsh
end
Expand Down