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:
parent
a06715ccdd
commit
96ebd35824
5 changed files with 31 additions and 45 deletions
2
resources/sql/autopatches/20160111.repo.01.slugx.sql
Normal file
2
resources/sql/autopatches/20160111.repo.01.slugx.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
UPDATE {$NAMESPACE}_repository.repository_transaction
|
||||
SET transactionType = 'repo:slug' WHERE transactionType = 'repo:clone-name';
|
|
@ -17,7 +17,7 @@ final class DiffusionRepositoryEditBasicController
|
|||
|
||||
$v_name = $repository->getName();
|
||||
$v_desc = $repository->getDetail('description');
|
||||
$v_clone_name = $repository->getRepositorySlug();
|
||||
$v_slug = $repository->getRepositorySlug();
|
||||
$v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$repository->getPHID(),
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
|
@ -30,10 +30,7 @@ final class DiffusionRepositoryEditBasicController
|
|||
$v_name = $request->getStr('name');
|
||||
$v_desc = $request->getStr('description');
|
||||
$v_projects = $request->getArr('projectPHIDs');
|
||||
|
||||
if ($repository->isHosted()) {
|
||||
$v_clone_name = $request->getStr('cloneName');
|
||||
}
|
||||
$v_slug = $request->getStr('slug');
|
||||
|
||||
if (!strlen($v_name)) {
|
||||
$e_name = pht('Required');
|
||||
|
@ -49,7 +46,7 @@ final class DiffusionRepositoryEditBasicController
|
|||
$type_name = PhabricatorRepositoryTransaction::TYPE_NAME;
|
||||
$type_desc = PhabricatorRepositoryTransaction::TYPE_DESCRIPTION;
|
||||
$type_edge = PhabricatorTransactions::TYPE_EDGE;
|
||||
$type_clone_name = PhabricatorRepositoryTransaction::TYPE_CLONE_NAME;
|
||||
$type_slug = PhabricatorRepositoryTransaction::TYPE_SLUG;
|
||||
|
||||
$xactions[] = id(clone $template)
|
||||
->setTransactionType($type_name)
|
||||
|
@ -60,8 +57,8 @@ final class DiffusionRepositoryEditBasicController
|
|||
->setNewValue($v_desc);
|
||||
|
||||
$xactions[] = id(clone $template)
|
||||
->setTransactionType($type_clone_name)
|
||||
->setNewValue($v_clone_name);
|
||||
->setTransactionType($type_slug)
|
||||
->setNewValue($v_slug);
|
||||
|
||||
$xactions[] = id(clone $template)
|
||||
->setTransactionType($type_edge)
|
||||
|
@ -85,7 +82,7 @@ final class DiffusionRepositoryEditBasicController
|
|||
} catch (PhabricatorApplicationTransactionValidationException $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')
|
||||
->setLabel(pht('Name'))
|
||||
->setValue($v_name)
|
||||
->setError($e_name));
|
||||
|
||||
if ($repository->isHosted()) {
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setName('cloneName')
|
||||
->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
|
||||
->setError($e_name))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setName('slug')
|
||||
->setLabel(pht('Short Name'))
|
||||
->setValue($v_slug)
|
||||
->setError($e_slug))
|
||||
->appendChild(
|
||||
id(new PhabricatorRemarkupControl())
|
||||
->setUser($viewer)
|
||||
|
|
|
@ -286,15 +286,12 @@ final class DiffusionRepositoryEditMainController
|
|||
$view->addProperty(pht('Type'), $type);
|
||||
$view->addProperty(pht('Callsign'), $repository->getCallsign());
|
||||
|
||||
$clone_name = $repository->getRepositorySlug();
|
||||
|
||||
if ($repository->isHosted()) {
|
||||
$view->addProperty(
|
||||
pht('Clone/Checkout As'),
|
||||
$clone_name
|
||||
? $clone_name.'/'
|
||||
: phutil_tag('em', array(), $repository->getCloneName().'/'));
|
||||
$short_name = $repository->getRepositorySlug();
|
||||
if ($short_name === null) {
|
||||
$short_name = $repository->getCloneName();
|
||||
$short_name = phutil_tag('em', array(), $short_name);
|
||||
}
|
||||
$view->addProperty(pht('Short Name'), $short_name);
|
||||
|
||||
$view->invokeWillRenderEvent();
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ final class PhabricatorRepositoryEditor
|
|||
$types[] = PhabricatorRepositoryTransaction::TYPE_PUSH_POLICY;
|
||||
$types[] = PhabricatorRepositoryTransaction::TYPE_CREDENTIAL;
|
||||
$types[] = PhabricatorRepositoryTransaction::TYPE_DANGEROUS;
|
||||
$types[] = PhabricatorRepositoryTransaction::TYPE_CLONE_NAME;
|
||||
$types[] = PhabricatorRepositoryTransaction::TYPE_SLUG;
|
||||
$types[] = PhabricatorRepositoryTransaction::TYPE_SERVICE;
|
||||
$types[] = PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE;
|
||||
$types[] = PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES;
|
||||
|
@ -98,7 +98,7 @@ final class PhabricatorRepositoryEditor
|
|||
return $object->getCredentialPHID();
|
||||
case PhabricatorRepositoryTransaction::TYPE_DANGEROUS:
|
||||
return $object->shouldAllowDangerousChanges();
|
||||
case PhabricatorRepositoryTransaction::TYPE_CLONE_NAME:
|
||||
case PhabricatorRepositoryTransaction::TYPE_SLUG:
|
||||
return $object->getRepositorySlug();
|
||||
case PhabricatorRepositoryTransaction::TYPE_SERVICE:
|
||||
return $object->getAlmanacServicePHID();
|
||||
|
@ -147,7 +147,7 @@ final class PhabricatorRepositoryEditor
|
|||
case PhabricatorRepositoryTransaction::TYPE_STAGING_URI:
|
||||
case PhabricatorRepositoryTransaction::TYPE_AUTOMATION_BLUEPRINTS:
|
||||
return $xaction->getNewValue();
|
||||
case PhabricatorRepositoryTransaction::TYPE_CLONE_NAME:
|
||||
case PhabricatorRepositoryTransaction::TYPE_SLUG:
|
||||
$name = $xaction->getNewValue();
|
||||
if (strlen($name)) {
|
||||
return $name;
|
||||
|
@ -220,7 +220,7 @@ final class PhabricatorRepositoryEditor
|
|||
case PhabricatorRepositoryTransaction::TYPE_DANGEROUS:
|
||||
$object->setDetail('allow-dangerous-changes', $xaction->getNewValue());
|
||||
return;
|
||||
case PhabricatorRepositoryTransaction::TYPE_CLONE_NAME:
|
||||
case PhabricatorRepositoryTransaction::TYPE_SLUG:
|
||||
$object->setRepositorySlug($xaction->getNewValue());
|
||||
return;
|
||||
case PhabricatorRepositoryTransaction::TYPE_SERVICE:
|
||||
|
@ -331,7 +331,7 @@ final class PhabricatorRepositoryEditor
|
|||
case PhabricatorRepositoryTransaction::TYPE_PUSH_POLICY:
|
||||
case PhabricatorRepositoryTransaction::TYPE_CREDENTIAL:
|
||||
case PhabricatorRepositoryTransaction::TYPE_DANGEROUS:
|
||||
case PhabricatorRepositoryTransaction::TYPE_CLONE_NAME:
|
||||
case PhabricatorRepositoryTransaction::TYPE_SLUG:
|
||||
case PhabricatorRepositoryTransaction::TYPE_SERVICE:
|
||||
case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES:
|
||||
case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE:
|
||||
|
@ -454,7 +454,7 @@ final class PhabricatorRepositoryEditor
|
|||
}
|
||||
break;
|
||||
|
||||
case PhabricatorRepositoryTransaction::TYPE_CLONE_NAME:
|
||||
case PhabricatorRepositoryTransaction::TYPE_SLUG:
|
||||
foreach ($xactions as $xaction) {
|
||||
$old = $xaction->getOldValue();
|
||||
$new = $xaction->getNewValue();
|
||||
|
|
|
@ -23,7 +23,7 @@ final class PhabricatorRepositoryTransaction
|
|||
const TYPE_PUSH_POLICY = 'repo:push-policy';
|
||||
const TYPE_CREDENTIAL = 'repo:credential';
|
||||
const TYPE_DANGEROUS = 'repo:dangerous';
|
||||
const TYPE_CLONE_NAME = 'repo:clone-name';
|
||||
const TYPE_SLUG = 'repo:slug';
|
||||
const TYPE_SERVICE = 'repo:service';
|
||||
const TYPE_SYMBOLS_SOURCES = 'repo:symbol-source';
|
||||
const TYPE_SYMBOLS_LANGUAGE = 'repo:symbol-language';
|
||||
|
@ -369,19 +369,19 @@ final class PhabricatorRepositoryTransaction
|
|||
'%s enabled protection against dangerous changes.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
}
|
||||
case self::TYPE_CLONE_NAME:
|
||||
case self::TYPE_SLUG:
|
||||
if (strlen($old) && !strlen($new)) {
|
||||
return pht(
|
||||
'%s removed the clone name of this repository.',
|
||||
'%s removed the short name of this repository.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
} else if (strlen($new) && !strlen($old)) {
|
||||
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),
|
||||
$new);
|
||||
} else {
|
||||
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),
|
||||
$old,
|
||||
$new);
|
||||
|
|
Loading…
Reference in a new issue