1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 11:30:55 +01:00

Change repository "Clone/Checkout As" to "Short Name"

Summary:
Ref T4245.

  - Rename "Clone/Checkout As" to "Short Name" in the UI.
  - Allow any repository to have a short name, not just hosted repositories.

Test Plan:
  - Ran migration.
  - Reviewed old transactions, saw they looked good.
  - Edited an existing repository's short name.
  - Gave an imported repository a new short name.
  - Removed a repository's short name.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4245

Differential Revision: https://secure.phabricator.com/D14989
This commit is contained in:
epriestley 2016-01-11 02:24:01 -08:00
parent a06715ccdd
commit 96ebd35824
5 changed files with 31 additions and 45 deletions

View file

@ -0,0 +1,2 @@
UPDATE {$NAMESPACE}_repository.repository_transaction
SET transactionType = 'repo:slug' WHERE transactionType = 'repo:clone-name';

View file

@ -17,7 +17,7 @@ final class DiffusionRepositoryEditBasicController
$v_name = $repository->getName(); $v_name = $repository->getName();
$v_desc = $repository->getDetail('description'); $v_desc = $repository->getDetail('description');
$v_clone_name = $repository->getRepositorySlug(); $v_slug = $repository->getRepositorySlug();
$v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs( $v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
$repository->getPHID(), $repository->getPHID(),
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
@ -30,10 +30,7 @@ final class DiffusionRepositoryEditBasicController
$v_name = $request->getStr('name'); $v_name = $request->getStr('name');
$v_desc = $request->getStr('description'); $v_desc = $request->getStr('description');
$v_projects = $request->getArr('projectPHIDs'); $v_projects = $request->getArr('projectPHIDs');
$v_slug = $request->getStr('slug');
if ($repository->isHosted()) {
$v_clone_name = $request->getStr('cloneName');
}
if (!strlen($v_name)) { if (!strlen($v_name)) {
$e_name = pht('Required'); $e_name = pht('Required');
@ -49,7 +46,7 @@ final class DiffusionRepositoryEditBasicController
$type_name = PhabricatorRepositoryTransaction::TYPE_NAME; $type_name = PhabricatorRepositoryTransaction::TYPE_NAME;
$type_desc = PhabricatorRepositoryTransaction::TYPE_DESCRIPTION; $type_desc = PhabricatorRepositoryTransaction::TYPE_DESCRIPTION;
$type_edge = PhabricatorTransactions::TYPE_EDGE; $type_edge = PhabricatorTransactions::TYPE_EDGE;
$type_clone_name = PhabricatorRepositoryTransaction::TYPE_CLONE_NAME; $type_slug = PhabricatorRepositoryTransaction::TYPE_SLUG;
$xactions[] = id(clone $template) $xactions[] = id(clone $template)
->setTransactionType($type_name) ->setTransactionType($type_name)
@ -60,8 +57,8 @@ final class DiffusionRepositoryEditBasicController
->setNewValue($v_desc); ->setNewValue($v_desc);
$xactions[] = id(clone $template) $xactions[] = id(clone $template)
->setTransactionType($type_clone_name) ->setTransactionType($type_slug)
->setNewValue($v_clone_name); ->setNewValue($v_slug);
$xactions[] = id(clone $template) $xactions[] = id(clone $template)
->setTransactionType($type_edge) ->setTransactionType($type_edge)
@ -85,7 +82,7 @@ final class DiffusionRepositoryEditBasicController
} catch (PhabricatorApplicationTransactionValidationException $ex) { } catch (PhabricatorApplicationTransactionValidationException $ex) {
$validation_exception = $ex; $validation_exception = $ex;
$e_slug = $ex->getShortMessage($type_clone_name); $e_slug = $ex->getShortMessage($type_slug);
} }
} }
} }
@ -102,23 +99,13 @@ final class DiffusionRepositoryEditBasicController
->setName('name') ->setName('name')
->setLabel(pht('Name')) ->setLabel(pht('Name'))
->setValue($v_name) ->setValue($v_name)
->setError($e_name)); ->setError($e_name))
->appendChild(
if ($repository->isHosted()) { id(new AphrontFormTextControl())
$form ->setName('slug')
->appendChild( ->setLabel(pht('Short Name'))
id(new AphrontFormTextControl()) ->setValue($v_slug)
->setName('cloneName') ->setError($e_slug))
->setLabel(pht('Clone/Checkout As'))
->setValue($v_clone_name)
->setError($e_slug)
->setCaption(
pht(
'Optional directory name to use when cloning or checking out '.
'this repository.')));
}
$form
->appendChild( ->appendChild(
id(new PhabricatorRemarkupControl()) id(new PhabricatorRemarkupControl())
->setUser($viewer) ->setUser($viewer)

View file

@ -286,15 +286,12 @@ final class DiffusionRepositoryEditMainController
$view->addProperty(pht('Type'), $type); $view->addProperty(pht('Type'), $type);
$view->addProperty(pht('Callsign'), $repository->getCallsign()); $view->addProperty(pht('Callsign'), $repository->getCallsign());
$clone_name = $repository->getRepositorySlug(); $short_name = $repository->getRepositorySlug();
if ($short_name === null) {
if ($repository->isHosted()) { $short_name = $repository->getCloneName();
$view->addProperty( $short_name = phutil_tag('em', array(), $short_name);
pht('Clone/Checkout As'),
$clone_name
? $clone_name.'/'
: phutil_tag('em', array(), $repository->getCloneName().'/'));
} }
$view->addProperty(pht('Short Name'), $short_name);
$view->invokeWillRenderEvent(); $view->invokeWillRenderEvent();

View file

@ -39,7 +39,7 @@ final class PhabricatorRepositoryEditor
$types[] = PhabricatorRepositoryTransaction::TYPE_PUSH_POLICY; $types[] = PhabricatorRepositoryTransaction::TYPE_PUSH_POLICY;
$types[] = PhabricatorRepositoryTransaction::TYPE_CREDENTIAL; $types[] = PhabricatorRepositoryTransaction::TYPE_CREDENTIAL;
$types[] = PhabricatorRepositoryTransaction::TYPE_DANGEROUS; $types[] = PhabricatorRepositoryTransaction::TYPE_DANGEROUS;
$types[] = PhabricatorRepositoryTransaction::TYPE_CLONE_NAME; $types[] = PhabricatorRepositoryTransaction::TYPE_SLUG;
$types[] = PhabricatorRepositoryTransaction::TYPE_SERVICE; $types[] = PhabricatorRepositoryTransaction::TYPE_SERVICE;
$types[] = PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE; $types[] = PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE;
$types[] = PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES; $types[] = PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES;
@ -98,7 +98,7 @@ final class PhabricatorRepositoryEditor
return $object->getCredentialPHID(); return $object->getCredentialPHID();
case PhabricatorRepositoryTransaction::TYPE_DANGEROUS: case PhabricatorRepositoryTransaction::TYPE_DANGEROUS:
return $object->shouldAllowDangerousChanges(); return $object->shouldAllowDangerousChanges();
case PhabricatorRepositoryTransaction::TYPE_CLONE_NAME: case PhabricatorRepositoryTransaction::TYPE_SLUG:
return $object->getRepositorySlug(); return $object->getRepositorySlug();
case PhabricatorRepositoryTransaction::TYPE_SERVICE: case PhabricatorRepositoryTransaction::TYPE_SERVICE:
return $object->getAlmanacServicePHID(); return $object->getAlmanacServicePHID();
@ -147,7 +147,7 @@ final class PhabricatorRepositoryEditor
case PhabricatorRepositoryTransaction::TYPE_STAGING_URI: case PhabricatorRepositoryTransaction::TYPE_STAGING_URI:
case PhabricatorRepositoryTransaction::TYPE_AUTOMATION_BLUEPRINTS: case PhabricatorRepositoryTransaction::TYPE_AUTOMATION_BLUEPRINTS:
return $xaction->getNewValue(); return $xaction->getNewValue();
case PhabricatorRepositoryTransaction::TYPE_CLONE_NAME: case PhabricatorRepositoryTransaction::TYPE_SLUG:
$name = $xaction->getNewValue(); $name = $xaction->getNewValue();
if (strlen($name)) { if (strlen($name)) {
return $name; return $name;
@ -220,7 +220,7 @@ final class PhabricatorRepositoryEditor
case PhabricatorRepositoryTransaction::TYPE_DANGEROUS: case PhabricatorRepositoryTransaction::TYPE_DANGEROUS:
$object->setDetail('allow-dangerous-changes', $xaction->getNewValue()); $object->setDetail('allow-dangerous-changes', $xaction->getNewValue());
return; return;
case PhabricatorRepositoryTransaction::TYPE_CLONE_NAME: case PhabricatorRepositoryTransaction::TYPE_SLUG:
$object->setRepositorySlug($xaction->getNewValue()); $object->setRepositorySlug($xaction->getNewValue());
return; return;
case PhabricatorRepositoryTransaction::TYPE_SERVICE: case PhabricatorRepositoryTransaction::TYPE_SERVICE:
@ -331,7 +331,7 @@ final class PhabricatorRepositoryEditor
case PhabricatorRepositoryTransaction::TYPE_PUSH_POLICY: case PhabricatorRepositoryTransaction::TYPE_PUSH_POLICY:
case PhabricatorRepositoryTransaction::TYPE_CREDENTIAL: case PhabricatorRepositoryTransaction::TYPE_CREDENTIAL:
case PhabricatorRepositoryTransaction::TYPE_DANGEROUS: case PhabricatorRepositoryTransaction::TYPE_DANGEROUS:
case PhabricatorRepositoryTransaction::TYPE_CLONE_NAME: case PhabricatorRepositoryTransaction::TYPE_SLUG:
case PhabricatorRepositoryTransaction::TYPE_SERVICE: case PhabricatorRepositoryTransaction::TYPE_SERVICE:
case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES: case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES:
case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE: case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE:
@ -454,7 +454,7 @@ final class PhabricatorRepositoryEditor
} }
break; break;
case PhabricatorRepositoryTransaction::TYPE_CLONE_NAME: case PhabricatorRepositoryTransaction::TYPE_SLUG:
foreach ($xactions as $xaction) { foreach ($xactions as $xaction) {
$old = $xaction->getOldValue(); $old = $xaction->getOldValue();
$new = $xaction->getNewValue(); $new = $xaction->getNewValue();

View file

@ -23,7 +23,7 @@ final class PhabricatorRepositoryTransaction
const TYPE_PUSH_POLICY = 'repo:push-policy'; const TYPE_PUSH_POLICY = 'repo:push-policy';
const TYPE_CREDENTIAL = 'repo:credential'; const TYPE_CREDENTIAL = 'repo:credential';
const TYPE_DANGEROUS = 'repo:dangerous'; const TYPE_DANGEROUS = 'repo:dangerous';
const TYPE_CLONE_NAME = 'repo:clone-name'; const TYPE_SLUG = 'repo:slug';
const TYPE_SERVICE = 'repo:service'; const TYPE_SERVICE = 'repo:service';
const TYPE_SYMBOLS_SOURCES = 'repo:symbol-source'; const TYPE_SYMBOLS_SOURCES = 'repo:symbol-source';
const TYPE_SYMBOLS_LANGUAGE = 'repo:symbol-language'; const TYPE_SYMBOLS_LANGUAGE = 'repo:symbol-language';
@ -369,19 +369,19 @@ final class PhabricatorRepositoryTransaction
'%s enabled protection against dangerous changes.', '%s enabled protection against dangerous changes.',
$this->renderHandleLink($author_phid)); $this->renderHandleLink($author_phid));
} }
case self::TYPE_CLONE_NAME: case self::TYPE_SLUG:
if (strlen($old) && !strlen($new)) { if (strlen($old) && !strlen($new)) {
return pht( return pht(
'%s removed the clone name of this repository.', '%s removed the short name of this repository.',
$this->renderHandleLink($author_phid)); $this->renderHandleLink($author_phid));
} else if (strlen($new) && !strlen($old)) { } else if (strlen($new) && !strlen($old)) {
return pht( return pht(
'%s set the clone name of this repository to "%s".', '%s set the short name of this repository to "%s".',
$this->renderHandleLink($author_phid), $this->renderHandleLink($author_phid),
$new); $new);
} else { } else {
return pht( return pht(
'%s changed the clone name of this repository from "%s" to "%s".', '%s changed the short name of this repository from "%s" to "%s".',
$this->renderHandleLink($author_phid), $this->renderHandleLink($author_phid),
$old, $old,
$new); $new);