From 23d1ee730877233312fb72123680ff36d6770c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20Sa=CC=81nchez=20Vega?= Date: Wed, 4 Jan 2017 15:01:13 -0800 Subject: [PATCH] Script for converting a forked PR into a branch in the Twisted repo. --- admin/pr_as_branch | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 admin/pr_as_branch diff --git a/admin/pr_as_branch b/admin/pr_as_branch new file mode 100755 index 00000000000..d9eb69ea2db --- /dev/null +++ b/admin/pr_as_branch @@ -0,0 +1,56 @@ +#!/bin/sh + +set -e +set -u + + +# Usage + +usage() { + program=$(basename "$0"); + + if [ $# != 0 ]; then echo "$@"; echo ""; fi; + + echo "${program}: usage:"; + echo " ${program} "; + +} + + +# Options + +while [ $# != 0 ]; do + case "$1" in + --help) + usage; + exit 0; + ;; + --|*) break; ;; + esac; +done; + +if [ $# != 3 ]; then + usage "Invalid arguments: $*"; + exit 1; +fi; + + PR_NUMBER="$1"; shift; +TICKET_NUMBER="$1"; shift; + BRANCH_NAME="$1"; shift; + + +# Do The Right Thing + +#repo="https://github.com/twisted/twisted.git"; +repo="git@github.com:twisted/twisted.git"; + +clone="$(mktemp -d -t twisted)"; + +git clone --progress "${repo}" "${clone}"; + +cd "${clone}"; + +git fetch origin "refs/pull/${PR_NUMBER}/head"; +git push origin "FETCH_HEAD:refs/heads/${TICKET_NUMBER}-${BRANCH_NAME}"; + +rm -fr "${clone}";