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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
06e7eeb1
Commit
06e7eeb1
authored
Oct 08, 2017
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Gitaly's RepositoryService.HasLocalBranches RPC
parent
9ac5338b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
9 deletions
+19
-9
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+1
-1
lib/gitlab/gitaly_client/ref_service.rb
lib/gitlab/gitaly_client/ref_service.rb
+0
-8
lib/gitlab/gitaly_client/repository_service.rb
lib/gitlab/gitaly_client/repository_service.rb
+7
-0
spec/lib/gitlab/gitaly_client/repository_service_spec.rb
spec/lib/gitlab/gitaly_client/repository_service_spec.rb
+11
-0
No files found.
lib/gitlab/git/repository.rb
View file @
06e7eeb1
...
@@ -193,7 +193,7 @@ module Gitlab
...
@@ -193,7 +193,7 @@ module Gitlab
def
has_local_branches?
def
has_local_branches?
gitaly_migrate
(
:has_local_branches
)
do
|
is_enabled
|
gitaly_migrate
(
:has_local_branches
)
do
|
is_enabled
|
if
is_enabled
if
is_enabled
gitaly_re
f
_client
.
has_local_branches?
gitaly_re
pository
_client
.
has_local_branches?
else
else
has_local_branches_rugged?
has_local_branches_rugged?
end
end
...
...
lib/gitlab/gitaly_client/ref_service.rb
View file @
06e7eeb1
...
@@ -57,14 +57,6 @@ module Gitlab
...
@@ -57,14 +57,6 @@ module Gitlab
branch_names
.
count
branch_names
.
count
end
end
# TODO implement a more efficient RPC for this https://gitlab.com/gitlab-org/gitaly/issues/616
def
has_local_branches?
request
=
Gitaly
::
FindAllBranchNamesRequest
.
new
(
repository:
@gitaly_repo
)
response
=
GitalyClient
.
call
(
@storage
,
:ref_service
,
:find_all_branch_names
,
request
).
first
response
&
.
names
.
present?
end
def
local_branches
(
sort_by:
nil
)
def
local_branches
(
sort_by:
nil
)
request
=
Gitaly
::
FindLocalBranchesRequest
.
new
(
repository:
@gitaly_repo
)
request
=
Gitaly
::
FindLocalBranchesRequest
.
new
(
repository:
@gitaly_repo
)
request
.
sort_by
=
sort_by_param
(
sort_by
)
if
sort_by
request
.
sort_by
=
sort_by_param
(
sort_by
)
if
sort_by
...
...
lib/gitlab/gitaly_client/repository_service.rb
View file @
06e7eeb1
...
@@ -58,6 +58,13 @@ module Gitlab
...
@@ -58,6 +58,13 @@ module Gitlab
request
=
Gitaly
::
CreateRepositoryRequest
.
new
(
repository:
@gitaly_repo
)
request
=
Gitaly
::
CreateRepositoryRequest
.
new
(
repository:
@gitaly_repo
)
GitalyClient
.
call
(
@storage
,
:repository_service
,
:create_repository
,
request
)
GitalyClient
.
call
(
@storage
,
:repository_service
,
:create_repository
,
request
)
end
end
def
has_local_branches?
request
=
Gitaly
::
HasLocalBranchesRequest
.
new
(
repository:
@gitaly_repo
)
response
=
GitalyClient
.
call
(
@storage
,
:repository_service
,
:has_local_branches
,
request
)
response
.
value
end
end
end
end
end
end
end
spec/lib/gitlab/gitaly_client/repository_service_spec.rb
View file @
06e7eeb1
...
@@ -73,4 +73,15 @@ describe Gitlab::GitalyClient::RepositoryService do
...
@@ -73,4 +73,15 @@ describe Gitlab::GitalyClient::RepositoryService do
client
.
apply_gitattributes
(
revision
)
client
.
apply_gitattributes
(
revision
)
end
end
end
end
describe
'#has_local_branches?'
do
it
'sends a has_local_branches message'
do
expect_any_instance_of
(
Gitaly
::
RepositoryService
::
Stub
)
.
to
receive
(
:has_local_branches
)
.
with
(
gitaly_request_with_path
(
storage_name
,
relative_path
),
kind_of
(
Hash
))
.
and_return
(
double
(
value:
true
))
expect
(
client
.
has_local_branches?
).
to
be
(
true
)
end
end
end
end
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