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
Jérome Perrin
gitlab-ce
Commits
fd46d6ce
Commit
fd46d6ce
authored
Jan 30, 2018
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove intermediate methods on Branch and Tag classes
parent
73bd48de
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
28 deletions
+17
-28
lib/gitlab/git/branch.rb
lib/gitlab/git/branch.rb
+5
-11
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+2
-2
lib/gitlab/git/tag.rb
lib/gitlab/git/tag.rb
+0
-6
lib/gitlab/gitaly_client/ref_service.rb
lib/gitlab/gitaly_client/ref_service.rb
+10
-9
No files found.
lib/gitlab/git/branch.rb
View file @
fd46d6ce
module
Gitlab
module
Gitlab
module
Git
module
Git
class
Branch
<
Ref
class
Branch
<
Ref
class
<<
self
def
self
.
find
(
repo
,
branch_name
)
def
find
(
repo
,
branch_name
)
if
branch_name
.
is_a?
(
Gitlab
::
Git
::
Branch
)
if
branch_name
.
is_a?
(
Gitlab
::
Git
::
Branch
)
branch_name
branch_name
else
else
repo
.
find_branch
(
branch_name
)
repo
.
find_branch
(
branch_name
)
end
end
def
names_contains_sha
(
repo
,
sha
,
limit:
0
)
GitalyClient
::
RefService
.
new
(
repo
).
branch_names_contains_sha
(
sha
)
end
end
end
end
...
...
lib/gitlab/git/repository.rb
View file @
fd46d6ce
...
@@ -1358,7 +1358,7 @@ module Gitlab
...
@@ -1358,7 +1358,7 @@ module Gitlab
def
branch_names_contains_sha
(
sha
)
def
branch_names_contains_sha
(
sha
)
gitaly_migrate
(
:branch_names_contains_sha
)
do
|
is_enabled
|
gitaly_migrate
(
:branch_names_contains_sha
)
do
|
is_enabled
|
if
is_enabled
if
is_enabled
Gitlab
::
Git
::
Branch
.
names_contains_sha
(
self
,
sha
)
gitaly_ref_client
.
branch_names_contains_sha
(
sha
)
else
else
refs_contains_sha
(
:branch
,
sha
)
refs_contains_sha
(
:branch
,
sha
)
end
end
...
@@ -1368,7 +1368,7 @@ module Gitlab
...
@@ -1368,7 +1368,7 @@ module Gitlab
def
tag_names_contains_sha
(
sha
)
def
tag_names_contains_sha
(
sha
)
gitaly_migrate
(
:tag_names_contains_sha
)
do
|
is_enabled
|
gitaly_migrate
(
:tag_names_contains_sha
)
do
|
is_enabled
|
if
is_enabled
if
is_enabled
Gitlab
::
Git
::
Tag
.
names_contains_sha
(
self
,
sha
)
gitaly_ref_client
.
tag_names_contains_sha
(
sha
)
else
else
refs_contains_sha
(
:tag
,
sha
)
refs_contains_sha
(
:tag
,
sha
)
end
end
...
...
lib/gitlab/git/tag.rb
View file @
fd46d6ce
module
Gitlab
module
Gitlab
module
Git
module
Git
class
Tag
<
Ref
class
Tag
<
Ref
class
<<
self
def
names_contains_sha
(
repo
,
sha
)
GitalyClient
::
RefService
.
new
(
repo
).
branch_names_contains_sha
(
sha
)
end
end
attr_reader
:object_sha
attr_reader
:object_sha
def
initialize
(
repository
,
name
,
target
,
target_commit
,
message
=
nil
)
def
initialize
(
repository
,
name
,
target
,
target_commit
,
message
=
nil
)
...
...
lib/gitlab/gitaly_client/ref_service.rb
View file @
fd46d6ce
...
@@ -146,7 +146,7 @@ module Gitlab
...
@@ -146,7 +146,7 @@ module Gitlab
end
end
# Limit: 0 implies no limit, thus all tag names will be returned
# Limit: 0 implies no limit, thus all tag names will be returned
def
tag_names_contain
ing
(
sha
,
limit:
0
)
def
tag_names_contain
s_sha
(
sha
,
limit:
0
)
request
=
Gitaly
::
ListTagNamesContainingCommitRequest
.
new
(
request
=
Gitaly
::
ListTagNamesContainingCommitRequest
.
new
(
repository:
@gitaly_repo
,
repository:
@gitaly_repo
,
commit_id:
sha
,
commit_id:
sha
,
...
@@ -155,10 +155,7 @@ module Gitlab
...
@@ -155,10 +155,7 @@ module Gitlab
stream
=
GitalyClient
.
call
(
@repository
.
storage
,
:ref_service
,
:list_tag_names_containing_commit
,
request
)
stream
=
GitalyClient
.
call
(
@repository
.
storage
,
:ref_service
,
:list_tag_names_containing_commit
,
request
)
stream
.
each_with_object
([])
do
|
response
,
array
|
consume_ref_contains_sha_response
(
stream
,
:tag_names
)
encoded_names
=
response
.
tag_names
.
map
{
|
t
|
Gitlab
::
Git
.
ref_name
(
t
)
}
array
.
concat
(
encoded_names
)
end
end
end
# Limit: 0 implies no limit, thus all tag names will be returned
# Limit: 0 implies no limit, thus all tag names will be returned
...
@@ -171,10 +168,7 @@ module Gitlab
...
@@ -171,10 +168,7 @@ module Gitlab
stream
=
GitalyClient
.
call
(
@repository
.
storage
,
:ref_service
,
:list_branch_names_containing_commit
,
request
)
stream
=
GitalyClient
.
call
(
@repository
.
storage
,
:ref_service
,
:list_branch_names_containing_commit
,
request
)
stream
.
each_with_object
([])
do
|
response
,
array
|
consume_ref_contains_sha_response
(
stream
,
:branch_names
)
encoded_names
=
response
.
branch_names
.
map
{
|
b
|
Gitlab
::
Git
.
ref_name
(
b
)
}
array
.
concat
(
encoded_names
)
end
end
end
private
private
...
@@ -247,6 +241,13 @@ module Gitlab
...
@@ -247,6 +241,13 @@ module Gitlab
Gitlab
::
Git
::
Commit
.
decorate
(
@repository
,
hash
)
Gitlab
::
Git
::
Commit
.
decorate
(
@repository
,
hash
)
end
end
def
consume_ref_contains_sha_response
(
stream
,
collection_name
)
stream
.
each_with_object
([])
do
|
response
,
array
|
encoded_names
=
response
.
send
(
collection_name
).
map
{
|
b
|
Gitlab
::
Git
.
ref_name
(
b
)
}
# rubocop:disable GitlabSecurity/PublicSend
array
.
concat
(
encoded_names
)
end
end
def
invalid_ref!
(
message
)
def
invalid_ref!
(
message
)
raise
Gitlab
::
Git
::
Repository
::
InvalidRef
.
new
(
message
)
raise
Gitlab
::
Git
::
Repository
::
InvalidRef
.
new
(
message
)
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