1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 16:22:43 +01:00

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
This commit is contained in:
Valerio Bozzolan 2023-07-22 13:52:13 +02:00
parent 0dfc84e2ab
commit 0f07c07b3b

View file

@ -189,7 +189,7 @@ final class DifferentialRevisionEditEngine
// Don't show the "Author" field when creating a revision using the web // Don't show the "Author" field when creating a revision using the web
// workflow, since it adds more noise than signal to this workflow. // workflow, since it adds more noise than signal to this workflow.
if ($this->getIsCreate()) { if ($is_create) {
$author_field->setIsHidden(true); $author_field->setIsHidden(true);
} }
@ -239,6 +239,12 @@ final class DifferentialRevisionEditEngine
->setConduitTypeDescription(pht('New reviewers.')) ->setConduitTypeDescription(pht('New reviewers.'))
->setValue($object->getReviewerPHIDsForEdit()); ->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()) $fields[] = id(new PhabricatorDatasourceEditField())
->setKey('repositoryPHID') ->setKey('repositoryPHID')
->setLabel(pht('Repository')) ->setLabel(pht('Repository'))
@ -248,7 +254,7 @@ final class DifferentialRevisionEditEngine
->setDescription(pht('The repository the revision belongs to.')) ->setDescription(pht('The repository the revision belongs to.'))
->setConduitDescription(pht('Change the repository for this revision.')) ->setConduitDescription(pht('Change the repository for this revision.'))
->setConduitTypeDescription(pht('New repository.')) ->setConduitTypeDescription(pht('New repository.'))
->setSingleValue($object->getRepositoryPHID()); ->setSingleValue($repository_phid);
// This is a little flimsy, but allows "Maniphest Tasks: ..." to continue // This is a little flimsy, but allows "Maniphest Tasks: ..." to continue
// working properly in commit messages until we fully sort out T5873. // working properly in commit messages until we fully sort out T5873.