您的位置:首页 > 编程语言

Phabricator命令行工具Arcanist的基本用法

2017-10-18 10:07 766 查看
Pharicator是FB的代码审查工具,现在我所在的团队也使用它来进行代码质量的控制。其提供了一个differential(code review)命令行工具Arcanist(arc)。

1安装:

1.1,安装PHP5

Pharicator需要php5.6,然而,Ubuntu16自带的是php7,解决方法如下:

https://stackoverflow.com/questions/36788873/package-php5-have-no-installation-candidate-ubuntu-16-04

1.2,安装php-cli

sudo apt-get install php5-cli php5-curl php-pear

如果出现:

       E: 软件包 php5-cli 没有可安装候选

        E: 无法定位软件包 php5-curl

如果出现上面提示 建议:

        sudo add-apt-repository ppa:ondrej/php

        sudo apt-get update

        sudo apt-get install php5.6-curl


1.3,创建phabricator软件存放目录

mkdir ~/phabricator

cd ~/phabricator

1.4,将Arcanist的源码拷贝到本地~/phabricator

~/phabricator
$ git clone git://github.com/facebook/libphutil.git

~/phabricator
$ git clone git://github.com/facebook/arcanist.git

1.5,将arc的路径加入到系统路径中

$ export PATH=$PATH:~/phabricator/arcanist/bin/

2 arc配置

2.1,arc的全局配置 

配置arc的默认编辑器,我使用

vim $ arc set-config editor "vim" 

配置默认的phabricator的uri,uri为团队的phabricator主页的url 

$ arc set-config default http://phabricator.example.com 

2.2,在项目的根目录下建.arcconfig配置文件,文件中至少要填入以下内容

{
"project_id" : "your project name",
"conduit_uri" : "your phabricator url"
}
 举个例子:

{
"project_id" : "HelloWorld",
"conduit_uri" : "http://phabricator.example.com"
}
该配置文件还可以配置静态代码检测引擎(lint)和单元测试引擎。 

2.3,为项目安装证书,用于phabricator的认证。 

yourproject/ $ arc install-certificate
接着按照命令行提示操作就OK了。 

弄完这一步,才能真正在项目中使用arc。


3,在项目中使用arc

arc help [--full | [COMMAND]] 查看帮助文档,接参数--full查看所有命令的详细用法,接具体的命令[COMMAND]如arc help diff可以查看该命令的详细用法。

想phabricator提交review request(Differential).修改完代码后,使用arc diff <path>命令提交review request,该命令会产生一个包含如下内容的文件要求填写:

<<Enter Revision Title>>         

Summary:

Test Plan:

Reviewers:

CC:

Maniphest Tasks:

# NEW DIFFERENTIAL REVISION

# Describe the changes in this new revision.

#

# arc could not identify any existing revision in your working copy.

# If you intended to update an existing revision, use:

#

#   $ arc diff --update <revision>

  按照提示填写后,保存退出,arc就会自动提交request。Reviewers用逗号隔开,Maniphest Tasks填相关联的phabricator上的task_id,如T100。Test
plan暂时没用过,官方文档:http://www.phabricator.com/docs/phabricator/article/Differential_User_Guide_Test_Plans.html

  提交完成后,会产生一个形如http://phabricator.example.com/D24的url,url中的D24是revision_id。

arc diff --update <revision_id>更新对应的review request。该命令产生一个如下的文件,按提示填写保存退出,arc会提交更新。

# Updating D27: hahahah

#

# Enter a brief description of the changes included in this update.

# The first line is used as subject, next lines as comment.

#

# If you intended to create a new revision, use:

#  $ arc diff --create

复制代码

arc commit --revision <revision_id>提交对应提交代码更改,这个命令把svn commit的工作也做掉了,直接提交到代码库。

arc todo <description> [option]可以快速给自己在phabricator上创建task,[option]用于把task CC给其他人.

arc tasks [options] 查看Maniphest的tasks。

arc amend --show 查看当前项目的differentials,arc amend --revision <revision_id> --show 查看指定revision_id的differential。

参考:http://udn.yyuap.com/thread-39791-1-1.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息