@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow Herald rules to add reviewers

Summary:
Ref T1279. Although I think this is a bad idea in general (we once supported it, removed it, and seemed better off for it) users expect it to exist and want it to be available. Give them enough rope to shoot themselves in the foot.

I will probably write some lengthy treatise on how you shouldn't use this rule later.

Implementation is straightforward because Differential previously supported this rule.

This rule can also be used to add project reviewers.

Test Plan: Made some "add reviewers" rules, created revisions, saw reviewers trigger.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1279

Differential Revision: https://secure.phabricator.com/D7235

+37 -5
+1 -1
src/__celerity_resource_map__.php
··· 1176 1176 ), 1177 1177 'herald-rule-editor' => 1178 1178 array( 1179 - 'uri' => '/res/c42c0444/rsrc/js/application/herald/HeraldRuleEditor.js', 1179 + 'uri' => '/res/a561eb19/rsrc/js/application/herald/HeraldRuleEditor.js', 1180 1180 'type' => 'js', 1181 1181 'requires' => 1182 1182 array(
+4 -1
src/applications/differential/editor/DifferentialRevisionEditor.php
··· 272 272 $xscript_header); 273 273 274 274 $sub = array( 275 - 'rev' => array(), 275 + 'rev' => $adapter->getReviewersAddedByHerald(), 276 276 'ccs' => $adapter->getCCsAddedByHerald(), 277 277 ); 278 278 $rem_ccs = $adapter->getCCsRemovedByHerald(); ··· 305 305 306 306 $stable[$key] = array_diff_key($old[$key], $add[$key] + $rem[$key]); 307 307 } 308 + 309 + // Prevent Herald rules from adding a revision's owner as a reviewer. 310 + unset($add['rev'][$revision->getAuthorPHID()]); 308 311 309 312 self::updateReviewers( 310 313 $revision,
+14 -3
src/applications/herald/adapter/HeraldAdapter.php
··· 51 51 const ACTION_FLAG = 'flag'; 52 52 const ACTION_ASSIGN_TASK = 'assigntask'; 53 53 const ACTION_ADD_PROJECTS = 'addprojects'; 54 + const ACTION_ADD_REVIEWERS = 'addreviewers'; 54 55 55 56 const VALUE_TEXT = 'text'; 56 57 const VALUE_NONE = 'none'; ··· 63 64 const VALUE_PROJECT = 'project'; 64 65 const VALUE_FLAG_COLOR = 'flagcolor'; 65 66 const VALUE_CONTENT_SOURCE = 'contentsource'; 67 + const VALUE_USER_OR_PROJECT = 'userorproject'; 66 68 67 69 private $contentSource; 68 70 ··· 293 295 } 294 296 if (!is_array($condition_value)) { 295 297 throw new HeraldInvalidConditionException( 296 - "Expected conditionv value to be an array."); 298 + "Expected condition value to be an array."); 297 299 } 298 300 299 301 $have = array_select_keys(array_fuse($field_value), $condition_value); ··· 482 484 self::ACTION_FLAG => pht('Mark with flag'), 483 485 self::ACTION_ASSIGN_TASK => pht('Assign task to'), 484 486 self::ACTION_ADD_PROJECTS => pht('Add projects'), 487 + self::ACTION_ADD_REVIEWERS => pht('Add reviewers'), 485 488 ); 486 489 case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: 487 490 return array( ··· 491 494 self::ACTION_EMAIL => pht('Send me an email'), 492 495 self::ACTION_AUDIT => pht('Trigger an Audit by me'), 493 496 self::ACTION_FLAG => pht('Mark with flag'), 494 - self::ACTION_ASSIGN_TASK => pht('Assign task to me.'), 497 + self::ACTION_ASSIGN_TASK => pht('Assign task to me'), 495 498 self::ACTION_ADD_PROJECTS => pht('Add projects'), 499 + self::ACTION_ADD_REVIEWERS => pht('Add me as a reviewer'), 496 500 ); 497 501 default: 498 502 throw new Exception("Unknown rule type '{$rule_type}'!"); ··· 518 522 case self::ACTION_REMOVE_CC: 519 523 case self::ACTION_AUDIT: 520 524 case self::ACTION_ASSIGN_TASK: 525 + case self::ACTION_ADD_REVIEWERS: 521 526 // For personal rules, force these actions to target the rule owner. 522 527 $target = array($author_phid); 523 528 break; ··· 612 617 case self::ACTION_NOTHING: 613 618 case self::ACTION_AUDIT: 614 619 case self::ACTION_ASSIGN_TASK: 620 + case self::ACTION_ADD_REVIEWERS: 615 621 return self::VALUE_NONE; 616 622 case self::ACTION_FLAG: 617 623 return self::VALUE_FLAG_COLOR; ··· 635 641 return self::VALUE_FLAG_COLOR; 636 642 case self::ACTION_ASSIGN_TASK: 637 643 return self::VALUE_USER; 644 + case self::ACTION_ADD_REVIEWERS: 645 + return self::VALUE_USER_OR_PROJECT; 638 646 default: 639 647 throw new Exception("Unknown or invalid action '{$action}'."); 640 648 } ··· 752 760 } 753 761 $out[] = null; 754 762 755 - if ($rule->getRepetitionPolicy() == HeraldRepetitionPolicyConfig::EVERY) { 763 + $integer_code_for_every = HeraldRepetitionPolicyConfig::toInt( 764 + HeraldRepetitionPolicyConfig::EVERY); 765 + 766 + if ($rule->getRepetitionPolicy() == $integer_code_for_every) { 756 767 $out[] = pht('Take these actions every time this rule matches:'); 757 768 } else { 758 769 $out[] = pht('Take these actions the first time this rule matches:');
+16
src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php
··· 15 15 protected $newCCs = array(); 16 16 protected $remCCs = array(); 17 17 protected $emailPHIDs = array(); 18 + protected $addReviewerPHIDs = array(); 18 19 19 20 protected $repository; 20 21 protected $affectedPackages; ··· 107 108 108 109 public function getEmailPHIDsAddedByHerald() { 109 110 return $this->emailPHIDs; 111 + } 112 + 113 + public function getReviewersAddedByHerald() { 114 + return $this->addReviewerPHIDs; 110 115 } 111 116 112 117 public function getPHID() { ··· 327 332 self::ACTION_ADD_CC, 328 333 self::ACTION_REMOVE_CC, 329 334 self::ACTION_EMAIL, 335 + self::ACTION_ADD_REVIEWERS, 330 336 self::ACTION_NOTHING, 331 337 ); 332 338 case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: ··· 335 341 self::ACTION_REMOVE_CC, 336 342 self::ACTION_EMAIL, 337 343 self::ACTION_FLAG, 344 + self::ACTION_ADD_REVIEWERS, 338 345 self::ACTION_NOTHING, 339 346 ); 340 347 } ··· 423 430 $effect, 424 431 true, 425 432 pht('Removed addresses from CC list.')); 433 + break; 434 + case self::ACTION_ADD_REVIEWERS: 435 + foreach ($effect->getTarget() as $phid) { 436 + $this->addReviewerPHIDs[$phid] = true; 437 + } 438 + $result[] = new HeraldApplyTranscript( 439 + $effect, 440 + true, 441 + pht('Added reviewers.')); 426 442 break; 427 443 default: 428 444 throw new Exception("No rules to handle action '{$action}'.");
+1
src/applications/herald/controller/HeraldRuleController.php
··· 513 513 'repository' => '/typeahead/common/repositories/', 514 514 'package' => '/typeahead/common/packages/', 515 515 'project' => '/typeahead/common/projects/', 516 + 'userorproject' => '/typeahead/common/usersorprojects/', 516 517 ), 517 518 'markup' => $template, 518 519 );
+1
webroot/rsrc/js/application/herald/HeraldRuleEditor.js
··· 220 220 case 'tag': 221 221 case 'package': 222 222 case 'project': 223 + case 'userorproject': 223 224 var tokenizer = this._newTokenizer(type); 224 225 input = tokenizer[0]; 225 226 get_fn = tokenizer[1];