Search code examples
phabricator

Phabricator restrict git push


I want my team including myself to review commits of each other. None of commits should be pushed including mine into repo until it's not audited by other team member. I kind of lost in phabricator documentation, so i'm asking here, is there any way to setup that kind of workflow?


Solution

  • You can only restrict pushes to repositories hosted by Phabricator. If your repository is hosted elsewhere (like GitHub), Phabricator obviously can't prevent users from pushing to it.

    To restrict pushes, create a new Herald rule (in the Herald application), like this:

    • Create a new "Commit Hook: Commit Content" rule.
    • Select "Global" as the rule type.

    Then configure the rule like this:

    When [all of] these conditions are met:
      [Accepted Differential revision][does not exist]
    Take these actions every time this rule matches:
      [Block change with message][Review is required for all changes.]
    

    You may want to use additional conditions like this, to run the rule only in certain repositories:

    [Repository][is any of][ ... list of review-requied repositories ... ]
    

    Or a condition like this, to let users bypass the rule by writing some string like "@bypass-review" in a message in an emergency:

    [Body][does not contain][@bypass-review]
    

    If you add a bypass like this, you can mention it in the rejection message.