Page MenuHomePhabricator

Configurable warning when not subscribing a mailing list
Closed, ResolvedPublic

Description

In the LLVM project, code reviews always need to go to one of 2 public mailing lists (either llvm-commits or cfe-commits). The problem is that people using phabricator often forget to add one of those lists, which is the primary way how other developers discover and follow code reviews that are going on.
It would be great if we had a way to configure that if somebody creates a patch without cc'ing one of the lists to pop up a window saying "you did not add llvm-commits or cfe-dev as subscribers - do you want to do a private review?"

Event Timeline

klimek raised the priority of this task from to Needs Triage.
klimek updated the task description. (Show Details)
klimek added a subscriber: klimek.

I don't immediately see a reasonable approach to implement this in a general way. In other cases, I think rules like this are usually expressed as "always use Herald to CC <some list>", but it sounds like there is no way to automatically determine the correct list in this case?

We have a buildRevisionWarnings() method, and we can move that into CustomFields and then I can write you a tiny piece of plugin code. This wouldn't prompt or pop a dialog, but would look like this:

Screen_Shot_2014-06-27_at_1.35.31_AM.png (780×1 px, 161 KB)

After T4631, this could also prompt from the CLI on the arc diff workflow, similar to the existing "You didn't add any reviewers, do you want to continue anyway?" prompt:

$ arc diff
...
...

You did not CC llvm-commits or cfe-commits. If you continue,
you will create a private review. Continue anyway? [y/N]

Would those cover your use case?

That definitely sounds like a very good first step. We would reevaluate how often unintentional private reviews happen afterwards. Thanks!

Okay, you should be able to drop something like this in phabricator/src/extensions/:

<?php

final class MailingListWarningCustomField extends DifferentialCustomField {

  public function getFieldKey() {
    return 'mycompany:mycustomfield';
  }

  public function shouldAppearInPropertyView() {
    // This is required or the field won't be loaded on the detail page.
    return true;
  }

  public function renderPropertyViewValue() {
    // This prevents it from actually rendering a property.
    return null;
  }

  public function getWarningsForRevisionHeader() {
    $revision = $this->getObject();

    $ccs = PhabricatorSubscribersQuery::loadSubscribersForPHID(
      $revision->getPHID());

    $warnings = array();
    if (true) {
      $warnings[] = pht(
        "You have not added X@lists or Y@lists to CC.");
    }

    return $warnings;
  }

}

The $ccs will be a list of CC'd PHIDs, so you could reasonably hard-code the list PHIDs, look for them in $ccs, and add a warning if they're not present. It will look like this (yellow header bar):

Screen_Shot_2014-07-02_at_5.15.11_AM.png (884×1 px, 160 KB)

Oh, this line:

public function getWarningsForRevisionHeader() {

...should actually be:

public function getWarningsForRevisionHeader(array $handles) {

Erk, this one too:

public function renderPropertyViewValue() {

Should be:

public function renderPropertyViewValue(array $handles) {
epriestley triaged this task as Wishlist priority.Jul 12 2014, 2:14 PM

Ah, this works, but only after-the-fact. The problem is when we add a mailing list to cc' after the fact, the mailing list doesn't get a mail that looks like the "request for review" mail, so people on the list are missing context (which is another thing we want to fix but haven't gotten around to).

Actually works quite nice (I have worded the text to suggest to create a new revision). Now I have to find out where I can make the warning field screaming red ;)

epriestley claimed this task.

I'm going to close this since I think T5786 covers the next steps.