Changeset View
Changeset View
Standalone View
Standalone View
arcanist/workflow/ArcanistLandBotWorkflow.php
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | if ($this->getArgument('preview')) { | ||||
array_push($landArgs, '--preview'); | array_push($landArgs, '--preview'); | ||||
} else { | } else { | ||||
// Always hold the revision since we are not using 'arc land' to actually | // Always hold the revision since we are not using 'arc land' to actually | ||||
// land the change. | // land the change. | ||||
array_push($landArgs, '--hold'); | array_push($landArgs, '--hold'); | ||||
} | } | ||||
$revision = $this->getArgument('revision'); | $revision = $this->getArgument('revision'); | ||||
if ($revision) { | if (empty($revision)) { | ||||
// By default, queue the latest revision on the current branch | |||||
$revisions = $repositoryApi->loadWorkingCopyDifferentialRevisions( | |||||
$this->getConduit(), array()); | |||||
$revision = 'D' . end($revisions)['id']; | |||||
} | |||||
array_push($landArgs, '--revision'); | array_push($landArgs, '--revision'); | ||||
array_push($landArgs, $revision); | array_push($landArgs, $revision); | ||||
} | |||||
$branch = $this->getArgument('branch'); | $branch = $this->getArgument('branch'); | ||||
if (!empty($branch)) { | if (!empty($branch)) { | ||||
array_push($landArgs, $branch[0]); | array_push($landArgs, $branch[0]); | ||||
} | } | ||||
$landWorkflow = $this->buildChildWorkflow('land', $landArgs); | $landWorkflow = $this->buildChildWorkflow('land', $landArgs); | ||||
$landWorkflow->run(); | $landWorkflow->run(); | ||||
if ($this->getArgument('preview')) { | if ($this->getArgument('preview')) { | ||||
return 0; | return 0; | ||||
} | } | ||||
// Whether --revision was set or not, we need a formatted revision ID | // Checkout the branch you were on previously | ||||
$revision = 'D' . $landWorkflow->getRevisionDict()['id']; | $repositoryApi->execxLocal('checkout %s', $oldBranch); | ||||
if ($this->getArgument('hold')) { | if ($this->getArgument('hold')) { | ||||
echo phutil_console_format(pht( | echo phutil_console_format(pht( | ||||
'Revision %s will not be queued with the land bot.', $revision) . "\n"); | 'Revision %s will not be queued with the land bot.', $revision) . "\n"); | ||||
return 0; | return 0; | ||||
} | } | ||||
// Checkout the branch you were on previously | |||||
$repositoryApi->execxLocal('checkout %s', $oldBranch); | |||||
// Encrypt your Conduit token to securely pass it to the land bot | // Encrypt your Conduit token to securely pass it to the land bot | ||||
$workingCopy = $repositoryApi->getWorkingCopyIdentity(); | $workingCopy = $repositoryApi->getWorkingCopyIdentity(); | ||||
$pubkeyFile = $workingCopy->getProjectPath( | $pubkeyFile = $workingCopy->getProjectPath( | ||||
'./contrib/source-control-tools/land-patch.pub'); | './contrib/source-control-tools/land-patch.pub'); | ||||
$token = $this->getConduit()->getConduitToken(); | $token = $this->getConduit()->getConduitToken(); | ||||
list($encryptedToken) = execx( | list($encryptedToken) = execx( | ||||
'echo %s | gpg --armor -o- --encrypt --recipient-file %s', | 'echo %s | gpg --armor -o- --encrypt --recipient-file %s', | ||||
$token, $pubkeyFile); | $token, $pubkeyFile); | ||||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |