diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-11-12 22:26:51 +0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-11-14 22:33:30 +0300 |
commit | 039df0267e6c3e2070aa9bf92b56bee0f0ac8ca9 (patch) | |
tree | 47a133ba4554cbd6484f682c8349a13c6b4b29d0 /lib/gitlab/git | |
parent | 0ff34e77293eb21f242de4d8a96f31d09cbdf572 (diff) |
Avoid Gitaly RPC errors when fetching diff stats
Diffstat (limited to 'lib/gitlab/git')
-rw-r--r-- | lib/gitlab/git/repository.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 1642c4c5687..aaaf794668d 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -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? |