summaryrefslogtreecommitdiff
path: root/app/models/commit.rb
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-09-01 10:24:29 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-09-01 10:24:29 +0000
commit096850a49abb54041cb3086ae34deb11e7380cb7 (patch)
tree3303bb2ecca3957212a48b3aa94e64b75f849c95 /app/models/commit.rb
parent15ad0ac1e741e462c3742cd4db8ca008a0c4f61d (diff)
parent934eef72902d6e753f47f7f8dbc42959c399ad09 (diff)
downloadgitlab-ce-096850a49abb54041cb3086ae34deb11e7380cb7.tar.gz
Merge branch 'sm-cherry-pick-list-commits-in-message' into 'master'
Add 'from commit' information to cherry-picked commits See merge request !13475
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index d41c88b4e30..c943365016f 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -251,6 +251,28 @@ class Commit
project.repository.next_branch("cherry-pick-#{short_id}", mild: true)
end
+ def cherry_pick_description(user)
+ message_body = "(cherry picked from commit #{sha})"
+
+ if merged_merge_request?(user)
+ commits_in_merge_request = merged_merge_request(user).commits
+
+ if commits_in_merge_request.present?
+ message_body << "\n"
+
+ commits_in_merge_request.reverse.each do |commit_in_merge|
+ message_body << "\n#{commit_in_merge.short_id} #{commit_in_merge.title}"
+ end
+ end
+ end
+
+ message_body
+ end
+
+ def cherry_pick_message(user)
+ %Q{#{message}\n\n#{cherry_pick_description(user)}}
+ end
+
def revert_description(user)
if merged_merge_request?(user)
"This reverts merge request #{merged_merge_request(user).to_reference}"