diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-04-15 15:54:55 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-04-20 13:01:46 -0400 |
commit | 34f1dbb143f5b3ddfb8b8fdd73f5991638f8bb7c (patch) | |
tree | 0834b3609bc6b6cb53dd109f821c5f7104a0eb07 | |
parent | 6853465acfc5887fd683a662afbaac1dbadd6aab (diff) | |
download | gitlab-ce-34f1dbb143f5b3ddfb8b8fdd73f5991638f8bb7c.tar.gz |
Better commit lookup for CommitRangeReferenceFilter
-rw-r--r-- | lib/gitlab/markdown/commit_range_reference_filter.rb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/gitlab/markdown/commit_range_reference_filter.rb b/lib/gitlab/markdown/commit_range_reference_filter.rb index ff85be8cb84..80c57b158a1 100644 --- a/lib/gitlab/markdown/commit_range_reference_filter.rb +++ b/lib/gitlab/markdown/commit_range_reference_filter.rb @@ -24,6 +24,12 @@ module Gitlab end end + def initialize(*args) + super + + @commit_map = {} + end + # Pattern used to extract commit range references from text # # The beginning and ending SHA1 sums can be between 6 and 40 hex @@ -76,10 +82,16 @@ module Gitlab [from_id, to_id] 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) - project.valid_repo? && - project.repository.commit(from_id) && - project.repository.commit(to_id) + project.valid_repo? && commit(from_id) && commit(to_id) end def url_for_commit_range(project, from_id, to_id) |