Commit 9ea37cda authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

merge with support of pre-receive and post-receive hooks

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent f4149bcd
......@@ -392,7 +392,7 @@ class Repository
end
def remove_file(user, path, message, branch)
commit_with_hooks(user, branch) do |branch|
commit_with_hooks(user, branch) do |ref|
path[0] = '' if path[0] == '/'
committer = user_to_comitter(user)
......@@ -431,7 +431,7 @@ class Repository
end
end
def merge(source_sha, target_branch, options = {})
def merge(user, source_sha, target_branch, options = {})
our_commit = rugged.branches[target_branch].target
their_commit = rugged.lookup(source_sha)
......@@ -441,13 +441,15 @@ class Repository
merge_index = rugged.merge_commits(our_commit, their_commit)
return false if merge_index.conflicts?
actual_options = options.merge(
parents: [our_commit, their_commit],
tree: merge_index.write_tree(rugged),
update_ref: "refs/heads/#{target_branch}"
)
commit_with_hooks(user, target_branch) do |ref|
actual_options = options.merge(
parents: [our_commit, their_commit],
tree: merge_index.write_tree(rugged),
update_ref: ref
)
Rugged::Commit.create(rugged, actual_options)
Rugged::Commit.create(rugged, actual_options)
end
end
def search_files(query, ref)
......
......@@ -17,7 +17,7 @@ module MergeRequests
end
merge_request.in_locked_state do
if merge_changes
if commit
after_merge
success
else
......@@ -28,12 +28,6 @@ module MergeRequests
private
def merge_changes
if sha = commit
after_commit(sha, merge_request.target_branch)
end
end
def commit
committer = repository.user_to_comitter(current_user)
......@@ -43,11 +37,7 @@ module MergeRequests
committer: committer
}
repository.merge(merge_request.source_sha, merge_request.target_branch, options)
end
def after_commit(sha, branch)
PostCommitService.new(project, current_user).execute(sha, branch)
repository.merge(current_user, merge_request.source_sha, merge_request.target_branch, options)
end
def after_merge
......
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