1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 10:12:41 +01:00

Correct Git repository browse behavior for differences in "ls-tree" output

Summary:
Ref T13589. The output for "git ls-tree commit:path" (the old invocation) and "git ls-tree commit -- path" (the new invocation) differs: the latter emits absolute paths.

Update the code to account for this difference in behavior.

Test Plan:
  - Browsed a non-root directory in a Git repository in Diffusion.
  - Before: saw absolute paths.
  - After: saw relative paths.

Maniphest Tasks: T13589

Differential Revision: https://secure.phabricator.com/D21519
This commit is contained in:
epriestley 2021-01-25 09:06:02 -08:00
parent 1da94dcf49
commit bafe8d1bbd

View file

@ -138,12 +138,6 @@ final class DiffusionBrowseQueryConduitAPIMethod
$submodules = array(); $submodules = array();
if ($path !== null) {
$prefix = rtrim($path, '/').'/';
} else {
$prefix = '';
}
$count = 0; $count = 0;
$results = array(); $results = array();
$lines = empty($stdout) $lines = empty($stdout)
@ -166,7 +160,7 @@ final class DiffusionBrowseQueryConduitAPIMethod
$line)); $line));
} }
list($mode, $type, $hash, $size, $name) = $parts; list($mode, $type, $hash, $size, $full_path) = $parts;
$path_result = new DiffusionRepositoryPath(); $path_result = new DiffusionRepositoryPath();
@ -184,8 +178,14 @@ final class DiffusionBrowseQueryConduitAPIMethod
} }
} }
$path_result->setFullPath($prefix.$name); if ($path === null) {
$path_result->setPath($name); $local_path = $full_path;
} else {
$local_path = basename($full_path);
}
$path_result->setFullPath($full_path);
$path_result->setPath($local_path);
$path_result->setHash($hash); $path_result->setHash($hash);
$path_result->setFileType($file_type); $path_result->setFileType($file_type);
$path_result->setFileSize($size); $path_result->setFileSize($size);