X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=.bin%2Fgit-format-request-pull;h=f03345b7143f331e7c4f569a10fb36b44c72bc7c;hb=05fa0b8255051e15def5845534f231495eedff7f;hp=7c4f3a6909a1d1cb37397c1484ace8dc435cde85;hpb=1afdf944dcef65ad2bab01e5a07756da28024503;p=home.git diff --git a/.bin/git-format-request-pull b/.bin/git-format-request-pull index 7c4f3a6..f03345b 100755 --- a/.bin/git-format-request-pull +++ b/.bin/git-format-request-pull @@ -5,9 +5,14 @@ usage() { exit ${1:-0} } +auto=false +force=false +eval set -- `getopt -- efh "$@"` while [[ -n $1 ]] ; do case $1 in -h|--help) usage;; + -e) auto=true;; + -f) force=true;; --) shift; break;; -*) usage 1;; *) break; @@ -15,9 +20,14 @@ while [[ -n $1 ]] ; do shift done -commit=$1 -url=$(git config --get remote.origin.url) +commit=${1:-mainline/master} +url=$(git config --get remote.pullrequest.url || git config --get remote.origin.url) branch=${2:-master} +if [[ ${branch} != master ]] ; then + subject=" (${branch} branch)" +else + subject="" +fi if [[ -z ${commit} ]] || [[ -n $3 ]] ; then usage 1 @@ -25,14 +35,25 @@ fi name=$(git config --get user.name) email=$(git config --get user.email) -cat << EOF +tmp=$(mktemp) +if ! request=$(PAGER= git request-pull ${commit} ${url} ${branch}) ; then + ${force} || exit 1 + request=$(echo "${request}" | sed "s:..BRANCH.NOT.VERIFIED..:${branch}:") +fi +cat << EOF > ${tmp} From: ${name} <${email}> Date: $(date -R) -Subject: Pull request ${url##*/} +Subject: Pull request ${url##*/}${subject} -$(git request-pull ${commit} ${url} ${branch}) +${request} EOF +cat ${tmp} -echo git send-email \ - --to \"$(git config --get sendemail.pullrequest)\" \ - --cc \"$(git config --get sendemail.to)\" ... 1>&2 +to=$(git config --get sendemail.pullrequest) +cc=$(git config --get sendemail.to || git config --get sendemail.pullrequestcc) +if ${auto} ; then + git send-email --to "${to}" --cc "${cc}" ${tmp} +else + echo git send-email --to \"${to}\" --cc \"${cc}\" ... 1>&2 +fi +rm -f ${tmp}