From 225b338de98b699ec8c46c650e540d4c14d90aa8 Mon Sep 17 00:00:00 2001 From: Andrew Stubbs Date: Thu, 25 Jul 2024 09:02:54 +0000 Subject: [PATCH 1/2] Support git+ssh:// URL --- autoload/gitlab/fugitive.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/gitlab/fugitive.vim b/autoload/gitlab/fugitive.vim index 1af85a1..dc6cea7 100644 --- a/autoload/gitlab/fugitive.vim +++ b/autoload/gitlab/fugitive.vim @@ -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) From 0ca94ec08f66470aad11ea44abb9e66cfe949cd4 Mon Sep 17 00:00:00 2001 From: Andrew Stubbs Date: Thu, 25 Jul 2024 12:30:34 +0000 Subject: [PATCH 2/2] Add git+ssh:// testcases --- test/homepage_for_remote.vader | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/homepage_for_remote.vader b/test/homepage_for_remote.vader index bf4faae..fe51335 100644 --- a/test/homepage_for_remote.vader +++ b/test/homepage_for_remote.vader @@ -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