Review board 和 Git 配合使用 三

现在看看Review board推荐的post-review工具。该工具可以简化工作,上一节的描述中一般都要自己生成一个diff文件,然后上传到网站上,发起一个请求。

post-review 可以简化这种工作。

文档可以参考:http://www.reviewboard.org/docs/manual/1.6/users/tools/post-review/

在Ubuntu上可以执行

easy_install -U RBTools

很轻松的安装该工具。

还要进行一些配置,

下面是设置Review board的站点url

git config reviewboard.url http://battleship

然后在maventest目录下使用该命令

post-review --parent=origin/master -n

-n 参数指的是将diff结果显示在终端,但是并不发送请求给Review board server,因此可以用来测试diff的结果

--parent=origin/master 指的是将当前代码和git服务器上的代码进行diff

如果用--parent=master 指的是将当前代码和本地git仓库里面的代码进行diff

还有一些比较有用的参数:

-p 参数指的是直接发布该review,如果不用则在Review board上发布为草稿,然后手动发布

--username和--passwor指定发布人的用户名和密码

-g 猜测的方式自动填写summary和description

让我们试一下这个命令:

post-review --parent=origin/master --username=c1 --password=123456 --summary="`cat $1`" --guess-description post-review --parent=origin/master --target-group=AGOLReview -p
Review request #43 posted.

http://battleship/r/43/
发送请求成功。

让我们继续进一步,在git hook里面执行这个命令

我希望当运行git commit 的时候(不带任何参数),会自动发送该请求。

在.git/hooks目录下,创建prepare-commit-msg文件,(可以从sample复制过来),删除其他命令,加上这行代码:

#!/bin/sh
#
post-review --parent=origin/master --username=c1 --password=123456 --summary="`cat $1`" --guess-description post-review --parent=origin/master --target-group=AGOLReview -p

运行 git commit -am'your comments' 吧,结果果如预期。

windows下安装post-review 可以参考别人的blog:

http://blog.csdn.net/tzleo/article/details/6873980

注意hooks/prepare-commit-msg脚本和Linux不同之处在于前面有变化:

exec C:/Python27/Scripts/post-review 

注意:

1.要用/ 而不是\

2.必须下载python2.x系列,不能安装3.x版本。

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

猜你喜欢

转载自www.cnblogs.com/skiwnywh/p/10321287.html