diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-08-14 17:52:49 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-08-14 17:52:49 +0200 |
commit | 9ea37cda3fa5e0aacf265bcb7739c1d4240f3bdc (patch) | |
tree | d4557426face47298c0195ae9c72efe42f99b69d | |
parent | f4149bcddca9c0e7aac078b3e7c198f5624ea107 (diff) | |
download | gitlab-ce-9ea37cda3fa5e0aacf265bcb7739c1d4240f3bdc.tar.gz |
merge with support of pre-receive and post-receive hooks
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | app/models/repository.rb | 18 | ||||
-rw-r--r-- | app/services/merge_requests/merge_service.rb | 14 |
2 files changed, 12 insertions, 20 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 99b6cd3cad1..f2f75e0e0f6 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -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) diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb index 2107529a21a..98a67c0bc99 100644 --- a/app/services/merge_requests/merge_service.rb +++ b/app/services/merge_requests/merge_service.rb @@ -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 |