Skip to content

Commit

Permalink
Merge pull request #50 from a-m-s/master
Browse files Browse the repository at this point in the history
Support git+ssh:// URL
  • Loading branch information
shumphrey authored Jul 25, 2024
2 parents e8dd4c9 + 0ca94ec commit 838d3a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion autoload/gitlab/fugitive.vim
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function! gitlab#fugitive#homepage_for_remote(url) abort
" https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols
" [full_url, scheme, host_with_port, host, path]
if a:url =~# '://'
let match = matchlist(a:url, '^\(https\=://\|git://\|ssh://\)\%([^@/]\+@\)\=\(\([^/:]\+\)\%(:\d\+\)\=\)/\(.\{-\}\)\%(\.git\)\=/\=$')
let match = matchlist(a:url, '^\(https\=://\|git://\|ssh://\|git+ssh://\)\%([^@/]\+@\)\=\(\([^/:]\+\)\%(:\d\+\)\=\)/\(.\{-\}\)\%(\.git\)\=/\=$')
else
let match = matchlist(a:url, '^\([^@/]\+@\)\=\(\([^:/]\+\)\):\(.\{-\}\)\%(\.git\)\=/\=$')
if empty(match)
Expand Down
16 changes: 16 additions & 0 deletions test/homepage_for_remote.vader
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,19 @@ Execute (gitlab#fugitive#homepage_for_remote - verbose ssh:// with user and port
let expected = 'https://my.gitlab.com:3456/shumphrey/fugitive-gitlab.vim'
let url = gitlab#fugitive#homepage_for_remote('ssh://git@my.gitlab.com:12345/shumphrey/fugitive-gitlab.vim.git')
AssertEqual url, expected

Execute (gitlab#fugitive#homepage_for_remote - git+ssh://):
let g:fugitive_gitlab_domains = {
\ 'git+ssh://my.gitlab.com': 'https://my.gitlab.com',
\ }
let expected = 'https://my.gitlab.com/shumphrey/fugitive-gitlab.vim'
let url = gitlab#fugitive#homepage_for_remote('git+ssh://my.gitlab.com/shumphrey/fugitive-gitlab.vim.git')
AssertEqual url, expected

Execute (gitlab#fugitive#homepage_for_remote - git+ssh:// with user and port):
let g:fugitive_gitlab_domains = {
\ 'git+ssh://git@my.gitlab.com:12345': 'https://my.gitlab.com:3456',
\ }
let expected = 'https://my.gitlab.com:3456/shumphrey/fugitive-gitlab.vim'
let url = gitlab#fugitive#homepage_for_remote('git+ssh://git@my.gitlab.com:12345/shumphrey/fugitive-gitlab.vim.git')
AssertEqual url, expected

0 comments on commit 838d3a1

Please sign in to comment.