Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r--app/models/repository.rb32
1 files changed, 16 insertions, 16 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index d410d60dbad..4f8b436ee16 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -862,17 +862,18 @@ class Repository
end
def revert(
- user, commit, branch_name, revert_tree_id = nil,
+ user, commit, branch_name,
start_branch_name: nil, start_project: project)
- revert_tree_id ||= check_revert_content(commit, branch_name)
-
- return false unless revert_tree_id
-
GitOperationService.new(user, self).with_branch(
branch_name,
start_branch_name: start_branch_name,
start_project: start_project) do |start_commit|
+ revert_tree_id = check_revert_content(commit, start_commit.sha)
+ unless revert_tree_id
+ raise Repository::CommitError.new('Failed to revert commit')
+ end
+
committer = user_to_committer(user)
Rugged::Commit.create(rugged,
@@ -885,17 +886,18 @@ class Repository
end
def cherry_pick(
- user, commit, branch_name, cherry_pick_tree_id = nil,
+ user, commit, branch_name,
start_branch_name: nil, start_project: project)
- cherry_pick_tree_id ||= check_cherry_pick_content(commit, branch_name)
-
- return false unless cherry_pick_tree_id
-
GitOperationService.new(user, self).with_branch(
branch_name,
start_branch_name: start_branch_name,
start_project: start_project) do |start_commit|
+ cherry_pick_tree_id = check_cherry_pick_content(commit, start_commit.sha)
+ unless cherry_pick_tree_id
+ raise Repository::CommitError.new('Failed to cherry-pick commit')
+ end
+
committer = user_to_committer(user)
Rugged::Commit.create(rugged,
@@ -919,9 +921,8 @@ class Repository
end
end
- def check_revert_content(target_commit, branch_name)
- source_sha = commit(branch_name).sha
- args = [target_commit.sha, source_sha]
+ def check_revert_content(target_commit, source_sha)
+ args = [target_commit.sha, source_sha]
args << { mainline: 1 } if target_commit.merge_commit?
revert_index = rugged.revert_commit(*args)
@@ -933,9 +934,8 @@ class Repository
tree_id
end
- def check_cherry_pick_content(target_commit, branch_name)
- source_sha = commit(branch_name).sha
- args = [target_commit.sha, source_sha]
+ def check_cherry_pick_content(target_commit, source_sha)
+ args = [target_commit.sha, source_sha]
args << 1 if target_commit.merge_commit?
cherry_pick_index = rugged.cherrypick_commit(*args)