Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4a4338fc
Commit
4a4338fc
authored
Jun 27, 2018
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Gitaly's OperationService.UserUpdateBranch RPC
parent
0ed8f349
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
1 deletion
+64
-1
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+7
-1
lib/gitlab/gitaly_client/operation_service.rb
lib/gitlab/gitaly_client/operation_service.rb
+16
-0
spec/lib/gitlab/gitaly_client/operation_service_spec.rb
spec/lib/gitlab/gitaly_client/operation_service_spec.rb
+41
-0
No files found.
lib/gitlab/git/repository.rb
View file @
4a4338fc
...
...
@@ -651,7 +651,13 @@ module Gitlab
end
def
update_branch
(
branch_name
,
user
:,
newrev
:,
oldrev
:)
OperationService
.
new
(
user
,
self
).
update_branch
(
branch_name
,
newrev
,
oldrev
)
gitaly_migrate
(
:operation_user_update_branch
)
do
|
is_enabled
|
if
is_enabled
gitaly_operations_client
.
user_update_branch
(
branch_name
,
user
,
newrev
,
oldrev
)
else
OperationService
.
new
(
user
,
self
).
update_branch
(
branch_name
,
newrev
,
oldrev
)
end
end
end
def
rm_branch
(
branch_name
,
user
:)
...
...
lib/gitlab/gitaly_client/operation_service.rb
View file @
4a4338fc
...
...
@@ -68,6 +68,22 @@ module Gitlab
raise
Gitlab
::
Git
::
Repository
::
InvalidRef
,
ex
end
def
user_update_branch
(
branch_name
,
user
,
newrev
,
oldrev
)
request
=
Gitaly
::
UserUpdateBranchRequest
.
new
(
repository:
@gitaly_repo
,
branch_name:
encode_binary
(
branch_name
),
user:
Gitlab
::
Git
::
User
.
from_gitlab
(
user
).
to_gitaly
,
newrev:
encode_binary
(
newrev
),
oldrev:
encode_binary
(
oldrev
)
)
response
=
GitalyClient
.
call
(
@repository
.
storage
,
:operation_service
,
:user_update_branch
,
request
)
if
pre_receive_error
=
response
.
pre_receive_error
.
presence
raise
Gitlab
::
Git
::
PreReceiveError
,
pre_receive_error
end
end
def
user_delete_branch
(
branch_name
,
user
)
request
=
Gitaly
::
UserDeleteBranchRequest
.
new
(
repository:
@gitaly_repo
,
...
...
spec/lib/gitlab/gitaly_client/operation_service_spec.rb
View file @
4a4338fc
...
...
@@ -53,6 +53,47 @@ describe Gitlab::GitalyClient::OperationService do
end
end
describe
'#user_update_branch'
do
let
(
:branch_name
)
{
'my-branch'
}
let
(
:newrev
)
{
'01e'
}
let
(
:oldrev
)
{
'01d'
}
let
(
:request
)
do
Gitaly
::
UserUpdateBranchRequest
.
new
(
repository:
repository
.
gitaly_repository
,
branch_name:
branch_name
,
newrev:
newrev
,
oldrev:
oldrev
,
user:
gitaly_user
)
end
let
(
:response
)
{
Gitaly
::
UserUpdateBranchResponse
.
new
}
subject
{
client
.
user_update_branch
(
branch_name
,
user
,
newrev
,
oldrev
)
}
it
'sends a user_update_branch message'
do
expect_any_instance_of
(
Gitaly
::
OperationService
::
Stub
)
.
to
receive
(
:user_update_branch
).
with
(
request
,
kind_of
(
Hash
))
.
and_return
(
response
)
subject
end
context
"when pre_receive_error is present"
do
let
(
:response
)
do
Gitaly
::
UserUpdateBranchResponse
.
new
(
pre_receive_error:
"something failed"
)
end
it
"throws a PreReceive exception"
do
expect_any_instance_of
(
Gitaly
::
OperationService
::
Stub
)
.
to
receive
(
:user_update_branch
).
with
(
request
,
kind_of
(
Hash
))
.
and_return
(
response
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Git
::
PreReceiveError
,
"something failed"
)
end
end
end
describe
'#user_delete_branch'
do
let
(
:branch_name
)
{
'my-branch'
}
let
(
:request
)
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment