diff options
Diffstat (limited to 'git-req.sh')
-rwxr-xr-x | git-req.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/git-req.sh b/git-req.sh new file mode 100755 index 0000000..5c86116 --- /dev/null +++ b/git-req.sh @@ -0,0 +1,23 @@ +#!/bin/bash +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)" +if [[ "${repo_url}" =~ gitlab ]] ; then + rem_ref_name="merge-requests" + loc_ref_name="mr" +else + rem_ref_name="pull" + loc_ref_name="pr" +fi + +git fetch origin refs/"$rem_ref_name"/"$req_no"/head:"$loc_ref_name"/"$req_no" +git checkout "$loc_ref_name/$req_no" |