Phabricator restrict git push

血红的双手。 提交于 2019-11-28 06:33:08

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.

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!