Render index.* like README.* when it's present in a directory

Resolves #18933
This commit is contained in:
Jakub Jirutka 2018-01-18 14:16:31 +01:00 committed by Achilleas Pipinellis
parent c0d30fad97
commit cb3f851098
No known key found for this signature in database
GPG key ID: A0996FBD3E92C17B
3 changed files with 11 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
title: Make index.* render like README.* when it's present in a repository
merge_request: 16550
author: Jakub Jirutka
type: added

View file

@ -8,7 +8,7 @@ module Gitlab
module FileDetector
PATTERNS = {
# Project files
readme: %r{\Areadme[^/]*\z}i,
readme: %r{\A(readme|index)[^\/]*\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,

View file

@ -15,7 +15,11 @@ describe Gitlab::FileDetector do
describe '.type_of' do
it 'returns the type of a README file' do
expect(described_class.type_of('README.md')).to eq(:readme)
%w(README readme INDEX index).each do |filename|
%w(.md .adoc).each do |extname|
expect(described_class.type_of(filename + extname)).to eq(:readme)
end
end
end
it 'returns nil for a README file in a directory' do