akaros/scripts/git/git-track-review
<<
>>
Prefs
   1#!/bin/bash
   2# Barret Rhoden (brho@cs.berkeley.edu)
   3# Copyright 2016 Google Inc
   4#
   5# Tracks a remote branch and runs checkpatch on the commits from the merge
   6# point of master to the tip of the remote branch.
   7
   8PATCHDIR="${PATCHDIR:-../patches}"
   9
  10usage()
  11{
  12        echo "$0 <remote>/<branch> [<url>]"
  13        exit -1
  14}
  15
  16if [ $# -lt 1 ]
  17then
  18        usage
  19fi
  20
  21if [ ! -f ./scripts/checkpatch.pl ]
  22then
  23        echo "Run from the root of the Akaros repo"
  24        exit -1
  25fi
  26
  27REMOTE=`echo $1 | cut -f 1 -d '/'`
  28TO=`echo $1 | cut -f 2- -d '/'`
  29
  30git track $REMOTE/$TO $2
  31
  32if [ $? -ne 0 ]
  33then
  34        exit -1
  35fi
  36
  37FROM=`git merge-base master $REMOTE/$TO`
  38
  39if [ $? -ne 0 ]
  40then
  41        echo "From failed; $FROM"
  42        exit -1
  43fi
  44
  45ls $PATCHDIR/*.patch 2>/dev/null
  46
  47if [ $? -eq 0 ]
  48then
  49        echo "$PATCHDIR has patches, remove and try again"
  50        exit -1
  51fi
  52
  53git format-patch -k -M -N -o $PATCHDIR $FROM..$REMOTE/$TO
  54
  55./scripts/checkpatch.pl $PATCHDIR/*
  56