Add notify section in project.config

The notify section allows project owners to include emails to users
directly from project.config. This removes the need to create fake
user accounts to always BCC a group mailing list. For example:

  [notify "dev-group"]
    email = dev-team <dev-team@example.com>
    filter = branch:master visibleto:dev

Internal groups may also be used as a mailing list, automatically
BCCing any user that is a member of the group if the group can see
the change:

  [access "refs/heads/*"]
    read = group Developers
  [notify "reviewers"]
    email = group Developers

Change-Id: I02bd05b562e420a4742ff27ffacad8f20648e4f0
This commit is contained in:
Shawn O. Pearce
2012-04-26 16:24:12 -07:00
parent 68e49477c4
commit 57bec12129
17 changed files with 597 additions and 98 deletions

View File

@@ -43,6 +43,12 @@ import java.util.List;
* @type <T> type of object the predicate can evaluate in memory.
*/
public abstract class Predicate<T> {
/** A predicate that matches any input, always, with no cost. */
@SuppressWarnings("unchecked")
public static <T> Predicate<T> any() {
return (Predicate<T>) Any.INSTANCE;
}
/** Combine the passed predicates into a single AND node. */
public static <T> Predicate<T> and(final Predicate<T>... that) {
if (that.length == 1) {
@@ -120,4 +126,36 @@ public abstract class Predicate<T> {
@Override
public abstract boolean equals(Object other);
private static class Any<T> extends Predicate<T> {
private static final Any<Object> INSTANCE = new Any<Object>();
private Any() {
}
@Override
public Predicate<T> copy(Collection<? extends Predicate<T>> children) {
return this;
}
@Override
public boolean match(T object) {
return true;
}
@Override
public int getCost() {
return 0;
}
@Override
public int hashCode() {
return System.identityHashCode(this);
}
@Override
public boolean equals(Object other) {
return other == this;
}
}
}