mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-13 02:12:41 +01:00
Fix an issue where entering the same Owners path for two repositories would incorrectly de-dupe the path
Summary: Ref T13130. See <https://discourse.phabricator-community.org/t/unable-to-create-owners-package-with-same-path-in-multiple-repositories/1400/1>. When you edit paths in Owners, we deduplicate similar paths, like `/x/y` and `/x/y/`. However, this logic currently only examines the paths, and incorrectly deduplicates the same path in different repositories. Instead, consider the repository before deduplicating. Test Plan: - Edited an Owners package and added the path "/" in two different repositories. - Before: only one surived the edit. - After: both survived. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13130 Differential Revision: https://secure.phabricator.com/D19420
This commit is contained in:
parent
7cfac40a22
commit
fb4b9bc2fc
1 changed files with 7 additions and 3 deletions
|
@ -108,19 +108,23 @@ final class PhabricatorOwnersPackagePathsTransaction
|
||||||
// paths now.
|
// paths now.
|
||||||
|
|
||||||
$display_map = array();
|
$display_map = array();
|
||||||
|
$seen_map = array();
|
||||||
foreach ($new as $key => $spec) {
|
foreach ($new as $key => $spec) {
|
||||||
$display_path = $spec['path'];
|
$display_path = $spec['path'];
|
||||||
$raw_path = rtrim($display_path, '/').'/';
|
$raw_path = rtrim($display_path, '/').'/';
|
||||||
|
|
||||||
// If the user entered two paths which normalize to the same value
|
// If the user entered two paths in the same repository which normalize
|
||||||
// (like "src/main.c" and "src/main.c/"), discard the duplicates.
|
// to the same value (like "src/main.c" and "src/main.c/"), discard the
|
||||||
if (isset($display_map[$raw_path])) {
|
// duplicates.
|
||||||
|
$repository_phid = $spec['repositoryPHID'];
|
||||||
|
if (isset($seen_map[$repository_phid][$raw_path])) {
|
||||||
unset($new[$key]);
|
unset($new[$key]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$new[$key]['path'] = $raw_path;
|
$new[$key]['path'] = $raw_path;
|
||||||
$display_map[$raw_path] = $display_path;
|
$display_map[$raw_path] = $display_path;
|
||||||
|
$seen_map[$repository_phid][$raw_path] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$diffs = PhabricatorOwnersPath::getTransactionValueChanges($old, $new);
|
$diffs = PhabricatorOwnersPath::getTransactionValueChanges($old, $new);
|
||||||
|
|
Loading…
Reference in a new issue