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

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2018-09-23 22:13:50 +0300
committerDouwe Maan <douwe@selenight.nl>2018-09-24 12:36:35 +0300
commitbb7200cb1e6b658184ded4b81dc1729ef6f95ba2 (patch)
tree2e544851c9074ebe0843a541f1fc6566ada815d6
parent1b43d5142b9d902609992351b76a56557fb66769 (diff)
Make UserCommitFiles BranchName optionaldm-user-commit-files-branch-name-optional
-rw-r--r--internal/service/operations/commit_files.go3
-rw-r--r--internal/service/operations/commit_files_test.go4
-rw-r--r--ruby/lib/gitlab/git/operation_service.rb16
3 files changed, 10 insertions, 13 deletions
diff --git a/internal/service/operations/commit_files.go b/internal/service/operations/commit_files.go
index 310f60a43..8020d1a1f 100644
--- a/internal/service/operations/commit_files.go
+++ b/internal/service/operations/commit_files.go
@@ -74,8 +74,5 @@ func validateUserCommitFilesHeader(header *pb.UserCommitFilesRequestHeader) erro
if len(header.GetCommitMessage()) == 0 {
return fmt.Errorf("empty CommitMessage")
}
- if len(header.GetBranchName()) == 0 {
- return fmt.Errorf("empty BranchName")
- }
return nil
}
diff --git a/internal/service/operations/commit_files_test.go b/internal/service/operations/commit_files_test.go
index c5816e7c0..0dbaccc3d 100644
--- a/internal/service/operations/commit_files_test.go
+++ b/internal/service/operations/commit_files_test.go
@@ -277,10 +277,6 @@ func TestFailedUserCommitFilesRequest(t *testing.T) {
req: headerRequest(testRepo, nil, branchName, commitFilesMessage, nil, nil),
},
{
- desc: "empty BranchName",
- req: headerRequest(testRepo, user, "", commitFilesMessage, nil, nil),
- },
- {
desc: "empty CommitMessage",
req: headerRequest(testRepo, user, branchName, nil, nil, nil),
},
diff --git a/ruby/lib/gitlab/git/operation_service.rb b/ruby/lib/gitlab/git/operation_service.rb
index 99ee18166..2844e84e3 100644
--- a/ruby/lib/gitlab/git/operation_service.rb
+++ b/ruby/lib/gitlab/git/operation_service.rb
@@ -119,13 +119,17 @@ module Gitlab
raise Gitlab::Git::CommitError.new('Failed to create commit')
end
- branch = repository.find_branch(branch_name)
- oldrev = find_oldrev_from_branch(newrev, branch)
-
- ref = Gitlab::Git::BRANCH_REF_PREFIX + branch_name
- update_ref_in_hooks(ref, newrev, oldrev)
+ branch_created = was_empty
+ if branch_name.present?
+ branch = repository.find_branch(branch_name)
+ oldrev = find_oldrev_from_branch(newrev, branch)
+ branch_created ||= Gitlab::Git.blank_ref?(oldrev)
+
+ ref = Gitlab::Git::BRANCH_REF_PREFIX + branch_name
+ update_ref_in_hooks(ref, newrev, oldrev)
+ end
- BranchUpdate.new(newrev, was_empty, was_empty || Gitlab::Git.blank_ref?(oldrev))
+ BranchUpdate.new(newrev, was_empty, branch_created)
end
def find_oldrev_from_branch(newrev, branch)