CodeReview Tools

Code Review Tools


Here is a sample of a configuration snippet for use with vim:

function! CommitMessages()
    let g:git_ci_msg_user = substitute(system("git config --get"), '\n$', '', '')
    let g:git_ci_msg_email = substitute(system("git config --get"), '\n$', '', '')

    nmap S oSigned-off-by: <C-R>=printf("%s <%s>", g:git_ci_msg_user, g:git_ci_msg_email)<CR><CR><ESC>
    nmap R oReviewed-by: <C-R>=printf("%s <%s>", g:git_ci_msg_user, g:git_ci_msg_email)<CR><ESC>
    iab #S Signed-off-by: <C-R>=printf("%s <%s>", g:git_ci_msg_user, g:git_ci_msg_email)<CR>
    iab #R Reviewed-by: <C-R>=printf("%s <%s>", g:git_ci_msg_user, g:git_ci_msg_email)<CR>
    iab #O Signed-off-by:
    iab #V Reviewed-by:
    iab #P Pair-Programmed-With:
    iab ME <C-R>=printf("%s <%s>", g:git_ci_msg_user, g:git_ci_msg_email)<CR>
    iab ASN Andreas<SPACE>Schneider<SPACE><>
    iab AB Alexander<SPACE>Bokovoy<SPACE><>
    iab OBNOX Michael<SPACE>Adam<SPACE><>
    iab VL Volker<SPACE>Lendecke<SPACE><>
    iab METZE Stefan<SPACE>Metzmacher<SPACE><>
    iab GD Guenther<SPACE>Deschner<SPACE><>
    iab JRA Jeremy<SPACE>Allison<SPACE><>
    iab JHROZEK Jakub<SPACE>Hrozek<SPACE><>
    iab ARIS Aris<SPACE>Adamantiadis<SPACE><>
autocmd BufWinEnter COMMIT_EDITMSG,*.diff,*.patch,*.patches.txt call CommitMessages()


Here are a few git aliases for code review:

  author   = !"SEARCH=${@:-`git config`}; set --; git log --format='%aN <%aE>' | uniq | grep -m 1 \"$SEARCH\""
  authors  = !"SEARCH=${@:-`git config`}; set --; git log --format='%aN <%aE>' | grep \"$SEARCH\" | uniq | awk '!a[$0]++'"
  reviewed = !"BRANCH=${1:-master}; shift; AUTHORS=\"~/\"; for A in \"${@:-`git config`}\"; do AUTHORS=$AUTHORS\" \\\"`git author $A`\\\"\"; done; set --; git rebase -i -x \"$AUTHORS\" $BRANCH"
git author [<search>]
Search for the latest author tag (a string in the format of "Full Name <>") matching a given search term. If no <search> is provided, return the latest author tag that uses the current value of "git config".
git authors [<search>]
Similar to "git author", except returns all author tags that match the search term. Useful in cases where a particular author has multiple e-mail addresses or multiple spellings to their name.
git reviewed [<branch> [<author> ...]]
Run a "git rebase -i <branch>" command that is configured to insert Reviewed-by tags for every <author> listed. <author> must be a search term as used in "git author" above. If no <author> is provided, uses the value of "git config". If no <branch> is provided, "master" is used.
NOTE: <branch> is expected as the first argument, if it exists at all, as such it must be specified before any <author> parameter.
NOTE: This alias requires the user to have the script (see below) saved in their home directory and set executable. If you save the script to a different location, modify the above alias so that "~/" is changed to the location of the script.


# <AUTHOR> ...
# A git utility script to append review tags to the current commit's message
# Each tag takes the format of "Reviewed-by: <AUTHOR>". Each parameter to this
# script is treated as a separate <AUTHOR> which will have its own tag.
# Each <AUTHOR> is taken as a literal string, so if <AUTHOR> has spaces be
# sure to enclose it in double quotes.

if [[ $# -eq 0 ]] ; then
  echo "ERROR: Must provide at least one author."
  exit 1


while [[ $# -gt 0 ]]; do


MSG=$(git log -1 --pretty=%B)

for AUTHOR in "${AUTHORS[@]}"; do
  RB="Reviewed-by: "$AUTHOR
  if !(echo -e "$MSG" | grep -qs "^$RB"); then

if [ -n "$TAGS" ]; then
  echo "$MSG" > $MSG_FILE
  sed -i "\$a$TAGS" $MSG_FILE
  git commit --amend -F $MSG_FILE --cleanup=strip


tig is a text-based, vim-like interface/browser for use with git. It is also fairly extensible. The following is a simple example of a tig configuration file (~/.tigrc) that triggers 'git reviewed' against the currently selected branch HEAD in the refs view when the user enters 4. This rebases the current checked-out branch against the selected branch and marks all rebased commits as Reviewed-by for the author:

bind refs 4     !git reviewed %(branch)

git-review-by and git-review-by-me

Both these scripts require the git_review.msg-filter.awk AWK script and require GNU awk as awk.

These scripts operate on a the set of patches since origin/master adding Reviewed-By to all Signed-Off-By commits. The git-review-by-me script does a rebase and build first to avoid embarrassment.