From 15683d9fa579275f0e4af5ca9b42a78a4ec1020b Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Tue, 24 Sep 2024 10:51:31 +0200 Subject: fix[git-req]: make the script POSIX-sh compliant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We actually don’t need the full strength of RE, simple pattern matching in case statement is enough. --- git-req.sh | 19 +++++++++++-------- 1 file 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" -- cgit