Commit eec2e4b9 authored by Patrick Steinhardt's avatar Patrick Steinhardt

checks: Introduce `#blank_rev?` helper

We have multiple locations which check for a blank revision, which
either is a blank value or the zero OID. We're about to add one more
location, so let's prepare for this and create a helper function to
deduplicate the logic.
parent e45e9924
......@@ -35,7 +35,7 @@ module Gitlab
def commits
newrevs = @changes.map do |change|
newrev = change[:newrev]
newrev unless newrev.blank? || Gitlab::Git.blank_ref?(newrev)
newrev unless blank_rev?(newrev)
end.compact
return [] if newrevs.empty?
......@@ -80,7 +80,7 @@ module Gitlab
@single_changes_accesses ||=
changes.map do |change|
commits =
if change[:newrev].blank? || Gitlab::Git.blank_ref?(change[:newrev])
if blank_rev?(change[:newrev])
[]
else
Gitlab::Lazy.new { commits_for(change[:newrev]) }
......@@ -109,6 +109,10 @@ module Gitlab
def bulk_access_checks!
Gitlab::Checks::LfsCheck.new(self).validate!
end
def blank_rev?(rev)
rev.blank? || Gitlab::Git.blank_ref?(rev)
end
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment