1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00:55 +01:00

Order readme files based on how well we can get the markup right.

Summary:
Handling readmes with no extension is a bit of a hack, but seemed like a small cost.

The Big Win here is that you can commit README.remarkup and README.md and have both Phabricator and GitHub render __with__ //all// ##the## ~~pretty~~ **markup**.

Test Plan: Looked at some readme files.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10047
This commit is contained in:
Asher Baker 2014-07-25 06:43:25 -07:00 committed by epriestley
parent c006cca9b1
commit 556bca3099

View file

@ -32,6 +32,7 @@ final class DiffusionReadmeQueryConduitAPIMethod
$paths[] = DiffusionRepositoryPath::newFromDictionary($dict);
}
$best = -1;
$readme = '';
foreach ($paths as $result_path) {
$file_type = $result_path->getFileType();
@ -41,11 +42,35 @@ final class DiffusionReadmeQueryConduitAPIMethod
continue;
}
$path = $result_path->getPath();
$path = strtolower($result_path->getPath());
if (preg_match('/^readme(|\.txt|\.remarkup|\.rainbow|\.md)$/i', $path)) {
if ($path === 'readme') {
$path .= '.txt';
}
if (strncmp($path, 'readme.', 7) !== 0) {
continue;
}
$priority = 0;
switch (substr($path, 7)) {
case 'remarkup':
$priority = 100;
break;
case 'rainbow':
$priority = 90;
break;
case 'md':
$priority = 50;
break;
case 'txt':
$priority = 10;
break;
}
if ($priority > $best) {
$best = $priority;
$readme = $result_path;
break;
}
}