3 final class PhabricatorRepositorySlugTransaction
4 extends PhabricatorRepositoryTransactionType
{
6 const TRANSACTIONTYPE
= 'repo:slug';
8 public function generateOldValue($object) {
9 return $object->getRepositorySlug();
12 public function generateNewValue($object, $value) {
20 public function applyInternalEffects($object, $value) {
21 $object->setRepositorySlug($value);
24 public function getTitle() {
25 $old = $this->getOldValue();
26 $new = $this->getNewValue();
28 if (strlen($old) && !strlen($new)) {
30 '%s removed the short name of this repository.',
31 $this->renderAuthor());
32 } else if (strlen($new) && !strlen($old)) {
34 '%s set the short name of this repository to %s.',
35 $this->renderAuthor(),
36 $this->renderNewValue());
39 '%s changed the short name of this repository from %s to %s.',
40 $this->renderAuthor(),
41 $this->renderOldValue(),
42 $this->renderNewValue());
46 public function validateTransactions($object, array $xactions) {
49 foreach ($xactions as $xaction) {
50 $old = $xaction->getOldValue();
51 $new = $xaction->getNewValue();
62 PhabricatorRepository
::assertValidRepositorySlug($new);
63 } catch (Exception
$ex) {
64 $errors[] = $this->newInvalidError(
70 $other = id(new PhabricatorRepositoryQuery())
71 ->setViewer(PhabricatorUser
::getOmnipotentUser())
72 ->withSlugs(array($new))
74 if ($other && ($other->getID() !== $object->getID())) {
75 $errors[] = $this->newError(
78 'The selected repository short name is already in use by '.
79 'another repository. Choose a unique short name.'),