From 58648dfdd2121581c9fda477f2ca46ed0d83e734 Mon Sep 17 00:00:00 2001 From: phwt <28344318+phwt@users.noreply.github.com> Date: Fri, 12 Aug 2022 16:33:54 +0700 Subject: [PATCH] feat: url simplification for main branch --- git-open | 4 ++-- test/git-open.bats | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/git-open b/git-open index bc3d121..01a8827 100755 --- a/git-open +++ b/git-open @@ -241,8 +241,8 @@ openurl="$protocol://$domain/$urlpath" if (( is_commit )); then sha=$(git rev-parse HEAD) openurl="$openurl/commit/$sha" -elif [[ $remote_ref != "master" ]]; then - # simplify URL for master +elif [[ $remote_ref != "master" && $remote_ref != "main" ]]; then + # simplify URL for master and main openurl="$openurl$providerBranchRef" fi diff --git a/test/git-open.bats b/test/git-open.bats index 32c0fe1..ea13561 100755 --- a/test/git-open.bats +++ b/test/git-open.bats @@ -58,6 +58,14 @@ setup() { assert_output "http://example.com/example" } +@test "url: simplification" { + git config --local url.http://example.com/.insteadOf ex: + git remote set-url origin ex:example.git + git checkout -B main + run ../git-open + assert_output "http://example.com/example" +} + ## ## GitHub ##