feat: url simplification for main branch

This commit is contained in:
phwt 2022-08-12 16:33:54 +07:00
parent f772364eb8
commit 58648dfdd2
2 changed files with 10 additions and 2 deletions

View file

@ -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

View file

@ -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
##