Skip to content
Snippets Groups Projects
Commit 2ea5b37f authored by Rubén Dávila's avatar Rubén Dávila Committed by Robert Speicher
Browse files

Some fixes and refactors for code related to forks.

parent 11345866
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -124,6 +124,8 @@ module CommitsHelper
end
 
def revert_commit_link(show_modal_condition, continue_to_path)
return unless current_user
if show_modal_condition
link_to('Revert', '#modal-revert-commit',
'data-target' => '#modal-revert-commit',
Loading
Loading
Loading
Loading
@@ -628,8 +628,6 @@ class Repository
args = [commit.id, source_sha]
args << { mainline: 1 } if commit.merge_commit?
 
# Temporary branch exists and contains the revert commit
return true if (base_branch != target_branch) && find_branch(target_branch)
return false unless diff_exists?(source_sha, commit.id)
 
revert_index = rugged.revert_commit(*args)
Loading
Loading
Loading
Loading
@@ -14,9 +14,7 @@ module Commits
if commit
success
else
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.")
custom_error
end
rescue Repository::CommitError, Gitlab::Git::Repository::InvalidBlobName, GitHooksService::PreReceiveError, ValidationError => ex
error(ex.message)
Loading
Loading
@@ -24,7 +22,11 @@ module Commits
 
def commit
if @create_merge_request
repository.revert(current_user, @commit, @target_branch, @commit.revert_branch_name)
# Temporary branch exists and contains the revert commit
return true if repository.find_branch(@commit.revert_branch_name)
return false unless create_target_branch
repository.revert(current_user, @commit, @commit.revert_branch_name)
else
repository.revert(current_user, @commit, @target_branch)
end
Loading
Loading
@@ -32,6 +34,25 @@ module Commits
 
private
 
def custom_error
if @branch_error_msg
error("There was an error creating the source branch: #{@branch_error_msg}")
else
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
end
def create_target_branch
result = CreateBranchService.new(@project, current_user)
.execute(@commit.revert_branch_name, @target_branch, source_project: @source_project)
@branch_error_msg = result[:message]
result[:status] != :error
end
def raise_error(message)
raise ValidationError.new(message)
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment