Page MenuHomePhabricator

D7543.id17020.diff
No OneTemporary

D7543.id17020.diff

Index: src/applications/harbormaster/controller/HarbormasterBuildableEditController.php
===================================================================
--- src/applications/harbormaster/controller/HarbormasterBuildableEditController.php
+++ src/applications/harbormaster/controller/HarbormasterBuildableEditController.php
@@ -41,16 +41,21 @@
->withNames(array($v_name))
->executeOne();
- if ($object instanceof DifferentialRevision) {
- throw new Exception(
- "TODO: We need to assign PHIDs to diffs before this will work.");
- } else if ($object instanceof PhabricatorRepositoryCommit) {
- $buildable
- ->setBuildablePHID($object->getPHID())
- ->setContainerPHID($object->getRepository()->getPHID());
+ if ($this->buildableAlreadyExists($object->getPHID())) {
+ $e_name = pht('Already Exists');
+ $errors[] = pht('A buildable already exists for this object.');
} else {
- $e_name = pht('Invalid');
- $errors[] = pht('Enter the name of a revision or commit.');
+ if ($object instanceof DifferentialRevision) {
+ throw new Exception(
+ "TODO: We need to assign PHIDs to diffs before this will work.");
+ } else if ($object instanceof PhabricatorRepositoryCommit) {
+ $buildable
+ ->setBuildablePHID($object->getPHID())
+ ->setContainerPHID($object->getRepository()->getPHID());
+ } else {
+ $e_name = pht('Invalid');
+ $errors[] = pht('Enter the name of a revision or commit.');
+ }
}
} else {
$e_name = pht('Required');
@@ -141,4 +146,19 @@
));
}
+ private function buildableAlreadyExists($phid) {
+ $request = $this->getRequest();
+ $viewer = $request->getUser();
+
+ $buildable = id(new HarbormasterBuildableQuery())
+ ->setViewer($viewer)
+ ->withBuildablePHIDs(array($phid))
+ ->setLimit(1)
+ ->executeOne();
+ if ($buildable) {
+ return true;
+ }
+ return false;
+ }
+
}
Index: src/applications/harbormaster/storage/HarbormasterBuildable.php
===================================================================
--- src/applications/harbormaster/storage/HarbormasterBuildable.php
+++ src/applications/harbormaster/storage/HarbormasterBuildable.php
@@ -34,6 +34,7 @@
$buildable = id(new HarbormasterBuildableQuery())
->setViewer($actor)
->withBuildablePHIDs(array($buildable_object_phid))
+ ->setLimit(1)
->executeOne();
if ($buildable) {
return $buildable;

File Metadata

Mime Type
text/plain
Expires
Sat, Oct 19, 6:59 AM (4 w, 15 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6720140
Default Alt Text
D7543.id17020.diff (2 KB)

Event Timeline