天天看點

**代碼審查:Phabricator指令行工具Arcanist的基本用法

Phabricator入門手冊

http://www.oschina.net/question/191440_125562

Pharicator是FB的代碼審查工具,現在我所在的團隊也使用它來進行代碼品質的控制。其提供了一個differential(code review)指令行工具Arcanist(arc)。本文僅從本人的日常使用中總結出Arcanist比較常用的用法做個簡單介紹。

  環境說明

OS: OS X Mountail Lion

SCV: svn

IDE: Eclipse

  安裝

将Arcanist的源碼拷貝到本地

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

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

複制代碼

将arc的路徑加入到系統路徑中

$ export PATH=$PATH:/somewhere/arcanist/bin/

  或在系統的profile或是bash(如果用bash)的配置檔案的末尾加上這一句。

指令行中輸入arc看提示确認是否安裝成功。

  arc配置

arc的全局配置

  配置arc的預設編輯器,我使用vim

$ arc set-config editor "vim"

  配置預設的phabricator的uri,uri為團隊的phabricator首頁的url

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

在項目的根目錄下建.arcconfig配置檔案,檔案中至少要填入以下内容

{

  "project_id" : "your project name",

  "conduit_uri" : "your phabricator url"

}

  舉個例子:

  "project_id" : "HelloWorld",

  "conduit_uri" : "http://phabricator.example.com"

  該配置檔案還可以配置靜态代碼檢測引擎(lint)和單元測試引擎。

為項目安裝證書,用于phabricator的認證。

yourproject/ $ arc install-certificate

  接着按照指令行提示操作就OK了。

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

  在項目中使用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 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。

  Reference:

如何聯系我:【萬裡虎】www.bravetiger.cn

【QQ】3396726884 (咨詢問題100元起,幫助解決問題500元起)

【部落格】http://www.cnblogs.com/kenshinobiy/

繼續閱讀