Document API management of repositories and fix some issues with creating URIs via API

Summary:
Ref T10923. Primarily documents the process for creating repositories via the API.

Also fixes a couple of issues with `repositoryPHID` not being set yet when creating URIs via the API.

Test Plan:
  - Followed all documented steps to create a new repository.
  - Created and edited some new URIs from the web workflow, too.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10923

Differential Revision: https://secure.phabricator.com/D15870
This commit is contained in:
epriestley
2016-05-09 13:52:23 -07:00
parent 34e85aaeb8
commit f191f66f34
3 changed files with 197 additions and 1 deletions

View File

@@ -3,6 +3,9 @@
final class DiffusionURIEditor
extends PhabricatorApplicationTransactionEditor {
private $repository;
private $repositoryPHID;
public function getEditorApplicationClass() {
return 'PhabricatorDiffusionApplication';
}
@@ -115,6 +118,7 @@ final class DiffusionURIEditor
break;
case PhabricatorRepositoryURITransaction::TYPE_REPOSITORY:
$object->setRepositoryPHID($xaction->getNewValue());
$object->attachRepository($this->repository);
break;
case PhabricatorRepositoryURITransaction::TYPE_CREDENTIAL:
$object->setCredentialPHID($xaction->getNewValue());
@@ -151,6 +155,9 @@ final class DiffusionURIEditor
switch ($type) {
case PhabricatorRepositoryURITransaction::TYPE_REPOSITORY:
// Save this, since we need it to validate TYPE_IO transactions.
$this->repositoryPHID = $object->getRepositoryPHID();
$missing = $this->validateIsEmptyTextField(
$object->getRepositoryPHID(),
$xactions);
@@ -208,6 +215,9 @@ final class DiffusionURIEditor
$xaction);
continue;
}
$this->repository = $repository;
$this->repositoryPHID = $repository_phid;
}
break;
case PhabricatorRepositoryURITransaction::TYPE_CREDENTIAL:
@@ -315,7 +325,7 @@ final class DiffusionURIEditor
if ($no_observers || $no_readwrite) {
$repository = id(new PhabricatorRepositoryQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withPHIDs(array($object->getRepositoryPHID()))
->withPHIDs(array($this->repositoryPHID))
->needURIs(true)
->executeOne();
$uris = $repository->getURIs();