Commit 7c6287c8 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add support of custom message to merge action of satellite

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 5c1a360f
...@@ -125,34 +125,31 @@ module Gitlab ...@@ -125,34 +125,31 @@ module Gitlab
# #
# Returns false if the merge produced conflicts # Returns false if the merge produced conflicts
# Returns true otherwise # Returns true otherwise
def merge_in_satellite!(repo) def merge_in_satellite!(repo, message = nil)
update_satellite_source_and_target!(repo) update_satellite_source_and_target!(repo)
merge_message = "Merge branch '#{merge_request.source_branch}' into '#{merge_request.target_branch}'"
if message
merge_message << "\n\n"
merge_message << message
end
# merge the source branch into the satellite # merge the source branch into the satellite
# will raise CommandFailed when merge fails # will raise CommandFailed when merge fails
if merge_request.for_fork? repo.git.merge(default_options({no_ff: true}), "-m #{merge_message}", "source/#{merge_request.source_branch}")
repo.git.pull(default_options({no_ff: true}), 'source', merge_request.source_branch)
else
repo.git.pull(default_options({no_ff: true}), 'origin', merge_request.source_branch)
end
rescue Grit::Git::CommandFailed => ex rescue Grit::Git::CommandFailed => ex
handle_exception(ex) handle_exception(ex)
end end
# Assumes a satellite exists that is a fresh clone of the projects repo, prepares satellite for merges, diffs etc # Assumes a satellite exists that is a fresh clone of the projects repo, prepares satellite for merges, diffs etc
def update_satellite_source_and_target!(repo) def update_satellite_source_and_target!(repo)
if merge_request.for_fork? repo.remote_add('source', merge_request.source_project.repository.path_to_repo)
repo.remote_add('source', merge_request.source_project.repository.path_to_repo) repo.remote_fetch('source')
repo.remote_fetch('source') repo.git.checkout(default_options({b: true}), merge_request.target_branch, "origin/#{merge_request.target_branch}")
repo.git.checkout(default_options({b: true}), merge_request.target_branch, "origin/#{merge_request.target_branch}")
else
repo.git.checkout(default_options, "#{merge_request.source_branch}")
repo.git.checkout(default_options({t: true}), "origin/#{merge_request.target_branch}")
end
rescue Grit::Git::CommandFailed => ex rescue Grit::Git::CommandFailed => ex
handle_exception(ex) handle_exception(ex)
end end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment