diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-09-01 13:24:29 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-09-01 13:24:29 +0300 |
commit | 096850a49abb54041cb3086ae34deb11e7380cb7 (patch) | |
tree | 3303bb2ecca3957212a48b3aa94e64b75f849c95 /app | |
parent | 15ad0ac1e741e462c3742cd4db8ca008a0c4f61d (diff) | |
parent | 934eef72902d6e753f47f7f8dbc42959c399ad09 (diff) |
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')
-rw-r--r-- | app/models/commit.rb | 22 | ||||
-rw-r--r-- | app/models/repository.rb | 2 |
2 files changed, 23 insertions, 1 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}" diff --git a/app/models/repository.rb b/app/models/repository.rb index b3fa51a14f7..5474c8eeb68 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -908,7 +908,7 @@ class Repository committer = user_to_committer(user) - create_commit(message: commit.message, + create_commit(message: commit.cherry_pick_message(user), author: { email: commit.author_email, name: commit.author_name, |