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

This commit is contained in:
Rubén Dávila 2016-02-08 17:06:04 -05:00 committed by Robert Speicher
parent 9d4c105ab0
commit 38e708f0ce
5 changed files with 23 additions and 3 deletions

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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;

View file

@ -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 @merge_request.merged? && @merge_request.merge_commit_sha.present?
- 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