Page MenuHomePhabricator

Add Herald support for blocking ref changes
ClosedPublic

Authored by epriestley on Dec 17 2013, 10:05 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 18, 1:39 AM
Unknown Object (File)
Tue, Apr 9, 8:59 PM
Unknown Object (File)
Mon, Apr 8, 12:43 AM
Unknown Object (File)
Mon, Apr 1, 1:26 PM
Unknown Object (File)
Mon, Apr 1, 1:26 PM
Unknown Object (File)
Mon, Apr 1, 12:58 PM
Unknown Object (File)
Mon, Apr 1, 12:34 PM
Unknown Object (File)
Feb 8 2024, 10:14 AM
Subscribers

Details

Summary

Ref T4195. Allows users to write Herald rules which block ref changes. For example, you can write a rule like alincoln can not create branches, or no one can push to the branch "frozen".

Test Plan

This covers a lot of ground. I created and pushed a bunch of rules, then looked at transcripts, in general. Here are some bits in detail:

Here's a hook-based reject message:

>>> orbital ~/repos/POEMS $ git push
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 274 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: +---------------------------------------------------------------+
remote: |      * * * PUSH REJECTED BY EVIL DRAGON BUREAUCRATS * * *     |
remote: +---------------------------------------------------------------+
remote:             \
remote:              \                    ^    /^
remote:               \                  / \  // \
remote:                \   |\___/|      /   \//  .\
remote:                 \  /V  V  \__  /    //  | \ \           *----*
remote:                   /     /  \/_/    //   |  \  \          \   |
remote:                   @___@`    \/_   //    |   \   \         \/\ \
remote:                  0/0/|       \/_ //     |    \    \         \  \
remote:              0/0/0/0/|        \///      |     \     \       |  |
remote:           0/0/0/0/0/_|_ /   (  //       |      \     _\     |  /
remote:        0/0/0/0/0/0/`/,_ _ _/  ) ; -.    |    _ _\.-~       /   /
remote:                    ,-}        _      *-.|.-~-.           .~    ~
remote:   \     \__/        `/\      /                 ~-. _ .-~      /
remote:    \____(Oo)           *.   }            {                   /
remote:    (    (--)          .----~-.\        \-`                 .~
remote:    //__\\  \ DENIED!  ///.----..<        \             _ -~
remote:   //    \\               ///-._ _ _ _ _ _ _{^ - - - - ~
remote: 
remote: 
remote: This commit was rejected by Herald pre-commit rule H24.
remote: Rule: No Branches Called Blarp
remote: Reason: "blarp" is a bad branch name
remote: 
To ssh://dweller@localhost/diffusion/POEMS/
 ! [remote rejected] blarp -> blarp (pre-receive hook declined)
error: failed to push some refs to 'ssh://dweller@localhost/diffusion/POEMS/'

Here's a transcript, showing that all the field values populate sensibly:

{F90453}

Here's a rule:

{F90454}

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Oops, here's a much better transcript:

{F90457}

Here are some push logs with rejection code 2 (Herald):

{F90460}

This is great, I especially like that you can specify a reason in the rule, and how that shows up in the commit hook.