From 557fd40b1c2f46dc00c72fe632a6148f86240ed5 Mon Sep 17 00:00:00 2001 From: Yohei TSUJI Date: Wed, 8 Aug 2018 12:58:58 +0900 Subject: [PATCH] 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"