Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/editor/PhabricatorRepositoryEditor.php
Show First 20 Lines • Show All 242 Lines • ▼ Show 20 Lines | switch ($xaction->getTransactionType()) { | ||||
$object->setDetail( | $object->setDetail( | ||||
'automation.blueprintPHIDs', | 'automation.blueprintPHIDs', | ||||
$xaction->getNewValue()); | $xaction->getNewValue()); | ||||
return; | return; | ||||
case PhabricatorRepositoryTransaction::TYPE_CALLSIGN: | case PhabricatorRepositoryTransaction::TYPE_CALLSIGN: | ||||
$object->setCallsign($xaction->getNewValue()); | $object->setCallsign($xaction->getNewValue()); | ||||
return; | return; | ||||
case PhabricatorRepositoryTransaction::TYPE_ENCODING: | case PhabricatorRepositoryTransaction::TYPE_ENCODING: | ||||
// Make sure the encoding is valid by converting to UTF-8. This tests | $object->setDetail('encoding', $xaction->getNewValue()); | ||||
// that the user has mbstring installed, and also that they didn't type | |||||
// a garbage encoding name. Note that we're converting from UTF-8 to | |||||
// the target encoding, because mbstring is fine with converting from | |||||
// a nonsense encoding. | |||||
$encoding = $xaction->getNewValue(); | |||||
if (strlen($encoding)) { | |||||
try { | |||||
phutil_utf8_convert('.', $encoding, 'UTF-8'); | |||||
} catch (Exception $ex) { | |||||
throw new PhutilProxyException( | |||||
pht( | |||||
"Error setting repository encoding '%s': %s'", | |||||
$encoding, | |||||
$ex->getMessage()), | |||||
$ex); | |||||
} | |||||
} | |||||
$object->setDetail('encoding', $encoding); | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
protected function applyCustomExternalTransaction( | protected function applyCustomExternalTransaction( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | switch ($type) { | ||||
'Some of the selected automation blueprints are invalid '. | 'Some of the selected automation blueprints are invalid '. | ||||
'or restricted: %s.', | 'or restricted: %s.', | ||||
implode(', ', $invalid)), | implode(', ', $invalid)), | ||||
$xaction); | $xaction); | ||||
} | } | ||||
} | } | ||||
break; | break; | ||||
case PhabricatorRepositoryTransaction::TYPE_VCS: | |||||
$vcs_map = PhabricatorRepositoryType::getAllRepositoryTypes(); | |||||
$current_vcs = $object->getVersionControlSystem(); | |||||
if (!$this->getIsNewObject()) { | |||||
foreach ($xactions as $xaction) { | |||||
if ($xaction->getNewValue() == $current_vcs) { | |||||
continue; | |||||
} | |||||
$errors[] = new PhabricatorApplicationTransactionValidationError( | |||||
$type, | |||||
pht('Immutable'), | |||||
pht( | |||||
'You can not change the version control system an existing '. | |||||
'repository uses. It can only be set when a repository is '. | |||||
'first created.'), | |||||
$xaction); | |||||
} | |||||
} else { | |||||
$value = $object->getVersionControlSystem(); | |||||
foreach ($xactions as $xaction) { | |||||
$value = $xaction->getNewValue(); | |||||
if (empty($vcs_map[$value])) { | |||||
$errors[] = new PhabricatorApplicationTransactionValidationError( | |||||
$type, | |||||
pht('Invalid'), | |||||
pht( | |||||
'Specified version control system must be a VCS '. | |||||
'recognized by Phabricator: %s.', | |||||
implode(', ', array_keys($vcs_map))), | |||||
$xaction); | |||||
} | |||||
} | |||||
if (!strlen($value)) { | |||||
$error = new PhabricatorApplicationTransactionValidationError( | |||||
$type, | |||||
pht('Required'), | |||||
pht( | |||||
'When creating a repository, you must specify a valid '. | |||||
'underlying version control system: %s.', | |||||
implode(', ', array_keys($vcs_map))), | |||||
nonempty(last($xactions), null)); | |||||
$error->setIsMissingFieldError(true); | |||||
$errors[] = $error; | |||||
} | |||||
} | |||||
break; | |||||
case PhabricatorRepositoryTransaction::TYPE_NAME: | |||||
$missing = $this->validateIsEmptyTextField( | |||||
$object->getName(), | |||||
$xactions); | |||||
if ($missing) { | |||||
$error = new PhabricatorApplicationTransactionValidationError( | |||||
$type, | |||||
pht('Required'), | |||||
pht('Repository name is required.'), | |||||
nonempty(last($xactions), null)); | |||||
$error->setIsMissingFieldError(true); | |||||
$errors[] = $error; | |||||
} | |||||
break; | |||||
case PhabricatorRepositoryTransaction::TYPE_ACTIVATE: | |||||
$status_map = PhabricatorRepository::getStatusMap(); | |||||
foreach ($xactions as $xaction) { | |||||
$status = $xaction->getNewValue(); | |||||
if (empty($status_map[$status])) { | |||||
$errors[] = new PhabricatorApplicationTransactionValidationError( | |||||
$type, | |||||
pht('Invalid'), | |||||
pht( | |||||
'Repository status "%s" is not valid.', | |||||
$status), | |||||
$xaction); | |||||
} | |||||
} | |||||
break; | |||||
case PhabricatorRepositoryTransaction::TYPE_ENCODING: | |||||
foreach ($xactions as $xaction) { | |||||
// Make sure the encoding is valid by converting to UTF-8. This tests | |||||
// that the user has mbstring installed, and also that they didn't | |||||
// type a garbage encoding name. Note that we're converting from | |||||
// UTF-8 to the target encoding, because mbstring is fine with | |||||
// converting from a nonsense encoding. | |||||
$encoding = $xaction->getNewValue(); | |||||
if (!strlen($encoding)) { | |||||
continue; | |||||
} | |||||
try { | |||||
phutil_utf8_convert('.', $encoding, 'UTF-8'); | |||||
} catch (Exception $ex) { | |||||
$errors[] = new PhabricatorApplicationTransactionValidationError( | |||||
$type, | |||||
pht('Invalid'), | |||||
pht( | |||||
'Repository encoding "%s" is not valid: %s', | |||||
$encoding, | |||||
$ex->getMessage()), | |||||
$xaction); | |||||
} | |||||
} | |||||
break; | |||||
case PhabricatorRepositoryTransaction::TYPE_SLUG: | case PhabricatorRepositoryTransaction::TYPE_SLUG: | ||||
foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
$old = $xaction->getOldValue(); | $old = $xaction->getOldValue(); | ||||
$new = $xaction->getNewValue(); | $new = $xaction->getNewValue(); | ||||
if (!strlen($new)) { | if (!strlen($new)) { | ||||
continue; | continue; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 125 Lines • Show Last 20 Lines |