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
039df026
Commit
039df026
authored
Nov 12, 2018
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid Gitaly RPC errors when fetching diff stats
parent
0ff34e77
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
1 deletion
+28
-1
changelogs/unreleased/osw-fallback-on-blank-refs.yml
changelogs/unreleased/osw-fallback-on-blank-refs.yml
+5
-0
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+9
-1
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+14
-0
No files found.
changelogs/unreleased/osw-fallback-on-blank-refs.yml
0 → 100644
View file @
039df026
---
title
:
Avoid Gitaly RPC errors when fetching diff stats
merge_request
:
22995
author
:
type
:
fixed
lib/gitlab/git/repository.rb
View file @
039df026
...
...
@@ -419,13 +419,17 @@ module Gitlab
end
def
diff_stats
(
left_id
,
right_id
)
if
[
left_id
,
right_id
].
any?
{
|
ref
|
ref
.
blank?
||
Gitlab
::
Git
.
blank_ref?
(
ref
)
}
return
empty_diff_stats
end
stats
=
wrapped_gitaly_errors
do
gitaly_commit_client
.
diff_stats
(
left_id
,
right_id
)
end
Gitlab
::
Git
::
DiffStatsCollection
.
new
(
stats
)
rescue
CommandError
,
TypeError
Gitlab
::
Git
::
DiffStatsCollection
.
new
([])
empty_diff_stats
end
# Returns a RefName for a given SHA
...
...
@@ -962,6 +966,10 @@ module Gitlab
private
def
empty_diff_stats
Gitlab
::
Git
::
DiffStatsCollection
.
new
([])
end
def
uncached_has_local_branches?
wrapped_gitaly_errors
do
gitaly_repository_client
.
has_local_branches?
...
...
spec/lib/gitlab/git/repository_spec.rb
View file @
039df026
...
...
@@ -1095,12 +1095,26 @@ describe Gitlab::Git::Repository, :seed_helper do
end
it
'returns no Gitaly::DiffStats when there is a nil SHA'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
CommitService
)
.
not_to
receive
(
:diff_stats
)
collection
=
repository
.
diff_stats
(
nil
,
'master'
)
expect
(
collection
).
to
be_a
(
Gitlab
::
Git
::
DiffStatsCollection
)
expect
(
collection
).
to
be_a
(
Enumerable
)
expect
(
collection
.
to_a
).
to
be_empty
end
it
'returns no Gitaly::DiffStats when there is a BLANK_SHA'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
CommitService
)
.
not_to
receive
(
:diff_stats
)
collection
=
repository
.
diff_stats
(
Gitlab
::
Git
::
BLANK_SHA
,
'master'
)
expect
(
collection
).
to
be_a
(
Gitlab
::
Git
::
DiffStatsCollection
)
expect
(
collection
).
to
be_a
(
Enumerable
)
expect
(
collection
.
to_a
).
to
be_empty
end
end
describe
"#ls_files"
do
...
...
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