Skip to content

Commit 1976483

Browse files
authored
Merge pull request paulirish#56 from elim/feature/separate-url-gitlab
Supports separate URLs in the repo and the web
2 parents 70e7399 + 8ce4938 commit 1976483

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,19 @@ git-open can automatically guess the corresponding repository page for remotes
9898
9999
#### GitLab support
100100
101-
To configure GitLab support you need to set `gitopen.gitlab.domain`:
101+
To configure GitLab support you need to set some options.
102+
103+
| option name | description | example |
104+
| ------------------------- | ---------------------------------------------------------- | ------------------ |
105+
| gitopen.gitlab.domain | The (web)domain name that will work for most of the people | gitlab.example.com |
106+
| gitopen.gitlab.ssh.domain | A specific ssh domain name, *if needed* | git.example.com |
107+
| gitopen.gitlab.ssh.port | A specific ssh port, *if needed* | 10022 |
102108
103109
```sh
104110
# use --global to set across all repos, instead of just the local one
105-
git config [--global] gitopen.gitlab.domain [yourdomain.here]
111+
git config [--global] gitopen.gitlab.domain [value]
112+
git config [--global] gitopen.gitlab.ssh.domain [value]
113+
git config [--global] gitopen.gitlab.ssh.port [value]
106114
```
107115
108116
## Related projects / alternatives

git-open

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,22 +92,24 @@ elif grep -q "/scm/" <<<$giturl; then
9292
else
9393
# custom GitLab
9494
gitlab_domain=$(git config --get gitopen.gitlab.domain)
95-
gitlab_port=$(git config --get gitopen.gitlab.port)
95+
gitlab_ssh_domain=$(git config --get gitopen.gitlab.ssh.domain)
96+
gitlab_ssh_domain=${gitlab_ssh_domain:-$gitlab_domain}
97+
gitlab_ssh_port=$(git config --get gitopen.gitlab.ssh.port)
9698
if [ -n "$gitlab_domain" ]; then
97-
if grep -q "$gitlab_domain" <<<$giturl; then
99+
if egrep -q "${gitlab_domain}|${gitlab_ssh_domain}" <<<$giturl; then
98100

99101
# Handle GitLab's default SSH notation (like git@gitlab.domain.com:user/repo)
100-
giturl=${giturl/git\@${gitlab_domain}\:/https://${gitlab_domain}/}
102+
giturl=${giturl/git\@${gitlab_ssh_domain}\:/https://${gitlab_domain}/}
101103

102104
# handle SSH protocol (links like ssh://git@gitlab.domain.com/user/repo)
103105
giturl=${giturl/#ssh\:\/\//https://}
104106

105107
# remove git@ from the domain
106-
giturl=${giturl/git\@${gitlab_domain}/${gitlab_domain}/}
108+
giturl=${giturl/git\@${gitlab_ssh_domain}/${gitlab_domain}/}
107109

108110
# remove SSH port
109-
if [ -n "$gitlab_port" ]; then
110-
giturl=${giturl/\/:${gitlab_port}\///}
111+
if [ -n "$gitlab_ssh_port" ]; then
112+
giturl=${giturl/\/:${gitlab_ssh_port}\///}
111113
fi
112114
providerUrlDifference=tree
113115
fi

0 commit comments

Comments
 (0)