Page MenuHomePhabricator
Paste P1692

example.diff
ActivePublic

Authored by epriestley on Jan 3 2015, 11:41 PM.
Tags
None
Referenced Files
F261050: example.diff
Jan 3 2015, 11:41 PM
Subscribers
None
diff --git a/src/applications/repository/editor/PhabricatorRepositoryEditor.php b/src/applications/repository/editor/PhabricatorRepositoryEditor.php
index 5335fa2..bb94a9f 100644
--- a/src/applications/repository/editor/PhabricatorRepositoryEditor.php
+++ b/src/applications/repository/editor/PhabricatorRepositoryEditor.php
@@ -330,6 +330,25 @@ final class PhabricatorRepositoryEditor
$errors = parent::validateTransaction($object, $type, $xactions);
switch ($type) {
+ case PhabricatorRepositoryTransaction::TYPE_NAME:
+ foreach ($xactions as $xaction) {
+ $username = $this->getActor()->getUsername();
+ $reponame = $xaction->getNewValue();
+
+ $prefix = $username.'-';
+ if (strncmp($reponame, $prefix, strlen($prefix)) {
+ $error = new PhabricatorApplicationTransactionValidationError(
+ $type,
+ pht('Invalid'),
+ pht(
+ 'Repositories must be prefixed with your username, like '.
+ '"%s".',
+ "{$prefix}example"),
+ $xaction);
+ $errors[] = $error;
+ }
+ }
+ break;
case PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE:
case PhabricatorRepositoryTransaction::TYPE_TRACK_ONLY:
foreach ($xactions as $xaction) {

Event Timeline

epriestley changed the title of this paste from untitled to example.diff.
epriestley updated the paste's language from autodetect to autodetect.