From 799e9fdca963acdf6e49bbe891ca292d13162ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Wed, 3 Feb 2021 15:16:26 +0100 Subject: [PATCH] Update fugitive plugin to work with subdomained remotes --- symlinks/vim/plugin/fugitive.vim | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/symlinks/vim/plugin/fugitive.vim b/symlinks/vim/plugin/fugitive.vim index 4c7fa2f..0d71aa3 100644 --- a/symlinks/vim/plugin/fugitive.vim +++ b/symlinks/vim/plugin/fugitive.vim @@ -20,9 +20,20 @@ endfunction " Hardcoded to use 'origin' remote function! s:GetPrUrl(...) let origin_url = fugitive#RemoteUrl('origin') - let origin_url = substitute(l:origin_url, '\.git$', '', '') - let origin_url = substitute(l:origin_url, ':', '/', '') - let origin_url = substitute(l:origin_url, 'git@', 'https://', '') + let l:origin_url = substitute(l:origin_url, '\.git$', '', '') + let l:origin_url = substitute(l:origin_url, ':', '/', '') + let l:origin_url = substitute(l:origin_url, 'git@', 'https://', '') + + " Remove prefix if it is available, for some of common git services + let common_services = ['github.com', 'bitbucket.org', 'gitlab.com'] + for service in l:common_services + if (l:origin_url =~ l:service) + " Common mechanism for managing multiple SSH keys + let l:origin_url = substitute(l:origin_url, '://.*' . l:service, '://' . l:service, '') + endif + endfor + + " This part probably only works on github if a:0 == 0 let pr_url = l:origin_url . '/compare/' . FugitiveHead() . '?expand=1' else