Page MenuHomePhabricator

Add Herald support for blocking ref changes
ClosedPublic

Authored by epriestley on Dec 17 2013, 10:05 PM.
Tags
None
Referenced Files
F13324187: D7782.diff
Fri, Jun 14, 11:02 PM
F13310496: D7782.diff
Mon, Jun 10, 2:13 PM
F13301285: D7782.id.diff
Fri, Jun 7, 5:19 PM
F13301227: D7782.diff
Fri, Jun 7, 4:45 PM
F13277121: D7782.diff
Fri, May 31, 8:30 AM
F13265901: D7782.diff
Tue, May 28, 7:06 AM
F13262747: D7782.id17605.diff
Mon, May 27, 3:14 AM
F13246583: D7782.diff
Thu, May 23, 11:43 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

Branch
cherald3
Lint
No Lint Coverage
Unit
No Test Coverage

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.