gerrit审查系统命令行工具。
git-gerrit的Python项目详细描述
吉特·格瑞特
git gerrit是Gerrit code review system的命令行工具,具有 强调gerrit遗留数字标识符。重物搬完了 使用pygerrit2包访问gerrit rest api。
git gerrit与python 2和python 3兼容。
命令:
git gerrit-query -- search for gerrit numbers git gerrit-fetch -- fetch gerrits by number git gerrit-log -- log oneline with gerrit numbers git gerrit-unpicked -- list gerrit numbers which have not been cherry-picked
安装
使用pip安装:
pip install git-gerrit
要从源代码安装,请克隆git repo并使用提供的 生成文件。如果找到,make将运行pip以安装包并 要求:
git clone https://github.com/meffie/git-gerrit.git cd git-gerrit make install
在本地git配置中设置gerrit主机名和项目名 运行git gerrit命令:
cd <project> git config gerrit.host <gerrit-hostname> git config gerrit.project <gerrit-project>
示例
使用openafs.org gerrit:
$ git config --local gerrit.host gerrit.openafs.org $ git config --local gerrit.project openafs
在主分支上查找打开的gerrits:
$ git gerrit-query -n3 is:open branch:master 13030 redhat: Make separate debuginfo for kmods work with recent rpm 13031 redhat: PACKAGE_VERSION macro no longer exists 13021 autoconf: update curses.m4
查找包含术语“debuginfo”的主题的gerrits:
$ git gerrit-query -n3 debuginfo 13030 redhat: Make separate debuginfo for kmods work with recent rpm 13029 redhat: Create unique debuginfo packages for kmods 12818 redhat: separate debuginfo package for kmod rpm
还显示分支名称:
$ git gerrit-query -n3 --format='{branch:>20s} {_number} {subject}' debuginfo master 13030 redhat: Make separate debuginfo for kmods work with recent rpm openafs-stable-1_6_x 13029 redhat: Create unique debuginfo packages for kmods openafs-stable-1_6_x 12818 redhat: separate debuginfo package for kmod rpm
列出分支上的gerrit主题:
$ git gerrit-query --format='{topic}' status:open branch:master | sort -u | head -n3 afsd-cache-verify AFS-OSD-integration afs_read-EOF
在我需要审阅的主分支上显示Gerrit提交的内容:
$ git gerrit-query branch:master status:open NOT label:Code-Review=-2 NOT reviewer:tycobb@yoyodyne.com ...
按编号提取gerrit:
$ git gerrit-fetch 12977
按编号签出gerrit:
$ git gerrit-fetch --checkout 13000
在当前分支上选择gerrit:
$ git gerrit-fetch --no-branch 13001 && git cherry-pick FETCH_HEAD
在一个已签出的分支中显示gerrit号码:
$ git gerrit-log -n3 12958 f47cb2d Suppress statement not reached warnings under Solaris Studio 12957 306f0f3 afs: squash empty declaration warning 12955 e006609 libafs: git ignore build artifacts on Solaris
按修订显示gerrit编号:
$ git gerrit-log -n3 openafs-stable-1_8_0 12953 a08327f Update NEWS for 1.8.0 final release 12938 acb0e84 afs_pioctl: avoid -Wpointer-sign 12950 b73863b LINUX: fix RedHat 7.5 ENOTDIR issues
按一系列修订显示gerrit编号:
$ git gerrit-log 607eba34d..origin/openafs-stable-1_8_x 13268 554176bd2 LINUX: Update to Linux struct iattr->ia_ctime to timespec64 with 4.18 13266 eb107ed5c Make OpenAFS 1.8.1 13265 8de978420 Update NEWS for 1.8.1
只显示gerrit数字和主题:
$ git gerrit-log -n3 --format='{number}: {subject}' 12958: Suppress statement not reached warnings under Solaris Studio 12957: afs: squash empty declaration warning 12955: libafs: git ignore build artifacts on Solaris
在主分支上显示尚未被选中的提交 马厩的树枝。(GrITIT可能已经存在了。):
$ git gerrit-unpicked -u origin/master origin/openafs-stable-1_8_x 13656 4eeed830fa31b7b8b5487ba619acbc8d30642aaa afscp: Link against opr/roken/hcrypto 13659 f5f59cd8d336b153e2b762bb7afd16e6ab1b1ee2 util: serverLog using memory after free 13665 1210a8d6d96db2d84595d35ef81ec5d176de05e8 LINUX: Run the 'sparse' checker if available ...
使用git别名
常用的查询可以保存为git别名。例如显示 尚未审查的Gerrits:
[alias] # git gerrit-todo [<branch>] [<userid>] gerrit-todo = "!f() { git-gerrit-query \"branch:${1-master} is:open NOT label:Code-Review>=+1,${2-$USER}\"; }; f"
另请参见
有关更完整的git/gerrit工作流工具,请参见git-review项目。