summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2018-11-14 15:37:30 +0100
committerJames Lopez <james@jameslopez.es>2018-11-14 16:07:31 +0100
commit3cd538c2e9e18f31cee008d9b9e13df4dfd40b1d (patch)
treefd0c6b32a4ccfc2951ec929a3c5765fd06326d83
parent24e5599748d98f34dc4f534eebc79a1bd9f0ddf9 (diff)
downloadgitlab-ce-3cd538c2e9e18f31cee008d9b9e13df4dfd40b1d.tar.gz
Fix text rendering of readme/index
-rw-r--r--lib/gitlab/file_detector.rb2
-rw-r--r--spec/lib/gitlab/file_detector_spec.rb4
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/gitlab/file_detector.rb b/lib/gitlab/file_detector.rb
index d6338b09e3d..4e749068f93 100644
--- a/lib/gitlab/file_detector.rb
+++ b/lib/gitlab/file_detector.rb
@@ -8,7 +8,7 @@ module Gitlab
module FileDetector
PATTERNS = {
# Project files
- readme: %r{\A(readme|index)[^/]*\z}i,
+ readme: %r{\A(readme|index)(|\.#{Gitlab::MarkupHelper::EXTENSIONS.join('|\.')})$[^\/]*\z}i,
changelog: %r{\A(changelog|history|changes|news)[^/]*\z}i,
license: %r{\A((un)?licen[sc]e|copying)(\.[^/]+)?\z}i,
contributing: %r{\Acontributing[^/]*\z}i,
diff --git a/spec/lib/gitlab/file_detector_spec.rb b/spec/lib/gitlab/file_detector_spec.rb
index edab53247e9..ba65827d1fb 100644
--- a/spec/lib/gitlab/file_detector_spec.rb
+++ b/spec/lib/gitlab/file_detector_spec.rb
@@ -23,6 +23,10 @@ describe Gitlab::FileDetector do
end
end
+ it 'returns nil for a README.rb file' do
+ expect(described_class.type_of('README.rb')).to be_nil
+ end
+
it 'returns nil for a README file in a directory' do
expect(described_class.type_of('foo/README.md')).to be_nil
end