diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2024-09-24 10:51:31 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2024-10-14 14:06:59 +0200 |
commit | 15683d9fa579275f0e4af5ca9b42a78a4ec1020b (patch) | |
tree | d86e3ab028286962665f35b6a1e8d149b2568ac1 | |
parent | 8b213ba547e1c99af66afe6ea3b569bf02bfb6b9 (diff) | |
download | hlupak-15683d9fa579275f0e4af5ca9b42a78a4ec1020b.tar.gz |
We actually don’t need the full strength of RE, simple pattern
matching in case statement is enough.
-rwxr-xr-x | git-req.sh | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -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" |