Skip to content
Snippets Groups Projects
Commit 1d6ba597 authored by Saverio Miroddi's avatar Saverio Miroddi
Browse files

Add 'from commit' information to cherry-picked commits

Store the original commit in the commit message. In case of
merge commit, the commits added to the start branch are also
listed.
parent 3a9f210b
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -251,6 +251,30 @@ class Commit
project.repository.next_branch("cherry-pick-#{short_id}", mild: true)
end
 
def cherry_pick_message(start_branch_name)
message_buffer = message.dup
if merge_commit?
compare = CompareService.new(project, sha).execute(project, start_branch_name)
*commits_in_merge, merge_commit = compare.commits
message_buffer << "\n\ncherry picked from merge #{merge_commit.sha}"
if commits_in_merge.present?
message_buffer << "; commits:"
commits_in_merge.each do |commit_in_merge|
message_buffer << "\n- #{commit_in_merge.sha}"
end
end
else
message_buffer << "\ncherry picked from commit #{sha}"
end
message_buffer
end
def revert_description(user)
if merged_merge_request?(user)
"This reverts merge request #{merged_merge_request(user).to_reference}"
Loading
Loading
Loading
Loading
@@ -875,7 +875,9 @@ class Repository
 
committer = user_to_committer(user)
 
create_commit(message: commit.message,
commit_message = commit.cherry_pick_message(start_branch_name)
create_commit(message: commit_message,
author: {
email: commit.author_email,
name: commit.author_name,
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment