Commit 3824f9b3 authored by randx's avatar randx

Unverify MR on every push. Ajax for MR accept. better UI

parent 411d84f3
...@@ -90,6 +90,7 @@ class MergeRequestsController < ApplicationController ...@@ -90,6 +90,7 @@ class MergeRequestsController < ApplicationController
respond_to do |format| respond_to do |format|
if @merge_request.update_attributes(params[:merge_request].merge(:author_id_of_changes => current_user.id)) if @merge_request.update_attributes(params[:merge_request].merge(:author_id_of_changes => current_user.id))
@merge_request.reload_code @merge_request.reload_code
@merge_request.mark_as_unchecked
format.html { redirect_to [@project, @merge_request], notice: 'Merge request was successfully updated.' } format.html { redirect_to [@project, @merge_request], notice: 'Merge request was successfully updated.' }
format.json { head :ok } format.json { head :ok }
else else
...@@ -101,8 +102,7 @@ class MergeRequestsController < ApplicationController ...@@ -101,8 +102,7 @@ class MergeRequestsController < ApplicationController
def automerge def automerge
render_404 unless @merge_request.open? && @merge_request.can_be_merged? render_404 unless @merge_request.open? && @merge_request.can_be_merged?
message = @merge_request.automerge! ? "Successfully merged" : "Can not be merged" @merge_request.automerge!(current_user)
redirect_to [@merge_request.project, @merge_request], :alert => message
end end
def destroy def destroy
......
...@@ -64,6 +64,10 @@ class MergeRequest < ActiveRecord::Base ...@@ -64,6 +64,10 @@ class MergeRequest < ActiveRecord::Base
state == UNCHECKED state == UNCHECKED
end end
def mark_as_unchecked
self.update_attributes(:state => UNCHECKED)
end
def can_be_merged? def can_be_merged?
state == CAN_BE_MERGED state == CAN_BE_MERGED
end end
...@@ -170,7 +174,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -170,7 +174,7 @@ class MergeRequest < ActiveRecord::Base
) )
end end
def automerge! def automerge!(current_user)
if GitlabMerge.new(self).merge if GitlabMerge.new(self).merge
self.merge!(current_user.id) self.merge!(current_user.id)
true true
......
...@@ -19,7 +19,7 @@ module Project::HooksTrait ...@@ -19,7 +19,7 @@ module Project::HooksTrait
# Update code for merge requests # Update code for merge requests
mrs = self.merge_requests.opened.find_all_by_branch(branch_name).all mrs = self.merge_requests.opened.find_all_by_branch(branch_name).all
mrs.each { |merge_request| merge_request.reload_code } mrs.each { |merge_request| merge_request.reload_code; merge_request.mark_as_unchecked }
# Close merge requests # Close merge requests
mrs = self.merge_requests.opened.where(:target_branch => branch_name).all mrs = self.merge_requests.opened.where(:target_branch => branch_name).all
......
...@@ -54,11 +54,10 @@ ...@@ -54,11 +54,10 @@
- if @merge_request.open? && @commits.any? - if @merge_request.open? && @commits.any?
- if @merge_request.can_be_merged? - if @merge_request.can_be_merged?
.alert-message.info .ui-box.padded
%p %p
You can accept this request automatically. If you still want to do it manually - #{link_to "click here", "#", :class => "how_to_merge_link cwhite", :title => "How To Merge"} for instructions You can accept this request automatically. If you still want to do it manually - #{link_to "click here", "#", :class => "how_to_merge_link vlink", :title => "How To Merge"} for instructions
.alert-actions = link_to "Accept Merge Request", automerge_project_merge_request_path(@project, @merge_request), :class => "btn small info accept_merge_request", :remote => true
= link_to "Accept Merge Request", automerge_project_merge_request_path(@project, @merge_request), :class => "btn small info"
&nbsp; &nbsp;
- else - else
...@@ -88,6 +87,10 @@ ...@@ -88,6 +87,10 @@
:javascript :javascript
$(function(){ $(function(){
MergeRequest.init(); MergeRequest.init();
$(".accept_merge_request").live("ajax:beforeSend", function() {
$(this).replaceWith('#{image_tag "ajax_loader.gif"}');
})
}) })
= render "notes/per_line_form" = render "notes/per_line_form"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment