Commit 34f1dbb1 authored by Robert Speicher's avatar Robert Speicher

Better commit lookup for CommitRangeReferenceFilter

parent 6853465a
...@@ -24,6 +24,12 @@ module Gitlab ...@@ -24,6 +24,12 @@ module Gitlab
end end
end end
def initialize(*args)
super
@commit_map = {}
end
# Pattern used to extract commit range references from text # Pattern used to extract commit range references from text
# #
# The beginning and ending SHA1 sums can be between 6 and 40 hex # The beginning and ending SHA1 sums can be between 6 and 40 hex
...@@ -76,10 +82,16 @@ module Gitlab ...@@ -76,10 +82,16 @@ module Gitlab
[from_id, to_id] [from_id, to_id]
end end
def commit(id)
unless @commit_map[id]
@commit_map[id] = project.repository.commit(id)
end
@commit_map[id]
end
def valid_range?(project, from_id, to_id) def valid_range?(project, from_id, to_id)
project.valid_repo? && project.valid_repo? && commit(from_id) && commit(to_id)
project.repository.commit(from_id) &&
project.repository.commit(to_id)
end end
def url_for_commit_range(project, from_id, to_id) def url_for_commit_range(project, from_id, to_id)
......
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