mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42: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.
|
||||
|
||||
$display_map = array();
|
||||
$seen_map = array();
|
||||
foreach ($new as $key => $spec) {
|
||||
$display_path = $spec['path'];
|
||||
$raw_path = rtrim($display_path, '/').'/';
|
||||
|
||||
// If the user entered two paths which normalize to the same value
|
||||
// (like "src/main.c" and "src/main.c/"), discard the duplicates.
|
||||
if (isset($display_map[$raw_path])) {
|
||||
// If the user entered two paths in the same repository which normalize
|
||||
// to the same value (like "src/main.c" and "src/main.c/"), discard the
|
||||
// duplicates.
|
||||
$repository_phid = $spec['repositoryPHID'];
|
||||
if (isset($seen_map[$repository_phid][$raw_path])) {
|
||||
unset($new[$key]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$new[$key]['path'] = $raw_path;
|
||||
$display_map[$raw_path] = $display_path;
|
||||
$seen_map[$repository_phid][$raw_path] = true;
|
||||
}
|
||||
|
||||
$diffs = PhabricatorOwnersPath::getTransactionValueChanges($old, $new);
|
||||
|
|
Loading…
Reference in a new issue