mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 13:22:42 +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:
parent
c006cca9b1
commit
556bca3099
1 changed files with 28 additions and 3 deletions
|
@ -32,6 +32,7 @@ final class DiffusionReadmeQueryConduitAPIMethod
|
||||||
$paths[] = DiffusionRepositoryPath::newFromDictionary($dict);
|
$paths[] = DiffusionRepositoryPath::newFromDictionary($dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$best = -1;
|
||||||
$readme = '';
|
$readme = '';
|
||||||
foreach ($paths as $result_path) {
|
foreach ($paths as $result_path) {
|
||||||
$file_type = $result_path->getFileType();
|
$file_type = $result_path->getFileType();
|
||||||
|
@ -41,11 +42,35 @@ final class DiffusionReadmeQueryConduitAPIMethod
|
||||||
continue;
|
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;
|
$readme = $result_path;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue