2011年10月16日 星期日

repo forall

repo這個小script是sync Android code base必備的玩意
通常比較常用的指令會是repo init用以設定repo database
還有repo sync用以synchronize database

但是最近愛上了repo forall這個指令
我的工作常常需要在同一個database下進行branch的跳躍
但是呢
一但有稍微改一些測試codes或者安插printk或者logcat message後
要進行branch的跳躍就會遇到有尚未committed changes的error
此時打一行repo forall -c 'git checkout -f'
就可以自動在數百個git projects目錄下跑git checkout -f的指令
非常地方便
以下附上一些可以加在' '裏頭跑的變數
讓整個操作更加多元

Environment
-----------
pwd is the project's working directory. If the current client is a
mirror client, then pwd is the Git repository.

REPO_PROJECT is set to the unique name of the project.
REPO_PATH is the path relative the the root of the client.
REPO_REMOTE is the name of the remote system from the manifest.
REPO_LREV is the name of the revision from the manifest, translated to a
local tracking branch. If you need to pass the manifest revision to a
locally executed git command, use REPO_LREV.
REPO_RREV is the name of the revision from the manifest, exactly as
written in the manifest.
shell positional arguments ($1, $2, .., $#) are set to any arguments
following .
Unless -p is used, stdin, stdout, stderr are inherited from the terminal
and are not redirected.