mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 05:50:55 +01:00
Fix DiffusionGitBrowseQuery to parse with "git config -l -f" instead of PHP ini parser
Summary: See discussion on rPc0aac8267dda74664acac5c93d9aeb5a0f9c4564. Test Plan: Looked at externals/, got a correctly-behaving link. Reviewers: vrana, davidreuss, btrahan Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D2317
This commit is contained in:
parent
12cd0d0b67
commit
2bdde748d9
2 changed files with 26 additions and 13 deletions
|
@ -112,22 +112,33 @@ final class DiffusionGitBrowseQuery extends DiffusionBrowseQuery {
|
|||
// find their source URIs.
|
||||
|
||||
if ($submodules) {
|
||||
list($module_info) = $repository->execxLocalCommand(
|
||||
'show %s:.gitmodules',
|
||||
|
||||
// NOTE: We need to read the file out of git and write it to a temporary
|
||||
// location because "git config -f" doesn't accept a "commit:path"-style
|
||||
// argument.
|
||||
list($contents) = $repository->execxLocalCommand(
|
||||
'cat-file blob %s:.gitmodules',
|
||||
$commit);
|
||||
$module_info = parse_ini_string(
|
||||
$module_info,
|
||||
$process_sections = true,
|
||||
$scanner_mode = INI_SCANNER_RAW);
|
||||
|
||||
$tmp = new TempFile();
|
||||
Filesystem::writeFile($tmp, $contents);
|
||||
list($module_info) = $repository->execxLocalCommand(
|
||||
'config -l -f %s',
|
||||
$tmp);
|
||||
|
||||
$dict = array();
|
||||
$lines = explode("\n", trim($module_info));
|
||||
foreach ($lines as $line) {
|
||||
list($key, $value) = explode('=', $line, 2);
|
||||
$parts = explode('.', $key);
|
||||
$dict[$key] = $value;
|
||||
}
|
||||
|
||||
foreach ($submodules as $path) {
|
||||
foreach ($module_info as $section) {
|
||||
if (empty($section['path']) || empty($section['url'])) {
|
||||
continue;
|
||||
}
|
||||
if ($section['path'] == $path->getFullPath()) {
|
||||
$path->setExternalURI($section['url']);
|
||||
}
|
||||
$full_path = $path->getFullPath();
|
||||
$key = $dict['submodule.'.$full_path.'.url'];
|
||||
if (isset($dict[$key])) {
|
||||
$path->setExternalURI($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ phutil_require_module('phabricator', 'applications/differential/constants/change
|
|||
phutil_require_module('phabricator', 'applications/diffusion/data/repositorypath');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/browse/base');
|
||||
|
||||
phutil_require_module('phutil', 'filesystem');
|
||||
phutil_require_module('phutil', 'filesystem/tempfile');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue