commit 41ea90cddf1aa7397f0b4bf87f8534f9d1730814 (tree)
parent 4f7af188fec24330e7dff99c8758588ae9780347
Author: Tim Pope <code@tpope.net>
Date: Wed, 14 Mar 2012 16:27:46 -0400
Support GitHub FI
Diffstat:
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git 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
@@ -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 ==# ''