Phabricator是一个代码审查管理,Arcanist是Phabricator配套的Code Review工具,需要配合本地git使用。
安装环境:
确认PHP是否已经安装
Mac OS X应该已经默认安装了PHP环境。在终端中输入php -v检查是否已安装了PHP环境。
liuhaihua@liuhaihuadeMacBook-Pro jwordpress % php -v
PHP 7.3.11 (cli) (built: Dec 13 2019 19:21:21) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
安装Arcanist在计划安装目录签出Arcanist代码仓库
git clone https://github.com/phacility/libphutil.git
git clone https://github.com/phacility/arcanist.git
配置arc的环境变量
输入
cd ~
输入命令行:
open -e .bash_profile
会自动弹出 .bash_profile 文件的编辑窗口,在配置文件的末尾加上这一句
export PATH=${PATH}:/路径/arcanist/bin/
输入命令行:source .bash_profile 更新更配置的环境变量。 然后输入命令:arc –help 查看配置是否成功。
配置项目
打开终端,切换到项目所在目录,运行arc install-certificate,按提示添加访问token
liuhaihua@liuhaihuadeMacBook-Pro JWordpress % arc diff
Usage Exception: This command requires arc to connect to a Phabricator install, but no
Phabricator installation is configured. To configure a Phabricator URI:
- set a default location with `arc set-config default <uri>`; or
- specify `--conduit-uri=uri` explicitly; or
- run `arc` in a working copy with an '.arcconfig'.
liuhaihua@liuhaihuadeMacBook-Pro JWordpress % vi .arcconfig
liuhaihua@liuhaihuadeMacBook-Pro JWordpress % arc diff
Usage Exception: YOU NEED TO AUTHENTICATE TO CONTINUE
You are trying to connect to a server (phabricator.59et.com) that you do not have any credentials stored for.
To retrieve and store credentials for this server, run this command:
$ arc install-certificate
liuhaihua@liuhaihuadeMacBook-Pro JWordpress % arc install-certificate
CONNECT Connecting to "http://phabricator.59et.com/api/"...
LOGIN TO PHABRICATOR
Open this page in your browser and login to Phabricator if necessary:
http://phabricator.59et.com/conduit/login/
Then paste the API Token on that page below.
Paste API Token from that page: xxxxxxxxxxxxxxx
Writing ~/.arcrc...
SUCCESS! API Token installed.
代码审查流程
在本地独立开发分支提交改动代码。有对应的Manifest Task时,改动需要在同名分支下提交。 执行arc diff。第一次执行时需要配置默认的比较目标,默认为origin/master,可以按需修改为origin/develop,或执行arc diff [分支名]来显示指定 在弹出的文本编辑器中填写Title、Summary和Reviewer,保存并关闭 等待审查通过,如果审查失败的话,可修改代码并重新执行arc diff 如果审查通过,制定arc land –onto=分支名合并代码并提交,提交后开发分支将被删除
liuhaihua@liuhaihuadeMacBook-Pro JWordpress % arc land
Landing current branch 'master'.
TARGET Landing onto "master", selected by following tracking branches upstream to the closest remote.
REMOTE Using remote "origin", selected by following tracking branches upstream to the closest remote.
You have untracked files in this working copy.
Working copy: /Users/liuhaihua/IdeaProjects/JWordpress/
Untracked changes in working copy:
(To ignore these 1 change(s), add them to ".git/info/exclude".)
.arcconfig
Ignore these 1 untracked file(s) and continue? [y/N] y
FETCH Fetching "origin/master"...
These 1 commit(s) will be landed:
- d5d296e 测试arc Enter a commit message.
Landing revision 'D1: 测试arc Enter a commit message.'...
BUILDS Checking build status...
PUSHING Pushing changes to "origin/master".
Counting objects: 133, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (132/132), done.
Writing objects: 100% (133/133), 15.43 KiB | 3.86 MiB/s, done.
Total 133 (delta 114), reused 0 (delta 0)
remote: Resolving deltas: 100% (114/114), completed with 2 local objects.
remote: Powered by GITEE.COM [GNK-3.8]
To https://gitee.com/jxuasea/JWordpress.git
流程
git checkout -b featurexxx — 创建一个新分支,并修改代码 git add . && git commit -m tt — 将该提交的都提交上去 arc diff [lastcommit]此命令会将 lastcommit 到最新的 commit 之间的改动的所有代码发送到phabricator 平台,并创建一个 revision;如果没有指定 lastcommit,则会使用 master 分支来作为 lastcommit 的起点。运行命令后会弹出一个编辑面板,在此面板中你需要指定 reviewers,即指定一个或多个给你 review code 的人 如果指定了多个reviewers,则其中任何一个 review 通过就可以,不用全部 review 通过 另外编辑面板中也有一个 test plan 选项,国外人一般每个项目都有测试,所以此项是必填的,如果没有测试,我们只需要随便设置一个字段即可,比如设置成 no 或 skip如果觉得指派reviewer的用法不太方便,可以执行arc diff –preview根据生成的diff页面进入配置,生成revision. 以上操作之后,系统会发送邮件通知 reviewers 去 review 你的代码,你也可以通过 arc list 来查看当前 review 的状态 如果 review 没有通过,你需要在原来的基础上修改,修改完并 commit 之后需要执行 arc diff [lastcommit] –update D(id) 继续 review
目前100000+人已关注加入我们