#!/bin/bash ODIR=pull-$$ RELATIVE_TO="master" COMMIT_ID="HEAD" PREFIX="PATCH" usage() { CMD=$(basename $0) cat < /dev/null # Customize the cover letter CL="$ODIR/0000-cover-letter.patch" PM="$ODIR/pull-msg" git request-pull $RELATIVE_TO $REMOTE_URL $COMMIT_ID > "$PM" if [ $? -ne 0 ]; then echo "ERROR: git request-pull reported an error" exit 1 fi # The cover letter already has a diffstat, remove it from the pull-msg # before inserting it. sed -n "0,\#$REMOTE_URL# p" "$PM" | sed -i "/BLURB HERE/ r /dev/stdin" "$CL" rm "$PM" # Insert the WEB_URL if there is one if [ -n "$WEB_URL" ]; then echo " $WEB_URL" | sed -i "\#$REMOTE_URL# r /dev/stdin" "$CL" fi # If the user specified a message body, insert it into the cover letter and # remove the BLURB token. if [ -n "$BODY" ]; then sed -i "/BLURB HERE/ r $BODY" "$CL" sed -i "/BLURB HERE/ d" "$CL" fi # If the user specified a subject, replace the SUBJECT token with it. if [ -n "$SUBJECT" ]; then sed -i -e "s/\*\*\* SUBJECT HERE \*\*\*/$SUBJECT/" "$CL" fi # Generate report for user cat <