git的代码review工具

facebook在GitHub上托管了大量的开源项目,足足有26个。其中hiphop-php以及xhp在这阵子炒的比较热,的确是让人印象深刻的东西。顺手把别的项目翻出来看,也有很实用的工具,比如git-review

git-review为git新增了一个很方便的代码review途径,利用这个命令,可以调用别的工具比如vimdiff来review代码的改动。下面简单记录一下使用的过程:

下载并安装

首先确认已经装好了git,剩下的事情比较简单。


git clone git://github.com/facebook/git-review.git
cd git-review
python setup.py install

这几步为git新增了一个review命令。

git-review的使用

查看指定版本的改动


git review 58e2fb834793f5c6c1fdd900a1c0224a44735962

出现提示

Now processing modified file foo.php
foo.php [diff]>

由于我配置了diff工具为vimdiff,所以接下来就可以用vimdiff查看foo.php在58e2fb834793f5c6c1fdd900a1c0224a44735962这个版本与最新版本之间有什么不同。

查看两个版本之间的改动


git review 5b744bdc5f5bcbcfd6bb65f815aebe6bdce8c427 58e2fb834793f5c6c1fdd900a1c0224a44735962

在review每个代码之前,都可以使用help查看git review命令的帮助,如果放弃review,那么直接敲退出就可以了。

3 Replies to “git的代码review工具”

  1. Traceback (most recent call last):
    File “C:\Python27\Scripts\git-review”, line 42, in
    import gitreview.review as review
    File “C:\Python27\lib\site-packages\gitreview\review\__init__.py”, line 23, in
    import cli_reviewer
    File “C:\Python27\lib\site-packages\gitreview\review\cli_reviewer.py”, line 20, in
    import gitreview.cli as cli
    File “C:\Python27\lib\site-packages\gitreview\cli\__init__.py”, line 17, in
    import readline
    ImportError: No module named readline

    我在win7下,python 2.7,貌似没有readline的?
    pip install readline 也报不支持WIN系统?

  2. 呃,好不容易找到了readline
    Traceback (most recent call last):
    File “C:\Python27\Scripts\git-review”, line 178, in
    sys.exit(main(sys.argv))
    File “C:\Python27\Scripts\git-review”, line 169, in main
    working_dir=options.workTree)
    File “C:\Python27\lib\site-packages\gitreview\git\__init__.py”, line 142, in get_repo
    git_config = config.load(git_dir)
    File “C:\Python27\lib\site-packages\gitreview\git\config.py”, line 110, in load
    return _load(where)
    File “C:\Python27\lib\site-packages\gitreview\git\config.py”, line 102, in _load
    cmd_out = proc.run_simple_cmd(cmd)
    File “C:\Python27\lib\site-packages\gitreview\proc.py”, line 170, in run_simple_cmd
    stdout=stdout)
    File “C:\Python27\lib\site-packages\gitreview\proc.py”, line 152, in run_cmd
    stderr=stderr)
    File “C:\Python27\lib\site-packages\gitreview\proc.py”, line 122, in popen_cmd
    stdin = file(stdin, ‘r’)
    IOError: [Errno 2] No such file or directory: ‘/dev/null’

Leave a Reply

Your email address will not be published.