diff options
author | Saverio Miroddi <saverio.pub2@gmail.com> | 2017-08-15 19:35:28 +0200 |
---|---|---|
committer | Saverio Miroddi <saverio.pub2@gmail.com> | 2017-08-15 19:35:28 +0200 |
commit | 3d7febc01c98baaeb6c937fa63d2bf23681cc8d2 (patch) | |
tree | ba29fdff7466c1baf604fd0858c86ce2794c0411 /app/models/commit.rb | |
parent | cd80a9075f5f2b3150c909a6cd56e7c8f239bd51 (diff) | |
download | gitlab-ce-3d7febc01c98baaeb6c937fa63d2bf23681cc8d2.tar.gz |
Extracted cherry-pick description in ::Commit
This also fixes the inconsistency between non/merge commits in the number of newlines introduced.
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r-- | app/models/commit.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index 24732b6dd29..9b5f3212bf3 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -251,15 +251,15 @@ class Commit project.repository.next_branch("cherry-pick-#{short_id}", mild: true) end - def cherry_pick_message(start_branch_name) - message_buffer = message.dup - + def cherry_pick_description(start_branch_name) if merge_commit? + message_buffer = "" + 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}" + message_buffer << "cherry picked from merge #{merge_commit.sha}" if commits_in_merge.present? message_buffer << "; commits:" @@ -268,11 +268,15 @@ class Commit message_buffer << "\n- #{commit_in_merge.sha}" end end + + message_buffer else - message_buffer << "\ncherry picked from commit #{sha}" + "cherry picked from commit #{sha}" end + end - message_buffer + def cherry_pick_message(start_branch_name) + %Q{#{message}\n\n#{cherry_pick_description(start_branch_name)}} end def revert_description(user) |