Search code examples
phabricator

Why is this Phabricator Herald rule not applied?


I am trying to create a Herald rule to block commits with empty commit messages. The rule is a global rule that applies to Commit Hook: Commit Content. Unfortunately, I have been unable to get the rule to trigger with the Test Console.

This led me to try altering the conditions in various ways, ultimately trying this:

When any of these conditions are met:
Always 

Take these actions every time this rule matches:
Block push with message: No empty commit messages allowed.

It seems like this should cause Phabricator to apply this rule to any commit, but according to the Rule Transcript even this rule is not applied.

Should it be? If so, what might cause this behavior?


Solution

  • Through discussion in the #phabricator channel on irc.freenode.net, I learned that testing pre-commit Herald rules with the Test Console is not currently supported by Phabricator. The developer that helped me created a task for this issue, which can be found here https://secure.phabricator.com/T9719.

    With the Test Console not an option, I am not entirely sure how to test Herald rules of this type without allowing unacceptable commits into the repository. I had read this https://secure.phabricator.com/book/phabricator/article/diffusion_hooks/ page, which explains how to install custom hooks. Interestingly, it states that "These hooks will run only after all the Herald rules have passed and Phabricator is otherwise ready to accept the commit or push." I asked whether it would be possible to create a hook of this type to deny all commits and then test the Herald rules by actually trying to make commits as normal. It was indicated that this might work. I haven't had a chance to test this yet, so I will post an update once I know more.