diff options
Diffstat (limited to 'git-req.sh')
-rwxr-xr-x | git-req.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/git-req.sh b/git-req.sh new file mode 100755 index 0000000..d1db37f --- /dev/null +++ b/git-req.sh @@ -0,0 +1,26 @@ +#!/bin/sh +set -eux + +[ "$#" -lt 1 ] && exit 1 + +req_no="$1" + +if ! git rev-parse --git-dir >/dev/null 2>&1 ; then + echo "Must be run from git repo checkout." + exit 2 +fi + +repo_url="$(git config --get remote.origin.url)" +case $repo_url in + *gitlab*) + rem_ref_name="merge-requests" + loc_ref_name="mr" + ;; + *) + rem_ref_name="pull" + loc_ref_name="pr" + ;; +esac + +git fetch origin refs/"$rem_ref_name"/"$req_no"/head:"$loc_ref_name"/"$req_no" +git checkout "$loc_ref_name/$req_no" |