diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-07-16 16:03:07 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-07-16 16:03:07 +0200 |
commit | a7fded9b9529cfc08463afd4f6cf12478262e951 (patch) | |
tree | 69a0acd9145acc15a5f90a9bac07f041ccf62e72 /app/models/merge_request.rb | |
parent | 26f5d6047d6e21a5c65a4276266648f1e69aac4a (diff) | |
download | gitlab-ce-a7fded9b9529cfc08463afd4f6cf12478262e951.tar.gz |
Huge refactoring for accepting merge requests
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models/merge_request.rb')
-rw-r--r-- | app/models/merge_request.rb | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 4dcde029efa..631a2d887cc 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -41,8 +41,6 @@ class MergeRequest < ActiveRecord::Base delegate :commits, :diffs, :last_commit, :last_commit_short_sha, to: :merge_request_diff, prefix: nil - attr_accessor :should_remove_source_branch - # When this attribute is true some MR validation is ignored # It allows us to close or modify broken merge requests attr_accessor :allow_broken @@ -57,7 +55,7 @@ class MergeRequest < ActiveRecord::Base transition [:reopened, :opened] => :closed end - event :merge do + event :mark_as_merged do transition [:reopened, :opened, :locked] => :merged end @@ -223,14 +221,6 @@ class MergeRequest < ActiveRecord::Base self.target_project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::CLOSED).last end - def automerge!(current_user, commit_message = nil) - return unless automergeable? - - MergeRequests::AutoMergeService. - new(target_project, current_user). - execute(self, commit_message) - end - def open? opened? || reopened? end @@ -239,11 +229,11 @@ class MergeRequest < ActiveRecord::Base title =~ /\A\[?WIP\]?:? /i end - def automergeable? + def mergeable? open? && !work_in_progress? && can_be_merged? end - def automerge_status + def gitlab_merge_status if work_in_progress? "work_in_progress" else @@ -445,4 +435,13 @@ class MergeRequest < ActiveRecord::Base "refs/merge-requests/#{id}/head" ) end + + def in_locked_state + begin + lock_mr + yield + ensure + unlock_mr if locked? + end + end end |