diff --git a/src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php b/src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php --- a/src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php +++ b/src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php @@ -236,6 +236,7 @@ $host_lease = id(new DrydockLease()) ->setResourceType('host') + ->setOwnerPHID($lease->getPHID()) ->setAttributes( array( 'platform' => $lease->getAttribute('platform'), @@ -243,9 +244,11 @@ ->waitUntilActive(); $lease->setAttribute('host.lease', $host_lease->getID()); + $lease->setAttribute('host.lease.phid', $host_lease->getPHID()); list($cache_lease, $source_url) = $this->tryAcquireWorkingCopyCache( $host_lease->getResource(), + $lease, $lease->getAttribute('resolved.repositoryURL')); $cmd = $this->getCommandInterfaceForLease($lease); @@ -306,6 +309,7 @@ $this->initializeGitSubmodules( $host_lease, + $lease, $host_lease->getAttribute('path')); } @@ -321,13 +325,16 @@ private function tryAcquireWorkingCopyCache( DrydockResource $host_resource, + DrydockLease $owner_lease, $url) { $cache_lease = id(new DrydockLease()) ->setResourceType('working-copy-cache') + ->setOwnerPHID($owner_lease->getPHID()) ->setAttributes( array( 'host.resource' => $host_resource->getID(), + 'host.resource.phid' => $host_resource->getPHID(), 'url' => $url, )) ->queueForActivation(); @@ -392,6 +399,7 @@ private function initializeGitSubmodules( DrydockLease $target_lease, + DrydockLease $owner_lease, $target_path = null) { $cmd = $this->getCommandInterfaceForLease($target_lease); @@ -431,6 +439,7 @@ foreach ($submodules as $name => $url) { list($cache_lease, $source_url) = $this->tryAcquireWorkingCopyCache( $target_lease->getResource(), + $owner_lease, $url); $this->log(pht( @@ -451,6 +460,7 @@ $this->initializeGitSubmodules( $target_lease, + $owner_lease, $target_path.'/'.$name); $this->log(pht( diff --git a/src/applications/drydock/blueprint/DrydockWorkingCopyCacheBlueprintImplementation.php b/src/applications/drydock/blueprint/DrydockWorkingCopyCacheBlueprintImplementation.php --- a/src/applications/drydock/blueprint/DrydockWorkingCopyCacheBlueprintImplementation.php +++ b/src/applications/drydock/blueprint/DrydockWorkingCopyCacheBlueprintImplementation.php @@ -95,7 +95,9 @@ $host_lease->getID())); $resource + ->setAttribute('host.resource.phid', $host_lease->getResourcePHID()) ->setAttribute('host.lease', $host_lease->getID()) + ->setAttribute('host.lease.phid', $host_lease->getPHID()) ->save(); $this->log(pht( diff --git a/src/applications/drydock/controller/DrydockLeaseViewController.php b/src/applications/drydock/controller/DrydockLeaseViewController.php --- a/src/applications/drydock/controller/DrydockLeaseViewController.php +++ b/src/applications/drydock/controller/DrydockLeaseViewController.php @@ -147,9 +147,32 @@ $attributes = $lease->getAttributes(); if ($attributes) { + $phids = array(); + foreach ($attributes as $key => $value) { + if (strlen($key) > 5 && substr($key, -5) === '.phid' || + strlen($key) > 4 && substr($key, -4) === 'PHID') { + $phids[] = $value; + } + } + + $handles = id(new PhabricatorHandleQuery()) + ->setViewer($this->getRequest()->getViewer()) + ->withPHIDs($phids) + ->execute(); + $view->addSectionHeader(pht('Attributes')); foreach ($attributes as $key => $value) { - $view->addProperty($key, $value); + if (strlen($key) > 5 && substr($key, -5) === '.phid' || + strlen($key) > 4 && substr($key, -4) === 'PHID') { + $handle = idx($handles, $value); + if ($handle !== null) { + $view->addProperty($key, $handle->renderLink()); + } else { + $view->addProperty($key, phutil_tag('em', array(), $value)); + } + } else { + $view->addProperty($key, $value); + } } } diff --git a/src/applications/drydock/controller/DrydockResourceViewController.php b/src/applications/drydock/controller/DrydockResourceViewController.php --- a/src/applications/drydock/controller/DrydockResourceViewController.php +++ b/src/applications/drydock/controller/DrydockResourceViewController.php @@ -122,9 +122,32 @@ $attributes = $resource->getAttributes(); if ($attributes) { + $phids = array(); + foreach ($attributes as $key => $value) { + if (strlen($key) > 5 && substr($key, -5) === '.phid' || + strlen($key) > 4 && substr($key, -4) === 'PHID') { + $phids[] = $value; + } + } + + $handles = id(new PhabricatorHandleQuery()) + ->setViewer($this->getRequest()->getViewer()) + ->withPHIDs($phids) + ->execute(); + $view->addSectionHeader(pht('Attributes')); foreach ($attributes as $key => $value) { - $view->addProperty($key, $value); + if (strlen($key) > 5 && substr($key, -5) === '.phid' || + strlen($key) > 4 && substr($key, -4) === 'PHID') { + $handle = idx($handles, $value); + if ($handle !== null) { + $view->addProperty($key, $handle->renderLink()); + } else { + $view->addProperty($key, phutil_tag('em', array(), $value)); + } + } else { + $view->addProperty($key, $value); + } } } diff --git a/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php b/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php --- a/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php +++ b/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php @@ -20,6 +20,7 @@ // Create the lease. $lease = id(new DrydockLease()) ->setResourceType('working-copy') + ->setOwnerPHID($build_target->getPHID()) ->setAttributes( array( 'platform' => $settings['platform'],