Page MenuHomePhabricator

Commit hooks should have better notification options for committers
Closed, WontfixPublic

Description

Use case: I want to add a global or object rule to enforce something in commit with pre-commit.

Instead of hard blocking the commit, I want to gradually educate people first by sending them a notification and telling them that next month, this will be a blocking commit hook.
Currently the only notification option is to send an email. There are two downsides:
1: You can target a specific person, project etc, but not the original committer
2: Email is not sent to the person triggering the action, since most people disable email notifications for 'self triggered actions'. (or is the author of the herald rule the trigger ?)

I think this could be better:
New option: Notify committer, and it would be delivered according the notification settings that the user configured.

Event Timeline

hartman raised the priority of this task from to Needs Triage.
hartman updated the task description. (Show Details)
hartman added projects: Herald, Notifications.
hartman added a subscriber: hartman.

This is a very niche use case. It also tends to conflate the pusher (who we may not know, for imported repositories), the committer, and the author. This makes me hesitant about implementing it.

A possible workaround is to write a rule like this:

When:
  [The commit][does][whatever you don't want]
  [Body][does not contain][@bypass-this-rule]
Take these actions:
  [Block commit with message]["The bad thing you're doing won't work in a month. For now, add @bypass-this-rule to your commit message to do it anyway."]

This will only work for hosted repositories, and has some tradeoffs, but in many cases I think it's a pretty good approach.

Also, Herald is intentionally stronger than self-actions.

epriestley claimed this task.
  • You can now technically write this as an extension by extending HeraldAction, although mail is quite complicated and this extension may be challenging to write.
  • You could use an extension like the one in P1895 to add a comment instead, although I think this will be caught by notification preferences.
  • You can use the action above (reject commit unless they bypass).
  • You could use "Add Projects" and then just manually email the offenders who got hit at the end of the week to warn them.

This specific use case is too niche to bring upstream, there are a variety of reasonable workarounds, and we haven't seen other interest in similar behaviors.

We are also very unlikely to ever upstream actions which allow one user to overrule another user's notification preferences.