Add http protocol for Gitlab custom host

This commit is contained in:
Martin Delille 2016-11-22 10:34:16 +01:00
parent 70e7399140
commit 88a9e254ae
2 changed files with 12 additions and 2 deletions

View file

@ -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.

View file

@ -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}/}