Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phabricator restrict git push

Tags:

phabricator

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?

like image 602
message Avatar asked Sep 04 '14 10:09

message


2 Answers

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.

like image 147
Evan Priestley Avatar answered Nov 08 '22 18:11

Evan Priestley


It seems that you want a Pre-Commit Code Review. We set this up by doing the following (we use Git repos. If you use some other type, these steps may be different):

  1. Setup a Herald rule
    • New rule for: Commit Hook: Commit Content
    • If you only want one repo, you can use Rule Type: Object, however, we used Global
    • For the conditions: we selected Accepted Differential revision and does not exist
    • Action: Block Change with message For the message, we refer them to an article that walks them through using Arcanist
  2. Each project will need a .arcconfig with at least this line: { "phabricator.uri": "http://your.phabricator.url" }
  3. Day-day developers are going to have to use arcanist.
    • Developer creates a local branch.
    • Changes and commits code to the local branch.
    • When finished, run arc diff [base_branch_name]
    • This will create a Differential revision that will allow another developer to code review.
    • If changes are needed, the developer checks out his local branch, makes changes, makes commits, and re-runs arc diff [base_branch_name] to update the diff.
    • After all revisions are done, run arc land [local_branch_name] --onto [base_branch_name]

I hope this helps. Also, Phabricator developers hangout in freenode.net IRC channel called #phabricator. Come join the community; they have always been very helpful for me.

like image 35
CEPA Avatar answered Nov 08 '22 17:11

CEPA