Differential D15420 Diff 37180 src/applications/drydock/operation/DrydockLandRepositoryOperation.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/drydock/operation/DrydockLandRepositoryOperation.php
<?php | <?php | ||||
final class DrydockLandRepositoryOperation | final class DrydockLandRepositoryOperation | ||||
extends DrydockRepositoryOperationType { | extends DrydockRepositoryOperationType { | ||||
const OPCONST = 'land'; | const OPCONST = 'land'; | ||||
const PHASE_PUSH = 'push'; | |||||
const PHASE_PUSH = 'op.land.push'; | |||||
const PHASE_COMMIT = 'op.land.commit'; | |||||
public function getOperationDescription( | public function getOperationDescription( | ||||
DrydockRepositoryOperation $operation, | DrydockRepositoryOperation $operation, | ||||
PhabricatorUser $viewer) { | PhabricatorUser $viewer) { | ||||
return pht('Land Revision'); | return pht('Land Revision'); | ||||
} | } | ||||
public function getOperationCurrentStatus( | public function getOperationCurrentStatus( | ||||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | public function applyOperation( | ||||
// size of a command. | // size of a command. | ||||
$future = $interface->getExecFuture( | $future = $interface->getExecFuture( | ||||
'git -c user.name=%s -c user.email=%s commit --author %s -F - --', | 'git -c user.name=%s -c user.email=%s commit --author %s -F - --', | ||||
$committer_info['name'], | $committer_info['name'], | ||||
$committer_info['email'], | $committer_info['email'], | ||||
"{$author_name} <{$author_email}>"); | "{$author_name} <{$author_email}>"); | ||||
$future | $future->write($commit_message); | ||||
->write($commit_message) | |||||
->resolvex(); | try { | ||||
$future->resolvex(); | |||||
} catch (CommandException $ex) { | |||||
$display_command = csprintf('git commit'); | |||||
// TODO: One reason this can fail is if the changes have already been | |||||
// merged. We could try to detect that. | |||||
$error = DrydockCommandError::newFromCommandException($ex) | |||||
->setPhase(self::PHASE_COMMIT) | |||||
->setDisplayCommand($display_command); | |||||
$operation->setCommandError($error->toDictionary()); | |||||
throw $ex; | |||||
} | |||||
try { | try { | ||||
$interface->execx( | $interface->execx( | ||||
'git push origin -- %s:%s', | 'git push origin -- %s:%s', | ||||
'HEAD', | 'HEAD', | ||||
$push_dst); | $push_dst); | ||||
} catch (CommandException $ex) { | } catch (CommandException $ex) { | ||||
$show_command = csprintf( | $display_command = csprintf( | ||||
'git push origin -- %s:%s', | 'git push origin %R:%R', | ||||
'HEAD', | 'HEAD', | ||||
$push_dst); | $push_dst); | ||||
$error = DrydockCommandError::newFromCommandException( | |||||
self::PHASE_PUSH, | $error = DrydockCommandError::newFromCommandException($ex) | ||||
$show_command, | ->setPhase(self::PHASE_PUSH) | ||||
$ex); | ->setDisplayCommand($display_command); | ||||
$operation->setCommandError($error); | |||||
$operation->setCommandError($error->toDictionary()); | |||||
throw $ex; | throw $ex; | ||||
} | } | ||||
} | } | ||||
private function getCommitterInfo(DrydockRepositoryOperation $operation) { | private function getCommitterInfo(DrydockRepositoryOperation $operation) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$committer_name = null; | $committer_name = null; | ||||
▲ Show 20 Lines • Show All 172 Lines • Show Last 20 Lines |