]> git.wh0rd.org - home.git/blame - .bin/git-format-request-pull
update configs
[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
1afdf944
MF
9while [[ -n $1 ]] ; do
10 case $1 in
11 -h|--help) usage;;
bdf10c38 12 -e) auto=true;;
1afdf944
MF
13 --) shift; break;;
14 -*) usage 1;;
15 *) break;
16 esac
17 shift
18done
19
20commit=$1
21url=$(git config --get remote.origin.url)
22branch=${2:-master}
23
24if [[ -z ${commit} ]] || [[ -n $3 ]] ; then
25 usage 1
26fi
27
28name=$(git config --get user.name)
29email=$(git config --get user.email)
bdf10c38
MF
30tmp=$(mktemp)
31cat << EOF > ${tmp}
1afdf944
MF
32From: ${name} <${email}>
33Date: $(date -R)
34Subject: Pull request ${url##*/}
35
36$(git request-pull ${commit} ${url} ${branch})
37EOF
bdf10c38 38cat ${tmp}
1afdf944 39
bdf10c38
MF
40to=$(git config --get sendemail.pullrequest)
41cc=$(git config --get sendemail.to)
42if ${auto} ; then
43 git send-email --to "${to}" --cc "${cc}" ${tmp}
44else
45 echo git send-email --to \"${to}\" --cc \"${cc}\" ... 1>&2
46fi
47rm -f ${tmp}