diff --git a/README.md b/README.md index 55117e1..dea63fd 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/git-open b/git-open index 6adb949..7dcae92 100755 --- a/git-open +++ b/git-open @@ -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 diff --git a/test/git-open.bats b/test/git-open.bats index be0119b..887d6a7 100755 --- a/test/git-open.bats +++ b/test/git-open.bats @@ -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 ..