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
Léo-Paul Géneau
gitlab-ce
Commits
a6dbb85e
Commit
a6dbb85e
authored
Jan 29, 2018
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove Rugged exception in cache rescue
parent
9d53c15c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
18 deletions
+14
-18
app/models/repository.rb
app/models/repository.rb
+1
-1
lib/gitlab/git/tree.rb
lib/gitlab/git/tree.rb
+2
-0
spec/lib/gitlab/git/tree_spec.rb
spec/lib/gitlab/git/tree_spec.rb
+8
-12
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+3
-5
No files found.
app/models/repository.rb
View file @
a6dbb85e
...
@@ -949,7 +949,7 @@ class Repository
...
@@ -949,7 +949,7 @@ class Repository
end
end
instance_variable_set
(
ivar
,
value
)
instance_variable_set
(
ivar
,
value
)
rescue
Rugged
::
ReferenceError
,
Gitlab
::
Git
::
Repository
::
NoRepository
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
# Even if the above `#exists?` check passes these errors might still
# Even if the above `#exists?` check passes these errors might still
# occur (for example because of a non-existing HEAD). We want to
# occur (for example because of a non-existing HEAD). We want to
# gracefully handle this and not cache anything
# gracefully handle this and not cache anything
...
...
lib/gitlab/git/tree.rb
View file @
a6dbb85e
...
@@ -83,6 +83,8 @@ module Gitlab
...
@@ -83,6 +83,8 @@ module Gitlab
commit_id:
sha
commit_id:
sha
)
)
end
end
rescue
Rugged
::
ReferenceError
[]
end
end
end
end
...
...
spec/lib/gitlab/git/tree_spec.rb
View file @
a6dbb85e
...
@@ -80,22 +80,18 @@ describe Gitlab::Git::Tree, seed_helper: true do
...
@@ -80,22 +80,18 @@ describe Gitlab::Git::Tree, seed_helper: true do
end
end
describe
'#where'
do
describe
'#where'
do
context
'with gitaly disabled'
do
shared_examples
'#where'
do
before
do
it
'returns an empty array when called with an invalid ref'
do
allow
(
Gitlab
::
GitalyClient
).
to
receive
(
:feature_enabled?
).
and_return
(
false
)
expect
(
described_class
.
where
(
repository
,
'foobar-does-not-exist'
)).
to
eq
([])
end
it
'calls #tree_entries_from_rugged'
do
expect
(
described_class
).
to
receive
(
:tree_entries_from_rugged
)
described_class
.
where
(
repository
,
SeedRepo
::
Commit
::
ID
,
'/'
)
end
end
end
end
it
'gets the tree entries from GitalyClient'
do
context
'with gitaly'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
CommitService
).
to
receive
(
:tree_entries
)
it_behaves_like
'#where'
end
described_class
.
where
(
repository
,
SeedRepo
::
Commit
::
ID
,
'/'
)
context
'without gitaly'
,
:skip_gitaly_mock
do
it_behaves_like
'#where'
end
end
end
end
end
end
spec/models/repository_spec.rb
View file @
a6dbb85e
...
@@ -772,8 +772,7 @@ describe Repository do
...
@@ -772,8 +772,7 @@ describe Repository do
user
,
'LICENSE'
,
'Copyright!'
,
user
,
'LICENSE'
,
'Copyright!'
,
message:
'Add LICENSE'
,
branch_name:
'master'
)
message:
'Add LICENSE'
,
branch_name:
'master'
)
allow
(
repository
).
to
receive
(
:file_on_head
)
allow
(
repository
).
to
receive
(
:root_ref
).
and_raise
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
.
and_raise
(
Rugged
::
ReferenceError
)
expect
(
repository
.
license_blob
).
to
be_nil
expect
(
repository
.
license_blob
).
to
be_nil
end
end
...
@@ -885,7 +884,7 @@ describe Repository do
...
@@ -885,7 +884,7 @@ describe Repository do
end
end
it
'returns nil for empty repository'
do
it
'returns nil for empty repository'
do
allow
(
repository
).
to
receive
(
:
file_on_head
).
and_raise
(
Rugged
::
ReferenceError
)
allow
(
repository
).
to
receive
(
:
root_ref
).
and_raise
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
expect
(
repository
.
gitlab_ci_yml
).
to
be_nil
expect
(
repository
.
gitlab_ci_yml
).
to
be_nil
end
end
end
end
...
@@ -1937,8 +1936,7 @@ describe Repository do
...
@@ -1937,8 +1936,7 @@ describe Repository do
describe
'#avatar'
do
describe
'#avatar'
do
it
'returns nil if repo does not exist'
do
it
'returns nil if repo does not exist'
do
expect
(
repository
).
to
receive
(
:file_on_head
)
allow
(
repository
).
to
receive
(
:root_ref
).
and_raise
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
.
and_raise
(
Rugged
::
ReferenceError
)
expect
(
repository
.
avatar
).
to
eq
(
nil
)
expect
(
repository
.
avatar
).
to
eq
(
nil
)
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