Skip to content

Commit

Permalink
Script for converting a forked PR into a branch in the Twisted repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilfredo Sánchez Vega committed Jan 4, 2017
1 parent 29599b1 commit 23d1ee7
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions admin/pr_as_branch
Original file line number Diff line number Diff line change
@@ -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} <pull_request_number> <trac_ticket_number> <branch_name>";

}


# 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}";

0 comments on commit 23d1ee7

Please sign in to comment.