summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-01-24 14:18:32 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-01-24 14:18:32 +0200
commit48f741eed9f3676a8d0d089d7336fcffd31ebaa7 (patch)
tree4a1e24e29f0a4c90fc10f274f4e900c0064bcd20 /app/models
parentd1d138562a347ec78f0331d5242e28fbb368bad0 (diff)
downloadgitlab-ce-48f741eed9f3676a8d0d089d7336fcffd31ebaa7.tar.gz
MergeRequests services
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models')
-rw-r--r--app/models/merge_request.rb24
-rw-r--r--app/models/project.rb2
2 files changed, 12 insertions, 14 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 712d01626b5..444d6ab469b 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -50,17 +50,26 @@ class MergeRequest < ActiveRecord::Base
end
event :merge do
- transition [:reopened, :opened] => :merged
+ transition [:reopened, :opened, :locked] => :merged
end
event :reopen do
transition closed: :reopened
end
+ event :lock do
+ transition [:reopened, :opened] => :locked
+ end
+
+ event :unlock do
+ transition locked: :reopened
+ end
+
state :opened
state :reopened
state :closed
state :merged
+ state :locked
end
state_machine :merge_status, initial: :unchecked do
@@ -136,19 +145,8 @@ class MergeRequest < ActiveRecord::Base
self.target_project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::CLOSED).last
end
- def merge!(user_id)
- self.author_id_of_changes = user_id
- self.merge
- end
-
def automerge!(current_user, commit_message = nil)
- if Gitlab::Satellite::MergeAction.new(current_user, self).merge!(commit_message)
- self.merge!(current_user.id)
- true
- end
- rescue
- mark_as_unmergeable
- false
+ MergeRequests::AutoMergeService.new.execute(self, current_user, commit_message)
end
def mr_and_commit_notes
diff --git a/app/models/project.rb b/app/models/project.rb
index 579644d1119..d9da2c377c8 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -350,7 +350,7 @@ class Project < ActiveRecord::Base
# Close merge requests
mrs = self.merge_requests.opened.where(target_branch: branch_name).to_a
mrs = mrs.select(&:last_commit).select { |mr| c_ids.include?(mr.last_commit.id) }
- mrs.each { |merge_request| merge_request.merge!(user.id) }
+ mrs.each { |merge_request| MergeRequests::MergeService.new.execute(merge_request, user, nil) }
true
end