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\.(?.*)\.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 @@ +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 @@ $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 @@ + $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 @@ + + 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 @@ + 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'), + ), + ); + } + +}