Commit 38e708f0 authored by Rubén Dávila's avatar Rubén Dávila Committed by Robert Speicher

Add link to fork if user can't revert MR.

parent 9d4c105a
......@@ -108,7 +108,7 @@ module CreatesCommit
# Merge request from fork to this project
@mr_source_project = @tree_edit_project
@mr_target_project = @project
@mr_target_branch = @ref
@mr_target_branch ||= @ref
end
end
end
......@@ -92,4 +92,11 @@ module MergeRequestsHelper
["#{source_path}:#{source_branch}", "#{target_path}:#{target_branch}"]
end
end
def can_update_merge_request?
project ||= @project
can?(current_user, :update_merge_request, project) ||
(current_user && current_user.already_forked?(project))
end
end
......@@ -628,6 +628,8 @@ class Repository
args = [commit.id, source_sha]
args << { mainline: 1 } if commit.is_a_merge_commit?
# Temporary branch exists and contains the revert commit
return true if create_mr && find_branch(target_branch)
return false unless diff_exists?(source_sha, commit.id)
revert_index = rugged.revert_commit(*args)
......
......@@ -85,6 +85,8 @@
= spinner
= render 'shared/issuable/sidebar', issuable: @merge_request
- if @merge_request.merge_commit_sha
= render "projects/commit/revert", commit_id: @merge_request.merge_commit_sha
:javascript
var merge_request;
......
......@@ -18,7 +18,16 @@
Edit
- if @merge_request.closed?
= link_to 'Reopen', merge_request_path(@merge_request, merge_request: {state_event: :reopen }), method: :put, class: 'btn btn-nr btn-grouped btn-reopen reopen-mr-link', title: "Reopen merge request"
- if @merge_request.merged? && @merge_request.merge_commit_sha.present?
= render "projects/commit/revert", commit_id: @merge_request.merge_commit_sha
- if can_update_merge_request?
= link_to '#modal-revert-commit', { 'data-target' => '#modal-revert-commit', 'data-toggle' => 'modal', class: 'btn btn-grouped btn-close'} do
Revert
- else
- continue_params = { to: namespace_project_merge_request_path(@project.namespace, @project, @merge_request),
notice: edit_in_new_fork_notice,
notice_now: edit_in_new_fork_notice_now }
- fork_path = namespace_project_forks_path(@project.namespace, @project, namespace_key: current_user.namespace.id,
continue: continue_params)
= link_to fork_path, { class: 'btn btn-grouped btn-close', method: :post } do
Revert
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