From 88a9e254aea74e1ba36734fada9b9d9abd9df9d9 Mon Sep 17 00:00:00 2001 From: Martin Delille Date: Tue, 22 Nov 2016 10:34:16 +0100 Subject: [PATCH] Add http protocol for Gitlab custom host --- README.md | 6 ++++++ git-open | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4e87acf..69b1029 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,12 @@ To configure GitLab support you need to set `gitopen.gitlab.domain`: git config [--global] gitopen.gitlab.domain [yourdomain.here] ``` +If your Gitlab custom hosted is serving `http` you can also specify this: +```sh +# use --global to set across all repos, instead of just the local one +git config [--global] gitopen.gitlab.protocol http +``` + ## Related projects / alternatives See [hub](https://github.com/github/hub) for complete GitHub opening support. diff --git a/git-open b/git-open index 3fb6609..6e90fab 100755 --- a/git-open +++ b/git-open @@ -93,14 +93,18 @@ else # custom GitLab gitlab_domain=$(git config --get gitopen.gitlab.domain) gitlab_port=$(git config --get gitopen.gitlab.port) + gitlab_protocol=$(git config --get gitopen.gitlab.protocol) + if [ -z "$gitlab_protocol" ]; then + gitlab_protocol=http + fi if [ -n "$gitlab_domain" ]; then if grep -q "$gitlab_domain" <<<$giturl; then # Handle GitLab's default SSH notation (like git@gitlab.domain.com:user/repo) - giturl=${giturl/git\@${gitlab_domain}\:/https://${gitlab_domain}/} + giturl=${giturl/git\@${gitlab_domain}\:/${gitlab_protocol}://${gitlab_domain}/} # handle SSH protocol (links like ssh://git@gitlab.domain.com/user/repo) - giturl=${giturl/#ssh\:\/\//https://} + giturl=${giturl/#ssh\:\/\//${gitlab_protocol}://} # remove git@ from the domain giturl=${giturl/git\@${gitlab_domain}/${gitlab_domain}/}