diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-12-09 09:37:38 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-12-09 09:37:38 +0000 |
commit | 7e8dc22dd7fb730d3fc47150cdfe95dc9ffdbc3a (patch) | |
tree | 17fb42e05aaa61b59bb4e95d72c42831c6de540f /app/models/commit_status.rb | |
parent | 291678d61358c141a7ba8cabf0e645408b52a8ea (diff) | |
parent | 903151141da36ed9b8c2333a9b66f5c611e4efb6 (diff) | |
download | gitlab-ce-7e8dc22dd7fb730d3fc47150cdfe95dc9ffdbc3a.tar.gz |
Merge branch 'merge-if-green' into 'master'
Merge when build succeeds
### What does this MR do?
Adds a button to a MR when the build/ci is running so it can be merged when/if the build is successfull.
### Are there points in the code the reviewer needs to double check?
English spelling and whether or not the grammer is correct.
### Why was this MR needed?
When you expect its all good, and don't want to revisit the current MR it can be accepted allready.
### What are the relevant issue numbers / Feature requests?
Fixes #2640 -- although `Merge if green` is replaced with `Merge when the build succeeds` the general idea is the same.
### Screenshots (if relevant)





### Further considerations
What if there are minor things needed solving, e.g. Rubocop, the current implementation will reset the approved status of the MR. It might be a consideration keep the approval for team member, or even guests. This would require an extra option in the Admin screen, though might add extra value.
#### TODO
- [x] Docs
- [x] Specs
/cc @DouweM @rspeicher
See merge request !1729
Diffstat (limited to 'app/models/commit_status.rb')
-rw-r--r-- | app/models/commit_status.rb | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index e70f4d37184..ff619965a57 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -1,34 +1,30 @@ # == Schema Information # -# Table name: ci_builds -# -# id :integer not null, primary key -# project_id :integer -# status :string(255) -# finished_at :datetime -# trace :text -# created_at :datetime -# updated_at :datetime -# started_at :datetime -# runner_id :integer -# coverage :float -# commit_id :integer -# commands :text -# job_id :integer -# name :string(255) -# deploy :boolean default(FALSE) -# options :text -# allow_failure :boolean default(FALSE), not null -# stage :string(255) -# trigger_request_id :integer -# stage_idx :integer -# tag :boolean -# ref :string(255) -# user_id :integer -# type :string(255) -# target_url :string(255) -# description :string(255) -# artifacts_file :text +# project_id integer +# status string +# finished_at datetime +# trace text +# created_at datetime +# updated_at datetime +# started_at datetime +# runner_id integer +# coverage float +# commit_id integer +# commands text +# job_id integer +# name string +# deploy boolean default: false +# options text +# allow_failure boolean default: false, null: false +# stage string +# trigger_request_id integer +# stage_idx integer +# tag boolean +# ref string +# user_id integer +# type string +# target_url string +# description string # class CommitStatus < ActiveRecord::Base @@ -79,6 +75,10 @@ class CommitStatus < ActiveRecord::Base build.update_attributes finished_at: Time.now end + after_transition [:pending, :running] => :success do |build, transition| + MergeRequests::MergeWhenBuildSucceedsService.new(build.commit.gl_project, nil).trigger(build) + end + state :pending, value: 'pending' state :running, value: 'running' state :failed, value: 'failed' |