How do you make Herald trigger for ONLY specific branches?

I’ve been trying to get Herald to trigger when someone commits to a specific branch. The situation is we work on named feature branches and when complete merge to dev. We want all dev commits to build, they may or may not be merge commits.

What we are trying to do is trigger a herald rule if “Branch” “is only” dev OR “Commit” "is merged into branch dev. i.e. branch contains dev AND “is merge commit” is insufficient.

I thought I could accomplish this with “contains” or a regular expression. Regular expressions give a little more control but I still haven’t managed to get it to work.

I’ve tried the following:


“Branch” “contains” dev
This results in triggering for all commits and merges relating to dev, even if the head is a feature branch. So it became apparent that contains wasn’t useful.


“Branch” “matches regexp” ^dev$
This fails the needed test cases using the test console:

With Field: Branches TXX-feature-x TYY-feature-y dev
Passed Branches matches regexp /^dev$/
Passed Rule passed.

Which is unexpected, when using regex101.com with this test string it only matches if the whole string is dev but Phabricator is matching with additional strings


I also tried other expressions such as (^|[^\s])dev with no luck. It seems to me that the each branch involved is evaluated separately rather than the whole field at once. Is this correct?

To me, it makes sense that a rule such as “Merge into branch”, “Target is branch” or something similar.

Is there something that I’m missing in understanding these Herald rules or is this just functionality that is not easily accomplished?

Cheers

Yes.

Is there something that I’m missing in understanding these Herald rules or is this just functionality that is not easily accomplished?

This is not easily accomplished.

Is there a plan to add better support for Herald rules? This seems like basic functionality for triggers “trigger only commits on branch X”.

Is there a plan to add better support for Herald rules?

No.

This seems like basic functionality for triggers “trigger only commits on branch X”.

It leads to catastrophic behavior if you misconfigure things.

I don’t want git checkout -b feature1 && git push origin feature1 to send tens of millions of emails if someone got a Herald rule wrong. See https://secure.phabricator.com/T6522 for some discussion.

See https://secure.phabricator.com/T6522#173837 in particular.

Sounds like the problem is more closely related to git since rebasing is more common. We are using Mercurial. Especially since our workflows encourage collaborative feature branches which will be maintained and not rebased.

I’m not sure how the current options prevent a lot of unnecessary triggers in the example of a rebase to master from an old feature branch since wouldn’t each of those commits from the feature branch match master with “contains” anyway?

It seems we would just need the regular expression evaluation to be a bit tighter to meet our requirements, rather than per branch just evaluate the space separated list of branches all together (as it is reported in the Herald test view). The current rule options are triggering the rule more often than we expect.

HI Sean_Tasker, might be a dumb question. but I couldn’t find a herald rule to select branch. May I know which heral Rule we have to select to create a rule based ont he branch name from the following list

{
Commits

Differential Diffs

Differential Revisions

Herald Rules

Maniphest Tasks

Outbound Mail

Phame Blogs

Phame Posts

Pholio Mocks

Phriction Documents

Ponder Questions

Projects

Commit Hook: Branches/Tags/Bookmarks

Commit Hook: Commit Content
}

You can use Commits and specify a condition for branches, but it may not give you the control you need. We had rules trigger on branches that we didn’t want because the branch we specified was an ancestor of the current branch and as such it was included in the branches list. That is the original reason for my question.