From 9a35780c090ff99a8f051aa4466b7507be30d9aa Mon Sep 17 00:00:00 2001 From: Guillaume Lostis Date: Fri, 19 Jun 2020 12:11:29 +0200 Subject: [PATCH 1/4] Add test for suffix with `=` in it --- test/git-open.bats | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/git-open.bats b/test/git-open.bats index 854f274..73ef6bd 100755 --- a/test/git-open.bats +++ b/test/git-open.bats @@ -172,6 +172,11 @@ setup() { assert_output "https://github.com/paulirish/git-open/anySuffix" } +@test "gh: git open --suffix anySuffix?hello=world" { + run ../git-open "--suffix" "anySuffix?hello=world" + assert_output "https://github.com/paulirish/git-open/anySuffix?hello=world" +} + @test "gh: gist" { git remote set-url origin "git@gist.github.com:2d84a6db1b41b4020685.git" run ../git-open From 91170cd5c864f988b874fba4399f0e1f7f9eb1c7 Mon Sep 17 00:00:00 2001 From: Guillaume Lostis Date: Fri, 19 Jun 2020 12:11:53 +0200 Subject: [PATCH 2/4] Fix handling of suffix with `=` in it --- git-open | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/git-open b/git-open index de056e9..1578759 100755 --- a/git-open +++ b/git-open @@ -46,7 +46,8 @@ done # parse suffix from suffix=value IFS='=' read -ra suffix_flag <<< "$suffix_flag" -suffix=${suffix_flag[1]} +function join_by { local IFS="$1"; shift; echo "$*"; } +suffix=$(join_by = ${suffix_flag[@]:1}) # are we in a git repo? if ! git rev-parse --is-inside-work-tree &>/dev/null; then From 1d55c4ee50aad8c881874eac8ee5c61f8cfabf11 Mon Sep 17 00:00:00 2001 From: Guillaume Lostis Date: Fri, 19 Jun 2020 12:35:48 +0200 Subject: [PATCH 3/4] Fix formatting to pass shellcheck --- git-open | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-open b/git-open index 1578759..d663a8d 100755 --- a/git-open +++ b/git-open @@ -47,7 +47,7 @@ done # parse suffix from suffix=value IFS='=' read -ra suffix_flag <<< "$suffix_flag" function join_by { local IFS="$1"; shift; echo "$*"; } -suffix=$(join_by = ${suffix_flag[@]:1}) +suffix=$(join_by "=" "${suffix_flag[@]:1}") # are we in a git repo? if ! git rev-parse --is-inside-work-tree &>/dev/null; then From 3bd3524de2df5816b6e3058ff6182dd9cabe352d Mon Sep 17 00:00:00 2001 From: Guillaume Lostis Date: Fri, 19 Jun 2020 14:02:31 +0200 Subject: [PATCH 4/4] Fix shellcheck --- git-open | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-open b/git-open index d663a8d..b7b55cb 100755 --- a/git-open +++ b/git-open @@ -144,7 +144,7 @@ else # Resolve sshconfig aliases if [[ -e "$ssh_config" ]]; then domain_resolv=$(ssh_resolve "$domain") - if [[ ! -z "$domain_resolv" ]]; then + if [[ -n "$domain_resolv" ]]; then domain="$domain_resolv" fi fi