aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2024-09-24 10:51:31 +0200
committerMatěj Cepl <mcepl@cepl.eu>2024-10-14 14:06:59 +0200
commit15683d9fa579275f0e4af5ca9b42a78a4ec1020b (patch)
treed86e3ab028286962665f35b6a1e8d149b2568ac1
parent8b213ba547e1c99af66afe6ea3b569bf02bfb6b9 (diff)
downloadhlupak-15683d9fa579275f0e4af5ca9b42a78a4ec1020b.tar.gz
fix[git-req]: make the script POSIX-sh compliantHEADmaster
We actually don’t need the full strength of RE, simple pattern matching in case statement is enough.
-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"