From f64ba46509119810959bd03e8e47348cabf804be Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sun, 18 Nov 2012 22:43:04 -0500 Subject: [PATCH] Allow :Gbrowse on HTTP GitHub FI Closes #272. --- doc/fugitive.txt | 2 +- plugin/fugitive.vim | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/doc/fugitive.txt b/doc/fugitive.txt index 51addb4..b32f4a5 100644 --- a/doc/fugitive.txt +++ b/doc/fugitive.txt @@ -203,7 +203,7 @@ that are part of Git repositories). To use with GitHub FI, point g:fugitive_github_domains at a list of domains: > - let g:fugitive_github_domains = ['git.example.com'] + let g:fugitive_github_domains = ['https://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 41477f1..67b3bf5 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -1870,14 +1870,19 @@ endfunction function! s:github_url(repo,url,rev,commit,path,type,line1,line2) abort let path = a:path let domain_pattern = 'github\.com' - for domain in exists('g:fugitive_github_domains') ? g:fugitive_github_domains : [] - let domain_pattern .= '\|' . escape(domain, '.') + let domains = exists('g:fugitive_github_domains') ? g:fugitive_github_domains : [] + for domain in domains + let domain_pattern .= '\|' . escape(split(domain, '://')[-1], '.') endfor let repo = matchstr(a:url,'^\%(https\=://\|git://\|git@\)\zs\('.domain_pattern.'\)[/:].\{-\}\ze\%(\.git\)\=$') if repo ==# '' return '' endif - let root = 'https://' . s:sub(repo,':','/') + if index(g:fugitive_github_domains, 'http://' . matchstr(repo, '^[^:/]*')) >= 0 + let root = 'http://' . s:sub(repo,':','/') + else + let root = 'https://' . s:sub(repo,':','/') + endif if path =~# '^\.git/refs/heads/' let branch = a:repo.git_chomp('config','branch.'.path[16:-1].'.merge')[11:-1] if branch ==# ''