Skip to content

Instantly share code, notes, and snippets.

@encukou
Created November 13, 2012 09:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save encukou/4064764 to your computer and use it in GitHub Desktop.
Save encukou/4064764 to your computer and use it in GitHub Desktop.
get patches from remote repo, name them according to freeipa guidelines
#! /bin/bash
export project=freeipa
export username=pviktori
export localrepo=~/dev/freeipa
export patchdir=~/patches/in
export remote=vm081
# Usage: getpatch <patchnumber> [num_patches]
#
# Fetch the HEAD from $remote, then format the last <num_patches> patches
# (default: 1), numbering them from <patchnumber>, and store them in $patchdir.
# If the $patchdir is empty, also generates a cover letter
export patchnumber=$1
shift
export numpatches=$1
shift
if [ "$patchnumber" == "" ]; then
echo Need to specify patch number
exit
fi
rm $patchdir/$project-$username-0000-cover-letter.patch
if ls $patchdir/* > /dev/null; then
COVER=''
echo 'clean the destination directory to generate cover letter'
else
COVER='--cover-letter'
fi
set -x
export patchnumber=`printf "%04d" $patchnumber`
export opts="-M3 -C -N -B --patience --minimal --full-index $COVER --inter-hunk-context=3"
cd $localrepo
git fetch $remote HEAD
patchnames=$(git format-patch $opts FETCH_HEAD~$numpatches..FETCH_HEAD --start-number $patchnumber $@)
for patchname in $patchnames; do
mv $patchname $patchdir/$project-$username-$patchname
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment