Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15410147
D13413.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
13 KB
Referenced Files
None
Subscribers
None
D13413.diff
View Options
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -902,10 +902,14 @@
'HarbormasterCommandBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterCommandBuildStepImplementation.php',
'HarbormasterConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterConduitAPIMethod.php',
'HarbormasterController' => 'applications/harbormaster/controller/HarbormasterController.php',
+ 'HarbormasterCustomFieldRepository' => 'applications/harbormaster/customfield/HarbormasterCustomFieldRepository.php',
'HarbormasterDAO' => 'applications/harbormaster/storage/HarbormasterDAO.php',
'HarbormasterHTTPRequestBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterHTTPRequestBuildStepImplementation.php',
'HarbormasterLeaseHostBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterLeaseHostBuildStepImplementation.php',
'HarbormasterLeaseWorkingCopyBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php',
+ 'HarbormasterLeaseWorkingCopyFromBuildableBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromBuildableBuildStepImplementation.php',
+ 'HarbormasterLeaseWorkingCopyFromRepositoryBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromRepositoryBuildStepImplementation.php',
+ 'HarbormasterLeaseWorkingCopyFromURLBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromURLBuildStepImplementation.php',
'HarbormasterLintMessagesController' => 'applications/harbormaster/controller/HarbormasterLintMessagesController.php',
'HarbormasterLintPropertyView' => 'applications/harbormaster/view/HarbormasterLintPropertyView.php',
'HarbormasterManagePlansCapability' => 'applications/harbormaster/capability/HarbormasterManagePlansCapability.php',
@@ -4407,10 +4411,14 @@
'HarbormasterCommandBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
'HarbormasterConduitAPIMethod' => 'ConduitAPIMethod',
'HarbormasterController' => 'PhabricatorController',
+ 'HarbormasterCustomFieldRepository' => 'PhabricatorStandardCustomFieldPHIDs',
'HarbormasterDAO' => 'PhabricatorLiskDAO',
'HarbormasterHTTPRequestBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
'HarbormasterLeaseHostBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
'HarbormasterLeaseWorkingCopyBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
+ 'HarbormasterLeaseWorkingCopyFromBuildableBuildStepImplementation' => 'HarbormasterLeaseWorkingCopyBuildStepImplementation',
+ 'HarbormasterLeaseWorkingCopyFromRepositoryBuildStepImplementation' => 'HarbormasterLeaseWorkingCopyBuildStepImplementation',
+ 'HarbormasterLeaseWorkingCopyFromURLBuildStepImplementation' => 'HarbormasterLeaseWorkingCopyBuildStepImplementation',
'HarbormasterLintMessagesController' => 'HarbormasterController',
'HarbormasterLintPropertyView' => 'AphrontView',
'HarbormasterManagePlansCapability' => 'PhabricatorPolicyCapability',
Index: src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php
===================================================================
--- src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php
+++ src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php
@@ -23,11 +23,14 @@
}
$url = $lease->getAttribute('url');
+ $ref = $lease->getAttribute('ref');
$buildable_phid = $lease->getAttribute('buildablePHID');
+ $repository_phid = $lease->getAttribute('repositoryPHID');
if ($url) {
$lease->setAttribute('resolved.target', 'url');
$lease->setAttribute('resolved.repositoryURL', $url);
+ $lease->setAttribute('resolved.repositoryReference', $ref);
$lease->save();
$this->log(pht(
@@ -35,6 +38,20 @@
$this->log(pht(
'Resolved working copy repository URL as "%s"',
$lease->getAttribute('resolved.repositoryURL')));
+ } else if ($repository_phid) {
+ $lease->setAttribute('resolved.target', 'commit');
+ $lease->setAttribute('resolved.repositoryPHID', $repository_phid);
+ $lease->setAttribute('resolved.commitIdentifier', $ref);
+ $lease->save();
+
+ $this->log(pht(
+ 'Resolved working copy target as "commit"'));
+ $this->log(pht(
+ 'Resolved working copy commit identifier as "%s"',
+ $lease->getAttribute('resolved.commitIdentifier')));
+ $this->log(pht(
+ 'Resolved working copy repository PHID as "%s"',
+ $lease->getAttribute('resolved.repositoryPHID')));
} else if ($buildable_phid) {
$buildable = id(new HarbormasterBuildableQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
@@ -474,7 +491,18 @@
$lease->getAttribute('resolved.commitIdentifier'));
$this->log(pht('Checked out commit'));
} else if ($lease->getAttribute('resolved.target') === 'url') {
- // Leave as default; we use the working copy for cloning only.
+ if ($lease->getAttribute('resolved.repositoryReference') !== null) {
+ $this->log(pht(
+ 'Checking out target reference "%s"',
+ $lease->getAttribute('resolved.repositoryReference')));
+ $cmd->execx(
+ 'git checkout -f %s',
+ $lease->getAttribute('resolved.repositoryReference'));
+ $this->log(pht('Checked out reference'));
+ } else {
+ $this->log(pht(
+ 'No target reference provided, leaving working directory as-is'));
+ }
} else {
throw new Exception(pht(
'Target type %s not yet supported.',
@@ -513,13 +541,8 @@
'Discovering initialized submodules in %s',
$working_directory_path));
list($stdout, $stderr) = $working_directory_cmd->execx('git config --local --list');
+ $matches = null;
preg_match_all('/submodule\.(?<name>.*)\.url=(?<url>.*)/', $stdout, $matches);
- $this->log(pht(
- 'Standard output is %s',
- $stdout));
- $this->log(pht(
- 'Submodule array is %s',
- print_r($matches, true)));
$submodules = array();
for ($i = 0; $i < count($matches['name']); $i++) {
$name = $matches['name'][$i];
Index: src/applications/harbormaster/customfield/HarbormasterCustomFieldRepository.php
===================================================================
--- /dev/null
+++ src/applications/harbormaster/customfield/HarbormasterCustomFieldRepository.php
@@ -0,0 +1,43 @@
+<?php
+
+final class HarbormasterCustomFieldRepository
+ extends PhabricatorStandardCustomFieldPHIDs {
+
+ public function getFieldType() {
+ return 'repository';
+ }
+
+ public function renderEditControl(array $handles) {
+ $value = $this->getFieldValue();
+
+ $control = id(new AphrontFormTokenizerControl())
+ ->setUser($this->getViewer())
+ ->setLabel($this->getFieldName())
+ ->setName($this->getFieldKey())
+ ->setDatasource(new DiffusionRepositoryDatasource())
+ ->setCaption($this->getCaption())
+ ->setValue(nonempty($value, array()));
+
+ $limit = $this->getFieldConfigValue('limit');
+ if ($limit) {
+ $control->setLimit($limit);
+ }
+
+ return $control;
+ }
+
+ public function appendToApplicationSearchForm(
+ PhabricatorApplicationSearchEngine $engine,
+ AphrontFormView $form,
+ $value) {
+
+ $control = id(new AphrontFormTokenizerControl())
+ ->setLabel($this->getFieldName())
+ ->setName($this->getFieldKey())
+ ->setDatasource(new DiffusionRepositoryDatasource())
+ ->setValue(nonempty($value, array()));
+
+ $form->appendControl($control);
+ }
+
+}
Index: src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php
===================================================================
--- src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php
+++ src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php
@@ -1,17 +1,12 @@
<?php
-final class HarbormasterLeaseWorkingCopyBuildStepImplementation
+abstract class HarbormasterLeaseWorkingCopyBuildStepImplementation
extends HarbormasterBuildStepImplementation {
- public function getName() {
- return pht('Lease Working Copy');
- }
-
- public function getGenericDescription() {
- return pht(
- 'Obtain a lease on a Drydock working copy of the '.
- 'current buildable for performing builds.');
- }
+ abstract protected function getLeaseAttributes(
+ HarbormasterBuild $build,
+ HarbormasterBuildTarget $build_target,
+ array $settings);
public function execute(
HarbormasterBuild $build,
@@ -29,7 +24,8 @@
array(
'platform' => $settings['platform'],
'buildablePHID' => $build->getBuildablePHID(),
- ) + $custom_attributes)
+ ) + $this->getLeaseAttributes($build, $build_target, $settings)
+ + $custom_attributes)
->queueForActivation();
// Create the associated artifact.
@@ -58,6 +54,8 @@
);
}
+ abstract protected function getLeaseFieldSpecifications();
+
public function getFieldSpecifications() {
return array(
'name' => array(
@@ -70,6 +68,7 @@
'type' => 'text',
'required' => true,
),
+ ) + $this->getLeaseFieldSpecifications() + array(
'attributes' => array(
'name' => pht('Required Attributes'),
'type' => 'textarea',
Index: src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromBuildableBuildStepImplementation.php
===================================================================
--- /dev/null
+++ src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromBuildableBuildStepImplementation.php
@@ -0,0 +1,30 @@
+<?php
+
+final class HarbormasterLeaseWorkingCopyFromBuildableBuildStepImplementation
+ extends HarbormasterLeaseWorkingCopyBuildStepImplementation {
+
+ public function getName() {
+ return pht('Lease Working Copy from Buildable');
+ }
+
+ public function getGenericDescription() {
+ return pht(
+ 'Obtain a lease on a Drydock working copy of the '.
+ 'current buildable for performing builds.');
+ }
+
+ protected function getLeaseAttributes(
+ HarbormasterBuild $build,
+ HarbormasterBuildTarget $build_target,
+ array $settings) {
+
+ return array(
+ 'buildablePHID' => $build->getBuildablePHID(),
+ );
+ }
+
+ protected function getLeaseFieldSpecifications() {
+ return array();
+ }
+
+}
Index: src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromRepositoryBuildStepImplementation.php
===================================================================
--- /dev/null
+++ src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromRepositoryBuildStepImplementation.php
@@ -0,0 +1,44 @@
+<?php
+
+final class HarbormasterLeaseWorkingCopyFromRepositoryBuildStepImplementation
+ extends HarbormasterLeaseWorkingCopyBuildStepImplementation {
+
+ public function getName() {
+ return pht('Lease Working Copy from Repository');
+ }
+
+ public function getGenericDescription() {
+ return pht(
+ 'Obtain a lease on a Drydock working copy of a '.
+ 'repository hosted on Phabricator.');
+ }
+
+ protected function getLeaseAttributes(
+ HarbormasterBuild $build,
+ HarbormasterBuildTarget $build_target,
+ array $settings) {
+
+ return array(
+ 'repositoryPHID' =>
+ head(phutil_json_decode(idx($settings, 'repositoryPHID'))),
+ 'ref' => idx($settings, 'ref'),
+ );
+ }
+
+ protected function getLeaseFieldSpecifications() {
+ return array(
+ 'repositoryPHID' => array(
+ 'name' => pht('Repository'),
+ 'type' => 'repository',
+ 'required' => true,
+ ),
+ 'ref' => array(
+ 'name' => pht('Reference to Checkout'),
+ 'type' => 'text',
+ 'required' => true,
+ 'caption' => pht('e.g. master'),
+ ),
+ );
+ }
+
+}
Index: src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromURLBuildStepImplementation.php
===================================================================
--- /dev/null
+++ src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyFromURLBuildStepImplementation.php
@@ -0,0 +1,43 @@
+<?php
+
+final class HarbormasterLeaseWorkingCopyFromURLBuildStepImplementation
+ extends HarbormasterLeaseWorkingCopyBuildStepImplementation {
+
+ public function getName() {
+ return pht('Lease Working Copy from URL');
+ }
+
+ public function getGenericDescription() {
+ return pht(
+ 'Obtain a lease on a Drydock working copy of a '.
+ 'repository at a given URL.');
+ }
+
+ protected function getLeaseAttributes(
+ HarbormasterBuild $build,
+ HarbormasterBuildTarget $build_target,
+ array $settings) {
+
+ return array(
+ 'url' => idx($settings, 'url'),
+ 'ref' => idx($settings, 'ref'),
+ );
+ }
+
+ protected function getLeaseFieldSpecifications() {
+ return array(
+ 'url' => array(
+ 'name' => pht('Repository URL'),
+ 'type' => 'text',
+ 'required' => true,
+ ),
+ 'ref' => array(
+ 'name' => pht('Reference to Checkout'),
+ 'type' => 'text',
+ 'required' => true,
+ 'caption' => pht('e.g. master'),
+ ),
+ );
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 20, 6:50 AM (3 d, 7 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7381782
Default Alt Text
D13413.diff (13 KB)
Attached To
Mode
D13413: Implement leasing working copies based on URLs and repositories
Attached
Detach File
Event Timeline
Log In to Comment