|  | #!/bin/bash | 
|  | # Barret Rhoden (brho@cs.berkeley.edu) | 
|  | # Copyright 2016 Google Inc | 
|  | # | 
|  | # Tracks a gerrit branch and runs checkpatch on the commits from the | 
|  | # merge point of master to the tip of the branch. | 
|  |  | 
|  | PATCHDIR="${PATCHDIR:-../patches}" | 
|  |  | 
|  | usage() | 
|  | { | 
|  | echo "$0 <gerrit-number> <local-branch-name>" | 
|  | exit -1 | 
|  | } | 
|  |  | 
|  | if [ $# -lt 2 ] | 
|  | then | 
|  | usage | 
|  | fi | 
|  |  | 
|  | if [ ! -f ./scripts/checkpatch.pl ] | 
|  | then | 
|  | echo "Run from the root of the Akaros repo" | 
|  | exit -1 | 
|  | fi | 
|  |  | 
|  | git gerrit-track $1 $2 | 
|  |  | 
|  | if [ $? -ne 0 ] | 
|  | then | 
|  | exit -1 | 
|  | fi | 
|  |  | 
|  | FROM=`git merge-base master $2` | 
|  |  | 
|  | if [ $? -ne 0 ] | 
|  | then | 
|  | echo "From failed; $FROM" | 
|  | exit -1 | 
|  | fi | 
|  |  | 
|  | ls $PATCHDIR/*.patch 2>/dev/null | 
|  |  | 
|  | if [ $? -eq 0 ] | 
|  | then | 
|  | echo "$PATCHDIR has patches, remove and try again" | 
|  | exit -1 | 
|  | fi | 
|  |  | 
|  | git format-patch -k -M -N -o $PATCHDIR $FROM..$2 | 
|  |  | 
|  | ./scripts/checkpatch.pl $PATCHDIR/* |