Commit 7c6287c878c3106492c1f96d7624e99aa6c8b398
1 parent
5c1a360f
Exists in
spb-stable
and in
3 other branches
Add support of custom message to merge action of satellite
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
1 changed file
with
12 additions
and
15 deletions
Show diff stats
lib/gitlab/satellite/merge_action.rb
| @@ -125,34 +125,31 @@ module Gitlab | @@ -125,34 +125,31 @@ module Gitlab | ||
| 125 | # | 125 | # |
| 126 | # Returns false if the merge produced conflicts | 126 | # Returns false if the merge produced conflicts |
| 127 | # Returns true otherwise | 127 | # Returns true otherwise |
| 128 | - def merge_in_satellite!(repo) | 128 | + def merge_in_satellite!(repo, message = nil) |
| 129 | update_satellite_source_and_target!(repo) | 129 | update_satellite_source_and_target!(repo) |
| 130 | 130 | ||
| 131 | + merge_message = "Merge branch '#{merge_request.source_branch}' into '#{merge_request.target_branch}'" | ||
| 132 | + | ||
| 133 | + if message | ||
| 134 | + merge_message << "\n\n" | ||
| 135 | + merge_message << message | ||
| 136 | + end | ||
| 137 | + | ||
| 131 | # merge the source branch into the satellite | 138 | # merge the source branch into the satellite |
| 132 | # will raise CommandFailed when merge fails | 139 | # will raise CommandFailed when merge fails |
| 133 | - if merge_request.for_fork? | ||
| 134 | - repo.git.pull(default_options({no_ff: true}), 'source', merge_request.source_branch) | ||
| 135 | - else | ||
| 136 | - repo.git.pull(default_options({no_ff: true}), 'origin', merge_request.source_branch) | ||
| 137 | - end | 140 | + repo.git.merge(default_options({no_ff: true}), "-m #{merge_message}", "source/#{merge_request.source_branch}") |
| 138 | rescue Grit::Git::CommandFailed => ex | 141 | rescue Grit::Git::CommandFailed => ex |
| 139 | handle_exception(ex) | 142 | handle_exception(ex) |
| 140 | end | 143 | end |
| 141 | 144 | ||
| 142 | # Assumes a satellite exists that is a fresh clone of the projects repo, prepares satellite for merges, diffs etc | 145 | # Assumes a satellite exists that is a fresh clone of the projects repo, prepares satellite for merges, diffs etc |
| 143 | def update_satellite_source_and_target!(repo) | 146 | def update_satellite_source_and_target!(repo) |
| 144 | - if merge_request.for_fork? | ||
| 145 | - repo.remote_add('source', merge_request.source_project.repository.path_to_repo) | ||
| 146 | - repo.remote_fetch('source') | ||
| 147 | - repo.git.checkout(default_options({b: true}), merge_request.target_branch, "origin/#{merge_request.target_branch}") | ||
| 148 | - else | ||
| 149 | - repo.git.checkout(default_options, "#{merge_request.source_branch}") | ||
| 150 | - repo.git.checkout(default_options({t: true}), "origin/#{merge_request.target_branch}") | ||
| 151 | - end | 147 | + repo.remote_add('source', merge_request.source_project.repository.path_to_repo) |
| 148 | + repo.remote_fetch('source') | ||
| 149 | + repo.git.checkout(default_options({b: true}), merge_request.target_branch, "origin/#{merge_request.target_branch}") | ||
| 152 | rescue Grit::Git::CommandFailed => ex | 150 | rescue Grit::Git::CommandFailed => ex |
| 153 | handle_exception(ex) | 151 | handle_exception(ex) |
| 154 | end | 152 | end |
| 155 | - | ||
| 156 | end | 153 | end |
| 157 | end | 154 | end |
| 158 | end | 155 | end |