Commit a28eef1d authored by Rubén Dávila's avatar Rubén Dávila Committed by Robert Speicher
Browse files

Update copy and URLs used when reverting MRs.

parent 38752d15
......@@ -62,13 +62,32 @@ def branches
def revert
return render_404 if @target_branch.blank?
create_commit(Commits::RevertService, success_notice: "The commit has been successfully reverted.",
success_path: namespace_project_commits_path(@project.namespace, @project, @target_branch),
failure_path: namespace_project_commit_path(@project.namespace, @project, params[:id]))
create_commit(Commits::RevertService, success_notice: "The #{revert_type_title} has been successfully reverted.",
success_path: successful_revert_path, failure_path: failed_revert_path)
end
private
def revert_type_title
@commit.merged_merge_request ? 'merge request' : 'commit'
end
def successful_revert_path
return referenced_merge_request_url if @commit.merged_merge_request
namespace_project_commits_url(@project.namespace, @project, @target_branch)
end
def failed_revert_path
return referenced_merge_request_url if @commit.merged_merge_request
namespace_project_commit_url(@project.namespace, @project, params[:id])
end
def referenced_merge_request_url
namespace_project_merge_request_url(@project.namespace, @project, @commit.merged_merge_request)
end
def commit
@commit ||= @project.commit(params[:id])
end
......@@ -99,6 +118,7 @@ def assign_revert_commit_vars
@mr_target_branch = @target_branch
@commit_params = {
commit: @commit,
revert_type_title: revert_type_title,
create_merge_request: params[:create_merge_request].present? || different_project?
}
end
......
......@@ -227,6 +227,12 @@ def is_a_merge_commit?
parents.size > 1
end
def merged_merge_request
return @merged_merge_request if defined?(@merged_merge_request)
@merged_merge_request = is_a_merge_commit? && MergeRequest.where(merge_commit_sha: id).first
end
private
def repo_changes
......
......@@ -14,7 +14,7 @@ def execute
if commit
success
else
error("Sorry, we cannot revert this commit automatically.
error("Sorry, we cannot revert this #{params[:revert_type_title]} automatically.
It may have already been reverted, or a more recent commit may
have updated some of its content.")
end
......
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