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
5e0e5801
Commit
5e0e5801
authored
Apr 18, 2017
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-enable ref operations with gitaly after not-found fix
parent
d32ecb23
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
79 deletions
+92
-79
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+29
-33
lib/gitlab/gitaly_client/ref.rb
lib/gitlab/gitaly_client/ref.rb
+3
-1
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+60
-45
No files found.
lib/gitlab/git/repository.rb
View file @
5e0e5801
...
@@ -45,17 +45,13 @@ module Gitlab
...
@@ -45,17 +45,13 @@ module Gitlab
# Default branch in the repository
# Default branch in the repository
def
root_ref
def
root_ref
# NOTE: This feature is intentionally disabled until
@root_ref
||=
gitaly_migrate
(
:root_ref
)
do
|
is_enabled
|
# https://gitlab.com/gitlab-org/gitaly/issues/179 is resolved
if
is_enabled
# @root_ref ||= Gitlab::GitalyClient.migrate(:root_ref) do |is_enabled|
gitaly_ref_client
.
default_branch_name
# if is_enabled
else
# gitaly_ref_client.default_branch_name
discover_default_branch
# else
end
@root_ref
||=
discover_default_branch
end
# end
# end
rescue
GRPC
::
BadStatus
=>
e
raise
CommandError
.
new
(
e
)
end
end
# Alias to old method for compatibility
# Alias to old method for compatibility
...
@@ -72,17 +68,13 @@ module Gitlab
...
@@ -72,17 +68,13 @@ module Gitlab
# Returns an Array of branch names
# Returns an Array of branch names
# sorted by name ASC
# sorted by name ASC
def
branch_names
def
branch_names
# Gitlab::GitalyClient.migrate(:branch_names) do |is_enabled|
gitaly_migrate
(
:branch_names
)
do
|
is_enabled
|
# NOTE: This feature is intentionally disabled until
if
is_enabled
# https://gitlab.com/gitlab-org/gitaly/issues/179 is resolved
gitaly_ref_client
.
branch_names
# if is_enabled
else
# gitaly_ref_client.branch_names
branches
.
map
(
&
:name
)
# else
end
branches
.
map
(
&
:name
)
end
# end
# end
rescue
GRPC
::
BadStatus
=>
e
raise
CommandError
.
new
(
e
)
end
end
# Returns an Array of Branches
# Returns an Array of Branches
...
@@ -152,17 +144,13 @@ module Gitlab
...
@@ -152,17 +144,13 @@ module Gitlab
# Returns an Array of tag names
# Returns an Array of tag names
def
tag_names
def
tag_names
# Gitlab::GitalyClient.migrate(:tag_names) do |is_enabled|
gitaly_migrate
(
:tag_names
)
do
|
is_enabled
|
# NOTE: This feature is intentionally disabled until
if
is_enabled
# https://gitlab.com/gitlab-org/gitaly/issues/179 is resolved
gitaly_ref_client
.
tag_names
# if is_enabled
else
# gitaly_ref_client.tag_names
rugged
.
tags
.
map
{
|
t
|
t
.
name
}
# else
end
rugged
.
tags
.
map
{
|
t
|
t
.
name
}
end
# end
# end
rescue
GRPC
::
BadStatus
=>
e
raise
CommandError
.
new
(
e
)
end
end
# Returns an Array of Tags
# Returns an Array of Tags
...
@@ -1294,6 +1282,14 @@ module Gitlab
...
@@ -1294,6 +1282,14 @@ module Gitlab
@gitaly_commit_client
||=
Gitlab
::
GitalyClient
::
Commit
.
new
(
self
)
@gitaly_commit_client
||=
Gitlab
::
GitalyClient
::
Commit
.
new
(
self
)
end
end
def
gitaly_migrate
(
method
,
&
block
)
Gitlab
::
GitalyClient
.
migrate
(
method
,
&
block
)
rescue
GRPC
::
NotFound
=>
e
raise
NoRepository
.
new
(
e
)
rescue
GRPC
::
BadStatus
=>
e
raise
CommandError
.
new
(
e
)
end
# Returns the `Rugged` sorting type constant for a given
# Returns the `Rugged` sorting type constant for a given
# sort type key. Valid keys are `:none`, `:topo`, and `:date`
# sort type key. Valid keys are `:none`, `:topo`, and `:date`
def
rugged_sort_type
(
key
)
def
rugged_sort_type
(
key
)
...
...
lib/gitlab/gitaly_client/ref.rb
View file @
5e0e5801
...
@@ -11,7 +11,9 @@ module Gitlab
...
@@ -11,7 +11,9 @@ module Gitlab
def
default_branch_name
def
default_branch_name
request
=
Gitaly
::
FindDefaultBranchNameRequest
.
new
(
repository:
@gitaly_repo
)
request
=
Gitaly
::
FindDefaultBranchNameRequest
.
new
(
repository:
@gitaly_repo
)
stub
.
find_default_branch_name
(
request
).
name
.
gsub
(
/^refs\/heads\//
,
''
)
branch_name
=
stub
.
find_default_branch_name
(
request
).
name
Gitlab
::
Git
.
branch_name
(
branch_name
)
end
end
def
branch_names
def
branch_names
...
...
spec/lib/gitlab/git/repository_spec.rb
View file @
5e0e5801
...
@@ -24,21 +24,26 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -24,21 +24,26 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
end
end
end
# TODO: Uncomment when feature is reenabled
context
'with gitaly enabled'
do
# context 'with gitaly enabled' do
before
{
stub_gitaly
}
# before { stub_gitaly }
#
it
'gets the branch name from GitalyClient'
do
# it 'gets the branch name from GitalyClient' do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:default_branch_name
)
# expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:default_branch_name)
repository
.
root_ref
# repository.root_ref
end
# end
#
it
'wraps GRPC not found'
do
# it 'wraps GRPC exceptions' do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:default_branch_name
).
# expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:default_branch_name).
and_raise
(
GRPC
::
NotFound
)
# and_raise(GRPC::Unknown)
expect
{
repository
.
root_ref
}.
to
raise_error
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
# expect { repository.root_ref }.to raise_error(Gitlab::Git::CommandError)
end
# end
# end
it
'wraps GRPC exceptions'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:default_branch_name
).
and_raise
(
GRPC
::
Unknown
)
expect
{
repository
.
root_ref
}.
to
raise_error
(
Gitlab
::
Git
::
CommandError
)
end
end
end
end
describe
"#rugged"
do
describe
"#rugged"
do
...
@@ -113,21 +118,26 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -113,21 +118,26 @@ describe Gitlab::Git::Repository, seed_helper: true do
it
{
is_expected
.
to
include
(
"master"
)
}
it
{
is_expected
.
to
include
(
"master"
)
}
it
{
is_expected
.
not_to
include
(
"branch-from-space"
)
}
it
{
is_expected
.
not_to
include
(
"branch-from-space"
)
}
# TODO: Uncomment when feature is reenabled
context
'with gitaly enabled'
do
# context 'with gitaly enabled' do
before
{
stub_gitaly
}
# before { stub_gitaly }
#
it
'gets the branch names from GitalyClient'
do
# it 'gets the branch names from GitalyClient' do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:branch_names
)
# expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:branch_names)
subject
# subject
end
# end
#
it
'wraps GRPC not found'
do
# it 'wraps GRPC exceptions' do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:branch_names
).
# expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:branch_names).
and_raise
(
GRPC
::
NotFound
)
# and_raise(GRPC::Unknown)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
# expect { subject }.to raise_error(Gitlab::Git::CommandError)
end
# end
# end
it
'wraps GRPC other exceptions'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:branch_names
).
and_raise
(
GRPC
::
Unknown
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Git
::
CommandError
)
end
end
end
end
describe
'#tag_names'
do
describe
'#tag_names'
do
...
@@ -145,21 +155,26 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -145,21 +155,26 @@ describe Gitlab::Git::Repository, seed_helper: true do
it
{
is_expected
.
to
include
(
"v1.0.0"
)
}
it
{
is_expected
.
to
include
(
"v1.0.0"
)
}
it
{
is_expected
.
not_to
include
(
"v5.0.0"
)
}
it
{
is_expected
.
not_to
include
(
"v5.0.0"
)
}
# TODO: Uncomment when feature is reenabled
context
'with gitaly enabled'
do
# context 'with gitaly enabled' do
before
{
stub_gitaly
}
# before { stub_gitaly }
#
it
'gets the tag names from GitalyClient'
do
# it 'gets the tag names from GitalyClient' do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:tag_names
)
# expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:tag_names)
subject
# subject
end
# end
#
it
'wraps GRPC not found'
do
# it 'wraps GRPC exceptions' do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:tag_names
).
# expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:tag_names).
and_raise
(
GRPC
::
NotFound
)
# and_raise(GRPC::Unknown)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
# expect { subject }.to raise_error(Gitlab::Git::CommandError)
end
# end
# end
it
'wraps GRPC exceptions'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:tag_names
).
and_raise
(
GRPC
::
Unknown
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Git
::
CommandError
)
end
end
end
end
shared_examples
'archive check'
do
|
extenstion
|
shared_examples
'archive check'
do
|
extenstion
|
...
...
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