Commit d453b24a authored by Robert Speicher's avatar Robert Speicher

Merge branch 'validate-readme-format' into 'master'

Validate README format

Take the first previewable README file as project's README, otherwise if
none file is available, or we can't preview any of them, we assume that
project doesn't have a README file.

Fixes #3978
parents 67a927ff 8e33ec1d
......@@ -19,6 +19,7 @@ v 8.4.0 (unreleased)
- Show 'All' tab by default in the builds page
- Fix API project lookups when querying with a namespace with dots (Stan Hu)
- Update version check images to use SVG
- Validate README format before displaying
v 8.3.3 (unreleased)
- Fix project transfer e-mail sending incorrect paths in e-mail notification (Stan Hu)
......
......@@ -17,18 +17,16 @@ class Tree
def readme
return @readme if defined?(@readme)
available_readmes = blobs.select(&:readme?)
# Take the first previewable readme, or return nil if none is available or
# we can't preview any of them
readme_tree = blobs.find do |blob|
blob.readme? && (previewable?(blob.name) || plain?(blob.name))
end
if available_readmes.count == 0
if readme_tree.nil?
return @readme = nil
end
# Take the first previewable readme, or the first available readme, if we
# can't preview any of them
readme_tree = available_readmes.find do |readme|
previewable?(readme.name)
end || available_readmes.first
readme_path = path == '/' ? readme_tree.name : File.join(path, readme_tree.name)
git_repo = repository.raw_repository
......
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