From 557fd40b1c2f46dc00c72fe632a6148f86240ed5 Mon Sep 17 00:00:00 2001 From: Yohei TSUJI Date: Wed, 8 Aug 2018 12:58:58 +0900 Subject: [PATCH 1/4] Added support for AWS Code commit. --- git-open | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/git-open b/git-open index fc68240..65b6af4 100755 --- a/git-open +++ b/git-open @@ -196,6 +196,23 @@ elif [[ "${#pathargs[@]}" -ge '2' && ${pathargs[${#pathargs[@]} - 2]} == '_git' # Keep project and repository name, append branch selector. providerBranchRef="?version=GB$branch" fi +elif [[ "$domain" =~ amazonaws\.com$ ]]; then + # AWS Code Commit + # Take region name from domain. + region=${domain#*.} + region=${region%%.*} + + # Replace domain. + # Ex. git-codecommit.us-east-1.amazonaws.com -> us-east-1.console.aws.amazon.com + domain="${region}.console.aws.amazon.com" + + # Replace URL path. + # Ex. v1/repos/example -> codecommit/home?region=us-east-1#/repository/example/browse/ + urlpath="codecommit/home?region=${region}#/repository/${urlpath##*/}/browse/" + + # Replace branch ref. + # Ex. /tree/foobar -> foobar/--/ + providerBranchRef="${providerBranchRef##*/}/--/" fi openurl="$protocol://$domain/$urlpath" From 2ef17f07d8d243595aa66b90609746e4f60dadae Mon Sep 17 00:00:00 2001 From: Yohei TSUJI Date: Thu, 9 Aug 2018 10:10:21 +0900 Subject: [PATCH 2/4] Added test cases for AWS Code Commit. --- git-open | 5 +++++ test/git-open.bats | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/git-open b/git-open index 65b6af4..67103f3 100755 --- a/git-open +++ b/git-open @@ -198,6 +198,11 @@ elif [[ "${#pathargs[@]}" -ge '2' && ${pathargs[${#pathargs[@]} - 2]} == '_git' fi elif [[ "$domain" =~ amazonaws\.com$ ]]; then # AWS Code Commit + if (( is_issue )); then + echo "Issue feature does not supported on AWS Code Commit." 1>&2 + exit 1 + fi + # Take region name from domain. region=${domain#*.} region=${region%%.*} diff --git a/test/git-open.bats b/test/git-open.bats index 50808ac..c070606 100755 --- a/test/git-open.bats +++ b/test/git-open.bats @@ -503,6 +503,39 @@ setup() { assert_output "https://gitopen.visualstudio.com/Project/_workitems?id=36" } +## +## AWS Code Commit +## + +@test "aws: https url" { + git remote set-url origin "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/repo" + git checkout -B "master" + run ../git-open + assert_output "https://us-east-1.console.aws.amazon.com/codecommit/home?region=us-east-1#/repository/repo/browse/" +} + +@test "aws: ssh url" { + git remote set-url origin "ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/repo" + git checkout -B "master" + run ../git-open + assert_output "https://us-east-1.console.aws.amazon.com/codecommit/home?region=us-east-1#/repository/repo/browse/" +} + +@test "aws: branch " { + git remote set-url origin "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/repo" + git checkout -B "mybranch" + run ../git-open + assert_output "https://us-east-1.console.aws.amazon.com/codecommit/home?region=us-east-1#/repository/repo/browse/mybranch/--/" +} + +@test "aws: issue" { + git remote set-url origin "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/repo" + git checkout -B "issues/#12" + run ../git-open "--issue" + [ "$status" -eq 1 ] + assert_output "Issue feature does not supported on AWS Code Commit." +} + teardown() { cd .. From c5e636f42360929931a01c2a3fdd3ff9dcfe9b36 Mon Sep 17 00:00:00 2001 From: Yohei TSUJI Date: Fri, 10 Aug 2018 15:56:39 +0900 Subject: [PATCH 3/4] Append 'AWS Code Commit' to supported remote repositories. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 664708c..faff7dc 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ git-open can automatically guess the corresponding repository page for remotes - Atlassian Bitbucket Server (formerly _Atlassian Stash_) - Visual Studio Team Services - Team Foundation Server (on-premises) +- AWS Code Commit ## Configuration From 6bb49c28c539d534f653bcf7e701acfa8619c7a7 Mon Sep 17 00:00:00 2001 From: "Y.Tsuji" Date: Mon, 13 Aug 2018 01:55:43 +0900 Subject: [PATCH 4/4] Fix Indentation. --- git-open | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-open b/git-open index 67103f3..2e10b2a 100755 --- a/git-open +++ b/git-open @@ -199,7 +199,7 @@ elif [[ "${#pathargs[@]}" -ge '2' && ${pathargs[${#pathargs[@]} - 2]} == '_git' elif [[ "$domain" =~ amazonaws\.com$ ]]; then # AWS Code Commit if (( is_issue )); then - echo "Issue feature does not supported on AWS Code Commit." 1>&2 + echo "Issue feature does not supported on AWS Code Commit." 1>&2 exit 1 fi