Installation and use of phabricator (code review) client

Time:2022-5-8

Phabricator is an open-source visual code review tool for Facebook. It integrates a series of open-source Web applications, including code review, code (GIT / SVN) hosting, syntax check, unit test, Wiki and other functions. It can also track bugs and directly associate JIRA with code review. It supports two code review workflows: “review” (review before submission) and “audit” (review after submission).

1、 Client environment installation

1. Install PHP

PHP comes with MAC without installation; Under Windows environment, Download PHP package from the official website:http://www.php.net/downloads.php, put the PHP directory directly into the D: \ root directory

2. Install arcanist and the dependent library libphutil:

Under Mac, enter / Applications (windows in D: \ root directory), create a new phabricator folder, and then download it in its directory:

$  git clone git://github.com/facebook/arcanist.git
$  git clone git://github.com/facebook/libphutil.git

3. Setting environment variables

Add the following two paths to the path variable of the system variable (non user variable) (remember to separate win7 and the following with; in the middle):

D:\php
D:\Phabricator\arcanist\bin

Under Mac, run:

export PATH="$PATH:/Applications/Phabricator/arcanist/bin"

4. Testing

Add the following two paths to the path variable of the system variable (non user variable) (remember to separate win7 and the following with; in the middle):

$PHP - V # test whether PHP is successfully installed
$arc help # tests whether arc is successfully installed

2、 Code review tool usage

1. Registered account

The browser opens the phabricator code review URL:http://192.168.4.28: 9080 /, register an account. The rules are as follows:

Phabricator usernamerequired: gaoyy # surname + initials, unified rules, easy to remember reviewer
Real name required: Gao Yuanyuan's # real Chinese name
Email:  [email protected] #Real and available email is used to receive various audit messages

2. Initialize authentication

Enter the root directory of the project, such as e: XXX front. When running arc diff for the first time, you will be prompted to install the certificate. Run according to the prompt. If not prompted, go to step 3, arc related configuration.

$ arc install-certificate

Open the page according to the prompt (if there is no prompt, it means that the. Arcconfig configuration file is missing under the project)http://192.168.4.28: 9080 / conduct / login /, after logging in the account, copy the API token value, come back and paste the prompt, and press enter to complete the certificate installation.

3. Arc related configuration

a. ) project profile

There are at the root of the project Arcconfig configuration file can directly configure code review URL, editor and other information. This file will be added to git version control, so you don’t need to add it yourself.

{
  "phabricator.uri" : "http://192.168.4.28:9080/",
  "editor" : "vim"
}

b. ) setting up the arc editor

If the arc diff prompt does not set the editor, you can set it through the following methods:

$arc set config editor "VIM" # default VI as editor
#Or
$ arc set-config editor "\"D:\Program Files\Sublime Text\sublime_ text. Exe \ "- W" # using sublime text

4. Code review preview process

The following is the preview process of approval before submission:

a. ) local submission code

$ git add .
$git CI - am '* [CPS BK] submit information'

b. ) submit for review

Run arc diff, add reviewers in the reviewers item in the pop-up VI editing window, separate multiple reviewers with commas, save and exit, generate an audit URL, copy it to the reviewer or ask the reviewer to check the email to complete the audit

$ arc diff

If you fail to pass the review and need to modify, or you forget something before and want to modify again, you can submit it locally according to step a.) and then run it

$arc diff -- update D (n) # update the previous audit and initiate submission again

c. ) after passing the review, run the following command to complete the submission

$arc land # has included the action of GIT push, so there is no need to submit again

5. Code review audit process

The following is the audit process of submitting first and then approving (the same as the normal submission process, just add the Auditors: XXX field in the line feed of the submission information):

$ git ci '
>* [Vue] submit information
> 
> Auditors: xxx
> '

Or commit first and then modify the line feed with git CI — amend to add the field Auditors: XXX.

6. Common commands

$arc help # get available instructions / tools packaged in arc
$arc diff # submit code for review
$arc diff -- update D (n) # failed to pass the review, and submit it for review again after modification
$arc diff -- create # creates a new submit audit
Submitted after $arc land # approval, GIT push action has been included, so there is no need to push again
$arc amend # reviews git update submitted information
$arc list # displays code information that has not been submitted for modification
$arc lint # checks the syntax of the code
$arc get config # view the configuration that has been set
$arc set config < key > < value > # modify the configuration and use the -- local parameter for global configuration

Official reference:https://secure.phabricator.co…