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