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:
authorLin Jen-Shin <godfat@godfat.org>2016-12-07 14:50:08 +0300
committerLin Jen-Shin <godfat@godfat.org>2016-12-07 14:50:08 +0300
commit6ae1a73cfdad4b98176bb99846042d4378119de2 (patch)
tree501de5fd5ab59d3cca7d5fa8412eb20d76da776a /app/services/git_operation_service.rb
parent65806ec632f2ea1e2087b7cdc64f13e6db49c88a (diff)
Pass source_branch properly for cherry-pick/revert
Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7237/diffs#note_19210818
Diffstat (limited to 'app/services/git_operation_service.rb')
-rw-r--r--app/services/git_operation_service.rb16
1 files changed, 5 insertions, 11 deletions
diff --git a/app/services/git_operation_service.rb b/app/services/git_operation_service.rb
index c34d4bde150..c9e2c21737a 100644
--- a/app/services/git_operation_service.rb
+++ b/app/services/git_operation_service.rb
@@ -25,21 +25,15 @@ GitOperationService = Struct.new(:user, :repository) do
end
end
- # Whenever `source_branch` or `source_commit` is passed, if `branch`
- # doesn't exist, it would be created from `source_branch` or
- # `source_commit`. Should only pass one of them, not both.
+ # Whenever `source_branch` is passed, if `branch` doesn't exist,
+ # it would be created from `source_branch`.
# If `source_project` is passed, and the branch doesn't exist,
# it would try to find the source from it instead of current repository.
def with_branch(
branch_name,
source_branch: nil,
- source_commit: nil,
source_project: repository.project)
- if source_commit && source_branch
- raise ArgumentError, 'Should pass only :source_branch or :source_commit'
- end
-
ref = Gitlab::Git::BRANCH_REF_PREFIX + branch_name
oldrev = Gitlab::Git::BLANK_SHA
@@ -62,13 +56,13 @@ GitOperationService = Struct.new(:user, :repository) do
" #{source_project.path_with_namespace}")
end
- elsif source_commit || source_branch
- newrev = (source_commit || repository.commit(source_branch)).try(:sha)
+ elsif source_branch
+ newrev = repository.commit(source_branch).try(:sha)
unless newrev
raise Repository::CommitError.new(
"Cannot find branch #{branch_name} nor" \
- " #{source_commit.try(:sha) || source_branch} from" \
+ " #{source_branch} from" \
" #{repository.project.path_with_namespace}")
end