diff --git a/doc/fugitive.txt b/doc/fugitive.txt index bc1a707..df976a3 100644 --- a/doc/fugitive.txt +++ b/doc/fugitive.txt @@ -186,6 +186,11 @@ that are part of Git repositories). "git instaweb" from a terminal). If a range is given, it is appropriately appended to the URL as an anchor. + To use with GitHub FI, point g:fugitive_github_domains + at a list of domains: +> + let g:fugitive_github_domains = ['git.example.com'] +~ :[range]Gbrowse! Like :Gbrowse, but put the URL on the clipboard rather than opening it. diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 57999b6..e7e743f 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -1758,11 +1758,15 @@ endfunction function! s:github_url(repo,url,rev,commit,path,type,line1,line2) abort let path = a:path - let repo_path = matchstr(a:url,'^\%(https\=://\|git://\|git@\)github\.com[/:]\zs.\{-\}\ze\%(\.git\)\=$') - if repo_path ==# '' + let domain_pattern = 'github\.com' + for domain in exists('g:fugitive_github_domains') ? g:fugitive_github_domains : [] + let domain_pattern .= '\|' . escape(domain, '.') + endfor + let repo = matchstr(a:url,'^\%(https\=://\|git://\|git@\)\zs\('.domain_pattern.'\)[/:].\{-\}\ze\%(\.git\)\=$') + if repo ==# '' return '' endif - let root = 'https://github.com/' . repo_path + let root = 'https://' . s:sub(repo,':','/') if path =~# '^\.git/refs/heads/' let branch = a:repo.git_chomp('config','branch.'.path[16:-1].'.merge')[11:-1] if branch ==# ''