aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xgit-req.sh19
1 files changed, 11 insertions, 8 deletions
diff --git a/git-req.sh b/git-req.sh
index 5c86116..d1db37f 100755
--- a/git-req.sh
+++ b/git-req.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
set -eux
[ "$#" -lt 1 ] && exit 1
@@ -11,13 +11,16 @@ if ! git rev-parse --git-dir >/dev/null 2>&1 ; then
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
+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"