3 final class PhabricatorRepositoryFetchRefsTransaction
4 extends PhabricatorRepositoryTransactionType
{
6 const TRANSACTIONTYPE
= 'fetch-refs';
8 public function generateOldValue($object) {
9 return $object->getFetchRules();
12 public function applyInternalEffects($object, $value) {
13 $object->setFetchRules($value);
16 public function getTitle() {
17 $old = $this->getOldValue();
18 $new = $this->getNewValue();
22 '%s set this repository to fetch all refs.',
23 $this->renderAuthor());
26 '%s set this repository to fetch refs: %s.',
27 $this->renderAuthor(),
28 $this->renderValue(implode(', ', $new)));
31 '%s changed fetched refs from %s to %s.',
32 $this->renderAuthor(),
33 $this->renderValue(implode(', ', $old)),
34 $this->renderValue(implode(', ', $new)));
38 public function validateTransactions($object, array $xactions) {
41 foreach ($xactions as $xaction) {
42 $new_value = $xaction->getNewValue();
44 if (!is_array($new_value) ||
!phutil_is_natural_list($new_value)) {
45 $errors[] = $this->newInvalidError(
47 'Fetch rules must be a list of strings, got "%s".',
48 phutil_describe_type($new_value)),
53 foreach ($new_value as $idx => $rule) {
54 if (!is_string($rule)) {
55 $errors[] = $this->newInvalidError(
57 'Fetch rule (at index "%s") must be a string, got "%s".',
59 phutil_describe_type($rule)),
65 $errors[] = $this->newInvalidError(
67 'Fetch rule (at index "%s") is empty. Fetch rules must '.
74 // Since we fetch ref "X" as "+X:X", don't allow rules to include
75 // colons. This is specific to Git and may not be relevant if
76 // Mercurial repositories eventually get fetch rules.
77 if (preg_match('/:/', $rule)) {
78 $errors[] = $this->newInvalidError(
80 'Fetch rule ("%s", at index "%s") is invalid: fetch rules '.
81 'must not contain colons.',