Skip to content

support set gitopen.gitlab.protocol #62

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

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ To configure GitLab support you need to set `gitopen.gitlab.domain`:
git config [--global] gitopen.gitlab.domain [yourdomain.here]
```

GitLab protocol default is `https:`, if you need modify:

```sh
git config [--global] gitopen.gitlab.protocol [https:|http:]
```

## Related projects / alternatives

See [hub](https://github.com/github/hub) for complete GitHub opening support.
Expand Down
10 changes: 8 additions & 2 deletions git-open
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,22 @@ elif grep -q "/scm/" <<<$giturl; then
# GitLab
else
# custom GitLab
gitlab_protocol=$(git config --get gitopen.gitlab.protocol)
gitlab_domain=$(git config --get gitopen.gitlab.domain)
gitlab_port=$(git config --get gitopen.gitlab.port)

if [ -z "$gitlab_protocol" ]; then
gitlab_protocol="https:";
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}/}
Expand Down