1
0
Fork 0
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:
epriestley 2012-04-27 12:51:50 -07:00
parent 12cd0d0b67
commit 2bdde748d9
2 changed files with 26 additions and 13 deletions

View file

@ -112,22 +112,33 @@ final class DiffusionGitBrowseQuery extends DiffusionBrowseQuery {
// find their source URIs. // find their source URIs.
if ($submodules) { 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); $commit);
$module_info = parse_ini_string(
$module_info, $tmp = new TempFile();
$process_sections = true, Filesystem::writeFile($tmp, $contents);
$scanner_mode = INI_SCANNER_RAW); 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 ($submodules as $path) {
foreach ($module_info as $section) { $full_path = $path->getFullPath();
if (empty($section['path']) || empty($section['url'])) { $key = $dict['submodule.'.$full_path.'.url'];
continue; if (isset($dict[$key])) {
} $path->setExternalURI($key);
if ($section['path'] == $path->getFullPath()) {
$path->setExternalURI($section['url']);
}
} }
} }
} }

View file

@ -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/data/repositorypath');
phutil_require_module('phabricator', 'applications/diffusion/query/browse/base'); 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'); phutil_require_module('phutil', 'utils');