Link for auto merge, db field for MR
This commit is contained in:
parent
78d620b3b6
commit
cd74f9da91
|
@ -96,18 +96,23 @@ class MergeRequestsController < ApplicationController
|
|||
end
|
||||
|
||||
def automerge
|
||||
render_404 unless @merge_request.open?
|
||||
|
||||
message = ""
|
||||
|
||||
if GitlabMerge.new(@merge_request).merge
|
||||
@merge_request.update_attributes(
|
||||
:author_id_of_changes => current_user.id,
|
||||
:closed => true
|
||||
)
|
||||
@merge_request.reload_code
|
||||
@merge_request.merge!(current_user.id)
|
||||
message = "Successfully merged"
|
||||
else
|
||||
@merge_request.mark_as_unmergable
|
||||
message = "Can not be merged"
|
||||
end
|
||||
|
||||
redirect_to [@merge_request.project, @merge_request], :alert => message
|
||||
rescue => ex
|
||||
@merge_request.mark_as_unmergable
|
||||
message = "Can not be merged"
|
||||
ensure
|
||||
redirect_to [@merge_request.project, @merge_request], :alert => message
|
||||
end
|
||||
|
||||
|
|
|
@ -56,6 +56,10 @@ class MergeRequest < ActiveRecord::Base
|
|||
self.reloaded_diffs
|
||||
end
|
||||
|
||||
def can_be_merged?
|
||||
auto_merge
|
||||
end
|
||||
|
||||
def new?
|
||||
today? && created_at == updated_at
|
||||
end
|
||||
|
@ -118,6 +122,11 @@ class MergeRequest < ActiveRecord::Base
|
|||
save
|
||||
end
|
||||
|
||||
def mark_as_unmergable
|
||||
self.auto_merge = false
|
||||
save
|
||||
end
|
||||
|
||||
def reloaded_commits
|
||||
if open? && unmerged_commits.any?
|
||||
self.st_commits = unmerged_commits
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
%span.right
|
||||
- if can?(current_user, :modify_merge_request, @merge_request)
|
||||
- if @merge_request.open?
|
||||
= link_to "Show how to merge", "#", :class => "how_to_merge_link btn small padded", :title => "How To Merge"
|
||||
= link_to 'Close', project_merge_request_path(@project, @merge_request, :merge_request => {:closed => true }, :status_only => true), :method => :put, :class => "btn small padded", :title => "Close merge request"
|
||||
= link_to edit_project_merge_request_path(@project, @merge_request), :class => "btn small padded" do
|
||||
Edit
|
||||
|
@ -53,6 +52,22 @@
|
|||
Closed by #{@merge_request.closed_event.author_name}
|
||||
%small #{time_ago_in_words(@merge_request.closed_event.created_at)} ago.
|
||||
|
||||
- if @merge_request.open? && @commits.any?
|
||||
- if @merge_request.can_be_merged?
|
||||
.alert-message.block-message.success
|
||||
%p You can try to merge this request with GitLab. If failed you can always do it manually
|
||||
.alert-actions
|
||||
= link_to "Try Merge it!", automerge_project_merge_request_path(@project, @merge_request), :class => "btn small success"
|
||||
|
||||
= link_to "Show how to merge", "#", :class => "how_to_merge_link btn small padded", :title => "How To Merge"
|
||||
- else
|
||||
.alert-message.block-message
|
||||
%p This request cant be merged with GitLab. You should do it manually
|
||||
.alert-actions
|
||||
%span.btn.small.disabled Try Merge it!
|
||||
= link_to "Show how to merge", "#", :class => "how_to_merge_link btn small padded success", :title => "How To Merge"
|
||||
|
||||
|
||||
= render "merge_requests/commits"
|
||||
|
||||
- unless @commits.empty?
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
class AddAutomergeToMergeRequest < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :merge_requests, :auto_merge, :boolean, :null => false, :default => true
|
||||
|
||||
end
|
||||
end
|
39
db/schema.rb
39
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20120323221339) do
|
||||
ActiveRecord::Schema.define(:version => 20120329170745) do
|
||||
|
||||
create_table "events", :force => true do |t|
|
||||
t.string "target_type"
|
||||
|
@ -30,8 +30,8 @@ ActiveRecord::Schema.define(:version => 20120323221339) do
|
|||
t.integer "assignee_id"
|
||||
t.integer "author_id"
|
||||
t.integer "project_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.boolean "closed", :default => false, :null => false
|
||||
t.integer "position", :default => 0
|
||||
t.boolean "critical", :default => false, :null => false
|
||||
|
@ -43,8 +43,8 @@ ActiveRecord::Schema.define(:version => 20120323221339) do
|
|||
|
||||
create_table "keys", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.text "key"
|
||||
t.string "title"
|
||||
t.string "identifier"
|
||||
|
@ -59,11 +59,12 @@ ActiveRecord::Schema.define(:version => 20120323221339) do
|
|||
t.integer "assignee_id"
|
||||
t.string "title"
|
||||
t.boolean "closed", :default => false, :null => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.text "st_commits"
|
||||
t.text "st_diffs"
|
||||
t.boolean "merged", :default => false, :null => false
|
||||
t.boolean "auto_merge", :default => true, :null => false
|
||||
end
|
||||
|
||||
add_index "merge_requests", ["project_id"], :name => "index_merge_requests_on_project_id"
|
||||
|
@ -73,8 +74,8 @@ ActiveRecord::Schema.define(:version => 20120323221339) do
|
|||
t.string "noteable_id"
|
||||
t.string "noteable_type"
|
||||
t.integer "author_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "project_id"
|
||||
t.string "attachment"
|
||||
t.string "line_code"
|
||||
|
@ -87,8 +88,8 @@ ActiveRecord::Schema.define(:version => 20120323221339) do
|
|||
t.string "name"
|
||||
t.string "path"
|
||||
t.text "description"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.boolean "private_flag", :default => true, :null => false
|
||||
t.string "code"
|
||||
t.integer "owner_id"
|
||||
|
@ -111,8 +112,8 @@ ActiveRecord::Schema.define(:version => 20120323221339) do
|
|||
t.text "content"
|
||||
t.integer "author_id", :null => false
|
||||
t.integer "project_id", :null => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "file_name"
|
||||
t.datetime "expires_at"
|
||||
end
|
||||
|
@ -145,8 +146,8 @@ ActiveRecord::Schema.define(:version => 20120323221339) do
|
|||
t.datetime "last_sign_in_at"
|
||||
t.string "current_sign_in_ip"
|
||||
t.string "last_sign_in_ip"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "name"
|
||||
t.boolean "admin", :default => false, :null => false
|
||||
t.integer "projects_limit", :default => 10
|
||||
|
@ -165,16 +166,16 @@ ActiveRecord::Schema.define(:version => 20120323221339) do
|
|||
create_table "users_projects", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
t.integer "project_id", :null => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "project_access", :default => 0, :null => false
|
||||
end
|
||||
|
||||
create_table "web_hooks", :force => true do |t|
|
||||
t.string "url"
|
||||
t.integer "project_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "wikis", :force => true do |t|
|
||||
|
|
Loading…
Reference in a new issue