在Sun/Oracle工作了N(>12)年后,对webrev工具甚为喜欢,因为其易用性确实非常好。幸运的是,有工程师将webrev工具放到了GitHub上,而且支持git。 下面给出使用webrev工具创建代码比对网页的全过程。 当然,首先得保证代码管理工具git在Linux(我用的是Ubuntu14.04)上已经就位和已经安装了ksh,因为webrev工具是基于ksh实现的。
第1步: Clone webrev from
veli$ cd /var/tmpveli$ git clone https://github.com/joyent/webrev.gitCloning into 'webrev'...remote: Counting objects: 27, done.remote: Total 27 (delta 0), reused 0 (delta 0), pack-reused 27Unpacking objects: 100% (27/27), done.Checking connectivity... done.veli$ tree webrevwebrev├── bin│ ├── wdiff│ ├── webrev│ └── which_scm├── etc│ ├── its.conf│ └── its.reg└── README.md
第2步: Add webrev/bin to PATH
veli$ export PATH=/var/tmp/webrev/bin:$PATHveli$ type webrevwebrev is /var/tmp/webrev/bin/webrev
第3步: Set up apache2
veli$ sudo apt-get install apache2veli$ sudo service apache2 statusveli$ cd /var/www/html && sudo ln -s /var/tmp tveli$ sudo vim /etc/apache2/apache2.conf # add "ServerName localhost:80"veli$ sudo service apache2 restart
第4步: clone my source code and update something
veli$ git clone https://github.com/idorax/vCodeHub.gitCloning into 'vCodeHub'...remote: Counting objects: 359, done.remote: Compressing objects: 100% (100/100), done.remote: Total 359 (delta 58), reused 0 (delta 0), pack-reused 254Receiving objects: 100% (359/359), 7.85 MiB | 1.61 MiB/s, done.Resolving deltas: 100% (164/164), done.Checking connectivity... done.
Now update a file,
veli$ cd /var/tmp/sandbox/vCodeHub/sharpsword/cveli$ vi sudorax.c
第5步: commit changes
veli$ git commit -a 1 05/14/2017: demo to use webrev 2 # Please enter the commit message for your changes. Lines starting 3 # with '#' will be ignored, and an empty message aborts the commit. 4 # On branch master 5 # Your branch is up-to-date with 'origin/master'. 6 # 7 # Changes to be committed: 8 # modified: sudorax.c 9 #veli$ git showcommit eb08966d562c03abbe538615a60b0ba648c9cadfAuthor: Vector LiDate: Sun May 14 11:29:11 2017 +0800 05/14/2017: demo to use webrevdiff --git a/sharpsword/c/sudorax.c b/sharpsword/c/sudorax.cindex 3f334c5..4645870 100644--- a/sharpsword/c/sudorax.c+++ b/sharpsword/c/sudorax.c@@ -46,12 +46,9 @@ typedef unsigned long uint32_t; static uint64_t power(int32_t n, uint32_t m) {- uint32_t i; uint64_t sum = 1;-- for (i = 0; i < m; i++)+ for (uint32_t i = 0; i < m; i++) sum *= n;- return sum; }
第6步: create webrev
veli$ webrevWARNING: codereview(1) not found. SCM detected: git File list from: git ... Done. Workspace: /var/tmp/sandbox/vCodeHub (at eb08966d562c)Compare against: origin/master (https://github.com/idorax/vCodeHub.git at c64cf7c91ba6) Output to: /var/tmp/sandbox/webrev Output Files: sharpsword/c/sudorax.c patch cdiffs udiffs wdiffs sdiffs frames old new Generating PDF: Skipped: no output available index.html: Done.
第7步: 在firefox里访问webrev
veli$ egrep '127.0.0.1' /etc/hosts127.0.0.1 localhost127.0.0.1 idorax
于是访问 http://idorax/t/sandbox/webrev
多么熟悉的web页面,终于出现了! Thank opensolaris, thank ! 点击Frames,
多么熟悉的代码比对页面,倍感亲切呀:-)
结束语: 能在家里的Linux上用上webrev,实在是太幸福了!归根结底就一句话, 感谢opensolaris, 感谢illumos!