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:
authorAlejandro Rodríguez <alejorro70@gmail.com>2018-07-21 01:32:11 +0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2018-07-21 01:32:11 +0300
commit90b76640110ac551783ccca2d2960dc380ce348d (patch)
tree0de0dca96fa2136f35e01e6a974a02f69d90c4bd
parent51350d20b17c1045dbd4c749b018c481f7662d3c (diff)
Handle non-existing branch on UserDeleteBranch
-rw-r--r--changelogs/unreleased/1006-operationservice-userdeletebranch-doesn-t-handle-non-existing-branches-correctly.yml5
-rw-r--r--internal/service/operations/branches_test.go2
-rw-r--r--ruby/lib/gitaly_server/operations_service.rb4
-rw-r--r--ruby/lib/gitlab/git/repository.rb6
4 files changed, 13 insertions, 4 deletions
diff --git a/changelogs/unreleased/1006-operationservice-userdeletebranch-doesn-t-handle-non-existing-branches-correctly.yml b/changelogs/unreleased/1006-operationservice-userdeletebranch-doesn-t-handle-non-existing-branches-correctly.yml
new file mode 100644
index 000000000..dfd1eb322
--- /dev/null
+++ b/changelogs/unreleased/1006-operationservice-userdeletebranch-doesn-t-handle-non-existing-branches-correctly.yml
@@ -0,0 +1,5 @@
+---
+title: Handle non-existing branch on UserDeleteBranch
+merge_request: 826
+author:
+type: fixed
diff --git a/internal/service/operations/branches_test.go b/internal/service/operations/branches_test.go
index 4a44ed9b4..fa04b5f72 100644
--- a/internal/service/operations/branches_test.go
+++ b/internal/service/operations/branches_test.go
@@ -352,7 +352,7 @@ func TestFailedUserDeleteBranchDueToValidation(t *testing.T) {
User: user,
BranchName: []byte("i-do-not-exist"),
},
- code: codes.Unknown,
+ code: codes.FailedPrecondition,
},
}
diff --git a/ruby/lib/gitaly_server/operations_service.rb b/ruby/lib/gitaly_server/operations_service.rb
index 362e50d65..c3913239e 100644
--- a/ruby/lib/gitaly_server/operations_service.rb
+++ b/ruby/lib/gitaly_server/operations_service.rb
@@ -109,8 +109,8 @@ module GitalyServer
Gitaly::UserDeleteBranchResponse.new
rescue Gitlab::Git::PreReceiveError => e
Gitaly::UserDeleteBranchResponse.new(pre_receive_error: set_utf8!(e.message))
- rescue Gitlab::Git::CommitError => e
- raise GRPC::FailedPrecondition.new(e)
+ rescue Gitlab::Git::Repository::InvalidRef, Gitlab::Git::CommitError => e
+ raise GRPC::FailedPrecondition.new(e.message)
end
end
end
diff --git a/ruby/lib/gitlab/git/repository.rb b/ruby/lib/gitlab/git/repository.rb
index c7f5f7512..757adc5d2 100644
--- a/ruby/lib/gitlab/git/repository.rb
+++ b/ruby/lib/gitlab/git/repository.rb
@@ -255,7 +255,11 @@ module Gitlab
end
def rm_branch(branch_name, user:)
- OperationService.new(user, self).rm_branch(find_branch(branch_name))
+ branch = find_branch(branch_name)
+
+ raise InvalidRef.new("branch not found: #{branch_name}") unless branch
+
+ OperationService.new(user, self).rm_branch(branch)
end
def rm_tag(tag_name, user:)