]> git.wh0rd.org - home.git/blame - .bin/git-format-request-pull
type out mus
[home.git] / .bin / git-format-request-pull
CommitLineData
1afdf944
MF
1#!/bin/bash
2
3usage() {
4 echo "Usage: git-request-pull-send-email <commit> [branch]"
5 exit ${1:-0}
6}
7
bdf10c38 8auto=false
8069c098 9eval set -- `getopt -- eh "$@"`
1afdf944
MF
10while [[ -n $1 ]] ; do
11 case $1 in
12 -h|--help) usage;;
bdf10c38 13 -e) auto=true;;
1afdf944
MF
14 --) shift; break;;
15 -*) usage 1;;
16 *) break;
17 esac
18 shift
19done
20
8069c098 21commit=${1:-mainline/master}
1afdf944
MF
22url=$(git config --get remote.origin.url)
23branch=${2:-master}
8069c098
MF
24if [[ ${branch} != master ]] ; then
25 subject=" (${branch} branch)"
26else
27 subject=""
28fi
1afdf944
MF
29
30if [[ -z ${commit} ]] || [[ -n $3 ]] ; then
31 usage 1
32fi
33
34name=$(git config --get user.name)
35email=$(git config --get user.email)
bdf10c38 36tmp=$(mktemp)
8069c098 37request=$(PAGER= git request-pull ${commit} ${url} ${branch}) || exit 1
bdf10c38 38cat << EOF > ${tmp}
1afdf944
MF
39From: ${name} <${email}>
40Date: $(date -R)
8069c098 41Subject: Pull request ${url##*/}${subject}
1afdf944 42
8069c098 43${request}
1afdf944 44EOF
bdf10c38 45cat ${tmp}
1afdf944 46
bdf10c38 47to=$(git config --get sendemail.pullrequest)
fc26d5d9 48cc=$(git config --get sendemail.to || git config --get sendemail.pullrequestcc)
bdf10c38
MF
49if ${auto} ; then
50 git send-email --to "${to}" --cc "${cc}" ${tmp}
51else
52 echo git send-email --to \"${to}\" --cc \"${cc}\" ... 1>&2
53fi
54rm -f ${tmp}