1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-04 12:42:43 +01:00
phorge-phorge/src/applications/drydock/operation/DrydockTestRepositoryOperation.php
epriestley a763f9510e Add some Drydock documentation plus "Test Configuration" for repository automation
Summary:
Ref T182. Ref T9252.

  - Adds a "Test" repository operation that just runs `git status` to see if things work.
  - Adds a button for it in Edit Repository.
  - Shows operation status on the operation detail view to make this workflow work a little better.
  - Adds a lot of words. Words words words words.

Test Plan:
  - Tested repository operation.
  - Read words.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T182, T9252

Differential Revision: https://secure.phabricator.com/D14349
2015-10-27 18:04:02 +00:00

53 lines
1.6 KiB
PHP

<?php
final class DrydockTestRepositoryOperation
extends DrydockRepositoryOperationType {
const OPCONST = 'test';
public function getOperationDescription(
DrydockRepositoryOperation $operation,
PhabricatorUser $viewer) {
return pht('Test Configuration');
}
public function getOperationCurrentStatus(
DrydockRepositoryOperation $operation,
PhabricatorUser $viewer) {
$repository = $operation->getRepository();
switch ($operation->getOperationState()) {
case DrydockRepositoryOperation::STATE_WAIT:
return pht(
'Waiting to test configuration for %s...',
$repository->getMonogram());
case DrydockRepositoryOperation::STATE_WORK:
return pht(
'Testing configuration for %s. This may take a moment if Drydock '.
'has to clone the repository for the first time.',
$repository->getMonogram());
case DrydockRepositoryOperation::STATE_DONE:
return pht(
'Success! Automation is configured properly and Drydock can '.
'operate on %s.',
$repository->getMonogram());
}
}
public function applyOperation(
DrydockRepositoryOperation $operation,
DrydockInterface $interface) {
$repository = $operation->getRepository();
if ($repository->isGit()) {
$interface->execx('git status');
} else if ($repository->isHg()) {
$interface->execx('hg status');
} else if ($repository->isSVN()) {
$interface->execx('svn status');
} else {
throw new PhutilMethodNotImplementedException();
}
}
}