2013年5月7日 星期二

Show progress during dd copy

tty 1
$ dd if=/dev/random of=/dev/null bs=1K count=100
0+14 records in
0+14 records out
204 bytes (204 B) copied, 24.92 seconds, 0.0 kB/s
 
 
tty 2 
$ pgrep -l '^dd$'
 
8789 dd 
$ kill -USR1 8789


$ watch -n 10 kill -USR1 8789




Reference :
Linux Commando: Show progress during dd copy

2013年5月6日 星期一

Gerrit auto publish and submit

$ ssh -p 29418 yan@yanxen.no-ip.org gerrit query --format JSON --current-patch-set status:open label:V=1 label:R=2 project:RWS_System

# ssh -p 29418 admin@yanxen.no-ip.org gerrit review --submit 9a48b3f46c6ddf6bbdcbe23c349802f6916bf5d1


// run after jenkins build and add comment
$ vi /home/gerrit/review_sites/hooks/comment-added
#!/usr/bin/python

# auto submit after jenkins verified
# for Gerrit 2.5

import json, sys
from subprocess import Popen, PIPE

username = "jenkins"
server = "localhost"

verified_min = 1
reviewed_min = 2

results = Popen([
"ssh", "-p", "29418", username+"@"+server, "gerrit", "query",
"--format", "JSON", "--current-patch-set", "--commit-message",
"--files" , "status:open", "label:V="+str(verified_min), "label:R="+str(reviewed_min)], stdout=PIPE).communicate()[0]

parsed = json.loads(results.split("\n")[0])

if parsed:
    commit = parsed['currentPatchSet']['revision']
    results = Popen([
"ssh", "-p", "29418", username+"@"+server,
"gerrit", "review", "--submit", commit], stdout=PIPE).communicate()[0]




Reference :
From blue skies and oceans — Configuring Gerrit to auto-submit on patch approval

2013年5月2日 星期四

run script after git clone

$ mkdir -p ~/.git/hooks

$ vi ~/.git/hooks/post-checkout
#!/bin/sh                                                                                                                    


echo "Project : $0"
echo "Working on `pwd` ..."

git config remote.origin.push refs/heads/*:refs/for/*


echo "Get Hooks ..."

HOOK_DIR='.git/hooks'

echo "  - commit-msg"
wget -P $HOOK_DIR -q http://yanxen.no-ip.org:8081/tools/hooks/commit-msg

chmod u+x -R $HOOK_DIR

$ chmod u+x -R ~/.git/hooks

$ git clone --template=/home/user/.git ssh://user@gerrit.server:29418/my_project

git-review for Gerrit

$ cd my_project

$ vi .gitreview
[gerrit]
host=gerrit.server
port=29418
project=my_project

$ git review -s

$ echo hello > world
 
$ git add world

$ git commit -m 'hello world'
 
$ git review  // 代替 git push





Reference :
gerrit with jenkins : installation and configuration | Loïc Dachary


Further:
隨手誌: git push到gerrit review server的方法與設定

2013年5月1日 星期三

missing Change-Id in commit message

下載生成 Change-Id 的 hook
$ scp -p -P 29418 user@gerrit.server:hooks/commit-msg .git/hooks/

or 

$ cd .git/hooks ; wget http://gerrit.server:8081/tools/hooks/commit-msg ; chmod u+x commit-msg


重新 commit
$ git commit --amend




Reference :
missing Change-Id in commit message
git - Gerrit error when Change-Id in commit messages are missing - Stack Overflow

Gerrit query verified

command :
$ ssh -p 29418 yan@gerrit.server gerrit query --format JSON --current-patch-set --commit-message --files status:open label:V=1 label:R=2

http :
http://gerrit.server/#/q/is:open+Verified>=1+-Verified<=-1+CodeReview>=1+-CodeReview<=-1+branch:master+reviewer:green+age:3d,n,z


Reference :
Gerrit Code Review - Searching Changes
gerrit query

Useful Gerrit Searches - HPDD Community Space - HPDD Community Wiki