4 Commits

Author SHA1 Message Date
Tim Pope
2723a1116f Return '' from buffer.path() if outside work tree
In reference to #278.
2012-12-08 16:53:55 -05:00
Tim Pope
7df3a6894a Send :help :Gw to the right place 2012-12-08 16:45:31 -05:00
Tim Pope
6f380fa8c6 Fix error when g:fugitive_github_domains is unset
Closes #274.
2012-11-20 17:57:37 -05:00
Tim Pope
f64ba46509 Allow :Gbrowse on HTTP GitHub FI
Closes #272.
2012-11-18 22:43:04 -05:00
2 changed files with 12 additions and 7 deletions

View File

@@ -122,7 +122,7 @@ that are part of Git repositories).
:{range}Gread! [args] |:read| the output of a Git command after {range}. :{range}Gread! [args] |:read| the output of a Git command after {range}.
*fugitive-:Gwrite* *fugitive-:Gw* *fugitive-:Gwrite*
:Gwrite Write to the current file's path and stage the results. :Gwrite Write to the current file's path and stage the results.
When run in a work tree file, it is effectively git When run in a work tree file, it is effectively git
add. Elsewhere, it is effectively git-checkout. A add. Elsewhere, it is effectively git-checkout. A
@@ -203,7 +203,7 @@ that are part of Git repositories).
To use with GitHub FI, point g:fugitive_github_domains To use with GitHub FI, point g:fugitive_github_domains
at a list of 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 :[range]Gbrowse! Like :Gbrowse, but put the URL on the clipboard rather
than opening it. than opening it.

View File

@@ -506,9 +506,9 @@ function! s:buffer_path(...) dict abort
let rev = matchstr(self.spec(),'^fugitive://.\{-\}//\zs.*') let rev = matchstr(self.spec(),'^fugitive://.\{-\}//\zs.*')
if rev != '' if rev != ''
let rev = s:sub(rev,'\w*','') let rev = s:sub(rev,'\w*','')
elseif self.repo().bare() elseif self.spec()[0 : len(self.repo().dir())] ==# self.repo().dir() . '/'
let rev = '/.git'.self.spec()[strlen(self.repo().dir()) : -1] let rev = '/.git'.self.spec()[strlen(self.repo().dir()) : -1]
else elseif !self.repo().bare() && self.spec()[0 : len(self.repo().tree())] ==# self.repo().tree() . '/'
let rev = self.spec()[strlen(self.repo().tree()) : -1] let rev = self.spec()[strlen(self.repo().tree()) : -1]
endif endif
return s:sub(s:sub(rev,'.\zs/$',''),'^/',a:0 ? a:1 : '') return s:sub(s:sub(rev,'.\zs/$',''),'^/',a:0 ? a:1 : '')
@@ -1870,14 +1870,19 @@ endfunction
function! s:github_url(repo,url,rev,commit,path,type,line1,line2) abort function! s:github_url(repo,url,rev,commit,path,type,line1,line2) abort
let path = a:path let path = a:path
let domain_pattern = 'github\.com' let domain_pattern = 'github\.com'
for domain in exists('g:fugitive_github_domains') ? g:fugitive_github_domains : [] let domains = exists('g:fugitive_github_domains') ? g:fugitive_github_domains : []
let domain_pattern .= '\|' . escape(domain, '.') for domain in domains
let domain_pattern .= '\|' . escape(split(domain, '://')[-1], '.')
endfor endfor
let repo = matchstr(a:url,'^\%(https\=://\|git://\|git@\)\zs\('.domain_pattern.'\)[/:].\{-\}\ze\%(\.git\)\=$') let repo = matchstr(a:url,'^\%(https\=://\|git://\|git@\)\zs\('.domain_pattern.'\)[/:].\{-\}\ze\%(\.git\)\=$')
if repo ==# '' if repo ==# ''
return '' return ''
endif endif
let root = 'https://' . s:sub(repo,':','/') if index(domains, 'http://' . matchstr(repo, '^[^:/]*')) >= 0
let root = 'http://' . s:sub(repo,':','/')
else
let root = 'https://' . s:sub(repo,':','/')
endif
if path =~# '^\.git/refs/heads/' if path =~# '^\.git/refs/heads/'
let branch = a:repo.git_chomp('config','branch.'.path[16:-1].'.merge')[11:-1] let branch = a:repo.git_chomp('config','branch.'.path[16:-1].'.merge')[11:-1]
if branch ==# '' if branch ==# ''