diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-06-23 14:58:14 +0530 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-07-13 13:24:56 +0530 |
commit | 495db09653bafb0371e5d5a5f12d5bc33cdb584b (patch) | |
tree | a524d76e48cb8c34e414ac4ee422f33dfa6625e2 /lib/gitlab/checks | |
parent | f0577d838544152f558411ef1101d56c5852d92e (diff) | |
download | gitlab-ce-495db09653bafb0371e5d5a5f12d5bc33cdb584b.tar.gz |
Enforce "developers can merge" during `pre-receive`.
1. When a merge request is being merged, save the merge commit SHA in
the `in_progress_merge_commit_sha` database column.
2. The `pre-receive` hook looks for any locked (in progress) merge
request with `in_progress_merge_commit_sha` matching the `newrev` it
is passed.
3. If it finds a matching MR, the merge is legitimate.
4. Update `git_access_spec` to test the behaviour we added here. Also
refactored this spec a bit to make it easier to add more contexts / conditions.
Diffstat (limited to 'lib/gitlab/checks')
-rw-r--r-- | lib/gitlab/checks/matching_merge_request.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/gitlab/checks/matching_merge_request.rb b/lib/gitlab/checks/matching_merge_request.rb new file mode 100644 index 00000000000..849848515da --- /dev/null +++ b/lib/gitlab/checks/matching_merge_request.rb @@ -0,0 +1,18 @@ +module Gitlab + module Checks + class MatchingMergeRequest + def initialize(newrev, branch_name, project) + @newrev = newrev + @branch_name = branch_name + @project = project + end + + def match? + @project.merge_requests + .with_state(:locked) + .where(in_progress_merge_commit_sha: @newrev, target_branch: @branch_name) + .exists? + end + end + end +end |