From 0f07c07b3bc3f412e591128780e8e969b7382897 Mon Sep 17 00:00:00 2001 From: Valerio Bozzolan Date: Sat, 22 Jul 2023 13:52:13 +0200 Subject: [PATCH] Attach Diff to Revision: fix Repository asked twice Summary: If you manually upload a Diff (patch) from the Differential web interface you can select the Repository. We fix the default value of the Repository field during creation mode, guessing the repo from the potentially already-available diff. Closes T15537 Test Plan: - Create a cute Differential Revision from web - Pick a Repository > Continue - Create a new Revision > Continue At this point you should still have that repository instead of nothing. Reviewers: O1 Blessed Committers, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: avivey, speck, tobiaswiese, Matthew, Cigaryno Maniphest Tasks: T15537 Differential Revision: https://we.phorge.it/D25338 --- .../editor/DifferentialRevisionEditEngine.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/applications/differential/editor/DifferentialRevisionEditEngine.php b/src/applications/differential/editor/DifferentialRevisionEditEngine.php index 995179a864..bd1cee7c26 100644 --- a/src/applications/differential/editor/DifferentialRevisionEditEngine.php +++ b/src/applications/differential/editor/DifferentialRevisionEditEngine.php @@ -189,7 +189,7 @@ final class DifferentialRevisionEditEngine // Don't show the "Author" field when creating a revision using the web // workflow, since it adds more noise than signal to this workflow. - if ($this->getIsCreate()) { + if ($is_create) { $author_field->setIsHidden(true); } @@ -239,6 +239,12 @@ final class DifferentialRevisionEditEngine ->setConduitTypeDescription(pht('New reviewers.')) ->setValue($object->getReviewerPHIDsForEdit()); + // Prefill Repository for example when coming from "Attach To". + $repository_phid = $object->getRepositoryPHID(); + if ($is_create && !$repository_phid && $diff) { + $repository_phid = $diff->getRepositoryPHID(); + } + $fields[] = id(new PhabricatorDatasourceEditField()) ->setKey('repositoryPHID') ->setLabel(pht('Repository')) @@ -248,7 +254,7 @@ final class DifferentialRevisionEditEngine ->setDescription(pht('The repository the revision belongs to.')) ->setConduitDescription(pht('Change the repository for this revision.')) ->setConduitTypeDescription(pht('New repository.')) - ->setSingleValue($object->getRepositoryPHID()); + ->setSingleValue($repository_phid); // This is a little flimsy, but allows "Maniphest Tasks: ..." to continue // working properly in commit messages until we fully sort out T5873.