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
65a4b948
Commit
65a4b948
authored
Oct 19, 2021
by
Robert May
Committed by
Douglas Barbosa Alexandre
Oct 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ListRefs bindings
parent
df675c00
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
0 deletions
+52
-0
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+6
-0
lib/gitlab/gitaly_client/ref_service.rb
lib/gitlab/gitaly_client/ref_service.rb
+14
-0
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+12
-0
spec/lib/gitlab/gitaly_client/ref_service_spec.rb
spec/lib/gitlab/gitaly_client/ref_service_spec.rb
+20
-0
No files found.
lib/gitlab/git/repository.rb
View file @
65a4b948
...
...
@@ -784,6 +784,12 @@ module Gitlab
end
end
def
list_refs
wrapped_gitaly_errors
do
gitaly_ref_client
.
list_refs
end
end
# Refactoring aid; allows us to copy code from app/models/repository.rb
def
commit
(
ref
=
'HEAD'
)
Gitlab
::
Git
::
Commit
.
find
(
self
,
ref
)
...
...
lib/gitlab/gitaly_client/ref_service.rb
View file @
65a4b948
...
...
@@ -194,6 +194,16 @@ module Gitlab
raise
ArgumentError
,
ex
end
def
list_refs
(
patterns
=
[
Gitlab
::
Git
::
BRANCH_REF_PREFIX
])
request
=
Gitaly
::
ListRefsRequest
.
new
(
repository:
@gitaly_repo
,
patterns:
patterns
)
response
=
GitalyClient
.
call
(
@storage
,
:ref_service
,
:list_refs
,
request
,
timeout:
GitalyClient
.
fast_timeout
)
consume_list_refs_response
(
response
)
end
def
pack_refs
request
=
Gitaly
::
PackRefsRequest
.
new
(
repository:
@gitaly_repo
)
...
...
@@ -206,6 +216,10 @@ module Gitlab
response
.
flat_map
{
|
message
|
message
.
names
.
map
{
|
name
|
yield
(
name
)
}
}
end
def
consume_list_refs_response
(
response
)
response
.
flat_map
(
&
:references
)
end
def
sort_local_branches_by_param
(
sort_by
)
sort_by
=
'name'
if
sort_by
==
'name_asc'
...
...
spec/lib/gitlab/git/repository_spec.rb
View file @
65a4b948
...
...
@@ -1888,6 +1888,18 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do
end
end
describe
'#list_refs'
do
it
'returns a list of branches with their head commit'
do
refs
=
repository
.
list_refs
reference
=
refs
.
first
expect
(
refs
).
to
be_an
(
Enumerable
)
expect
(
reference
).
to
be_a
(
Gitaly
::
ListRefsResponse
::
Reference
)
expect
(
reference
.
name
).
to
be_a
(
String
)
expect
(
reference
.
target
).
to
be_a
(
String
)
end
end
describe
'#set_full_path'
do
before
do
repository_rugged
.
config
[
"gitlab.fullpath"
]
=
repository_path
...
...
spec/lib/gitlab/gitaly_client/ref_service_spec.rb
View file @
65a4b948
...
...
@@ -252,6 +252,26 @@ RSpec.describe Gitlab::GitalyClient::RefService do
end
end
describe
'#list_refs'
do
it
'sends a list_refs message'
do
expect_any_instance_of
(
Gitaly
::
RefService
::
Stub
)
.
to
receive
(
:list_refs
)
.
with
(
gitaly_request_with_params
(
patterns:
[
'refs/heads/'
]),
kind_of
(
Hash
))
.
and_call_original
client
.
list_refs
end
it
'accepts a patterns argument'
do
expect_any_instance_of
(
Gitaly
::
RefService
::
Stub
)
.
to
receive
(
:list_refs
)
.
with
(
gitaly_request_with_params
(
patterns:
[
'refs/tags/'
]),
kind_of
(
Hash
))
.
and_call_original
client
.
list_refs
([
Gitlab
::
Git
::
TAG_REF_PREFIX
])
end
end
describe
'#pack_refs'
do
it
'sends a pack_refs message'
do
expect_any_instance_of
(
Gitaly
::
RefService
::
Stub
)
...
...
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