Added support for cnb.cool. (#217)

Co-authored-by: ericdduan <ericdduan@tencent.com>
This commit is contained in:
sixther 2025-03-20 03:07:49 +08:00 committed by GitHub
parent 2a66fcd7e3
commit a223125abc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 34 additions and 1 deletions

View file

@ -128,6 +128,7 @@ git-open can automatically guess the corresponding repository page for remotes
- Visual Studio Team Services
- Team Foundation Server (on-premises)
- AWS Code Commit
- cnb.cool
## Configuration

View file

@ -246,8 +246,16 @@ elif [[ "$domain" =~ amazonaws\.com$ ]]; then
# Replace branch ref.
# Ex. /tree/foobar -> foobar/--/
providerBranchRef="${providerBranchRef##*/}/--/"
elif [[ "$domain" =~ cnb\.cool$ ]]; then
# cnb.cool
# Replace URL path.
# Ex. repos/example -> repos/example/-
urlpath="$urlpath/-"
if [[ $remote_ref = "master" ]]; then
# repos/example/tree/master -> repos/example/-/tree/master
urlpath="$urlpath$providerBranchRef"
fi
fi
openurl="$protocol://$domain/$urlpath"
if (( is_commit )); then

View file

@ -626,6 +626,30 @@ setup() {
assert_output "Issue feature does not supported on AWS Code Commit."
}
##
## cnb.cool
##
@test "cnb: https url" {
git remote set-url origin "https://cnb.cool/repos/repo"
git checkout -B "master"
run ../git-open
assert_output "https://cnb.cool/repos/repo/-/tree/master"
}
@test "cnb: branch " {
git remote set-url origin "https://cnb.cool/repos/repo"
git checkout -B "mybranch"
run ../git-open
assert_output "https://cnb.cool/repos/repo/-/tree/mybranch"
}
@test "cnb: issue" {
git remote set-url origin "https://cnb.cool/repos/repo"
git checkout -B "issues/10"
run ../git-open "--issue"
assert_output "https://cnb.cool/repos/repo/-/issues/10"
}
teardown() {
cd ..