Page MenuHomePhabricator

example.diff

Authored By
epriestley
Jan 3 2015, 11:41 PM
Size
1 KB
Referenced Files
None
Subscribers
None

example.diff

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) {

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/qq/fy/lfct3awpoofnbpuk
Default Alt Text
example.diff (1 KB)

Event Timeline