Skip to content

Supports separate URLs in the repo and the web #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,19 @@ git-open can automatically guess the corresponding repository page for remotes

#### GitLab support

To configure GitLab support you need to set `gitopen.gitlab.domain`:
To configure GitLab support you need to set some options.

| option name | description | example |
| ------------------------- | ---------------------------------------------------------- | ------------------ |
| gitopen.gitlab.domain | The (web)domain name that will work for most of the people | gitlab.example.com |
| gitopen.gitlab.ssh.domain | A specific ssh domain name, *if needed* | git.example.com |
| gitopen.gitlab.ssh.port | A specific ssh port, *if needed* | 10022 |

```sh
# use --global to set across all repos, instead of just the local one
git config [--global] gitopen.gitlab.domain [yourdomain.here]
git config [--global] gitopen.gitlab.domain [value]
git config [--global] gitopen.gitlab.ssh.domain [value]
git config [--global] gitopen.gitlab.ssh.port [value]
```

## Related projects / alternatives
Expand Down
14 changes: 8 additions & 6 deletions git-open
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,24 @@ elif grep -q "/scm/" <<<$giturl; then
else
# custom GitLab
gitlab_domain=$(git config --get gitopen.gitlab.domain)
gitlab_port=$(git config --get gitopen.gitlab.port)
gitlab_ssh_domain=$(git config --get gitopen.gitlab.ssh.domain)
gitlab_ssh_domain=${gitlab_ssh_domain:-$gitlab_domain}
gitlab_ssh_port=$(git config --get gitopen.gitlab.ssh.port)
if [ -n "$gitlab_domain" ]; then
if grep -q "$gitlab_domain" <<<$giturl; then
if egrep -q "${gitlab_domain}|${gitlab_ssh_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_ssh_domain}\:/https://${gitlab_domain}/}

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

# remove git@ from the domain
giturl=${giturl/git\@${gitlab_domain}/${gitlab_domain}/}
giturl=${giturl/git\@${gitlab_ssh_domain}/${gitlab_domain}/}

# remove SSH port
if [ -n "$gitlab_port" ]; then
giturl=${giturl/\/:${gitlab_port}\///}
if [ -n "$gitlab_ssh_port" ]; then
giturl=${giturl/\/:${gitlab_ssh_port}\///}
fi
providerUrlDifference=tree
fi
Expand Down