Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Feature: reopen closed merge request

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
  • Loading branch information...
commit 36b065e634f65e5c4690ccd7eed0cc90986ec67b 1 parent 110585c
@randx randx authored
View
5 app/assets/stylesheets/sections/merge_requests.scss
@@ -91,6 +91,7 @@
}
// hide mr close link for inline diff comment form
-.diff-file .close-mr-link {
- display: none;
+.diff-file .close-mr-link,
+.diff-file .reopen-mr-link {
+ display: none;
}
View
4 app/controllers/projects/merge_requests_controller.rb
@@ -135,7 +135,7 @@ def automerge_check
def automerge
return access_denied! unless allowed_to_merge?
- if @merge_request.opened? && @merge_request.can_be_merged?
+ if @merge_request.open? && @merge_request.can_be_merged?
@merge_request.should_remove_source_branch = params[:should_remove_source_branch]
@merge_request.automerge!(current_user, params[:merge_commit_message])
@status = true
@@ -230,7 +230,7 @@ def define_show_vars
@merge_request_diff = @merge_request.merge_request_diff
@allowed_to_merge = allowed_to_merge?
- @show_merge_controls = @merge_request.opened? && @commits.any? && @allowed_to_merge
+ @show_merge_controls = @merge_request.open? && @commits.any? && @allowed_to_merge
end
def allowed_to_merge?
View
3  app/models/concerns/issuable.rb
@@ -23,7 +23,8 @@ module Issuable
scope :assigned, -> { where("assignee_id IS NOT NULL") }
scope :unassigned, -> { where("assignee_id IS NULL") }
scope :of_projects, ->(ids) { where(project_id: ids) }
-
+ scope :opened, -> { with_state(:opened, :reopened) }
+ scope :closed, -> { with_state(:closed) }
delegate :name,
:email,
View
4 app/models/issue.rb
@@ -28,8 +28,6 @@ class Issue < ActiveRecord::Base
scope :of_group, ->(group) { where(project_id: group.project_ids) }
scope :of_user_team, ->(team) { where(project_id: team.project_ids, assignee_id: team.member_ids) }
- scope :opened, -> { with_state(:opened, :reopened) }
- scope :closed, -> { with_state(:closed) }
attr_accessible :title, :assignee_id, :position, :description,
:milestone_id, :label_list, :author_id_of_changes,
@@ -50,9 +48,7 @@ class Issue < ActiveRecord::Base
end
state :opened
-
state :reopened
-
state :closed
end
View
6 app/models/merge_request.rb
@@ -100,8 +100,6 @@ class MergeRequest < ActiveRecord::Base
scope :of_group, ->(group) { where("source_project_id in (:group_project_ids) OR target_project_id in (:group_project_ids)", group_project_ids: group.project_ids) }
scope :of_user_team, ->(team) { where("(source_project_id in (:team_project_ids) OR target_project_id in (:team_project_ids) AND assignee_id in (:team_member_ids))", team_project_ids: team.project_ids, team_member_ids: team.member_ids) }
- scope :opened, -> { with_state(:opened) }
- scope :closed, -> { with_state(:closed) }
scope :merged, -> { with_state(:merged) }
scope :by_branch, ->(branch_name) { where("(source_branch LIKE :branch) OR (target_branch LIKE :branch)", branch: branch_name) }
scope :cared, ->(user) { where('assignee_id = :user OR author_id = :user', user: user.id) }
@@ -160,6 +158,10 @@ def automerge!(current_user, commit_message = nil)
MergeRequests::AutoMergeService.new.execute(self, current_user, commit_message)
end
+ def open?
+ opened? || reopened?
+ end
+
def mr_and_commit_notes
# Fetch comments only from last 100 commits
commits_for_notes_limit = 100
View
2  app/observers/merge_request_observer.rb
@@ -22,6 +22,8 @@ def after_reopen(merge_request, transition)
create_event(merge_request, Event::REOPENED)
create_note(merge_request)
execute_hooks(merge_request)
+ merge_request.reload_code
+ merge_request.mark_as_unchecked
end
def after_update(merge_request)
View
5 app/views/projects/merge_requests/_show.html.haml
@@ -2,7 +2,7 @@
= render "projects/merge_requests/show/mr_title"
= render "projects/merge_requests/show/how_to_merge"
= render "projects/merge_requests/show/mr_box"
- - if @merge_request.opened?
+ - if @merge_request.open?
- if @merge_request.source_branch_exists? && @merge_request.target_branch_exists?
= render "projects/merge_requests/show/mr_accept"
- else
@@ -26,7 +26,8 @@
- if can?(current_user, :modify_merge_request, @merge_request)
- unless @merge_request.closed? || @merge_request.merged?
= link_to 'Close', project_merge_request_path(@project, @merge_request, merge_request: {state_event: :close }), method: :put, class: "btn btn-grouped btn-close close-mr-link", title: "Close merge request"
-
+ - if @merge_request.closed?
+ = link_to 'Reopen', project_merge_request_path(@project, @merge_request, merge_request: {state_event: :reopen }), method: :put, class: "btn btn-grouped btn-reopen reopen-mr-link", title: "Close merge request"
.notes.tab-content.voting_notes#notes{ class: (controller.action_name == 'show') ? "" : "hide" }
= render "projects/notes/notes_with_form"
View
2  app/views/projects/merge_requests/show/_mr_box.html.haml
@@ -36,7 +36,7 @@
%i.icon-ok
Merged by #{link_to_member(@project, @merge_request.merge_event.author)}
#{time_ago_with_tooltip(@merge_request.merge_event.created_at)}.
-- if !@closes_issues.empty? && @merge_request.opened?
+- if !@closes_issues.empty? && @merge_request.open?
.alert.alert-info.alert-info
%span
%i.icon-ok
View
4 app/views/projects/merge_requests/show/_mr_title.html.haml
@@ -3,7 +3,7 @@
%span.pull-right
- if can?(current_user, :modify_merge_request, @merge_request)
- - if @merge_request.opened?
+ - if @merge_request.open?
.btn-group.pull-left
%a.btn.btn-grouped.dropdown-toggle{ data: {toggle: :dropdown} }
%i.icon-download-alt
@@ -18,6 +18,8 @@
= link_to edit_project_merge_request_path(@project, @merge_request), class: "btn btn-grouped", id:"edit_merge_request" do
%i.icon-edit
Edit
+ - if @merge_request.closed?
+ = link_to 'Reopen', project_merge_request_path(@project, @merge_request, merge_request: {state_event: :reopen }), method: :put, class: "btn btn-grouped btn-reopen reopen-mr-link", title: "Close merge request"
.votes-holder.hidden-sm.hidden-xs
#votes= render 'votes/votes_block', votable: @merge_request
Please sign in to comment.
Something went wrong with that request. Please try again.