mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-13 05:43:52 -05:00
Provide :Gedit - to open previous :Git output
Also, provide :GBrowse - to open the first URL contained in that output.
This commit is contained in:
@@ -2321,6 +2321,20 @@ function! s:TempState(...) abort
|
|||||||
return get(s:temp_files, s:cpath(fnamemodify(a:0 ? a:1 : @%, ':p')), {})
|
return get(s:temp_files, s:cpath(fnamemodify(a:0 ? a:1 : @%, ':p')), {})
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! fugitive#Result(...) abort
|
||||||
|
if !a:0 || a:1 =~# '^-\=$'
|
||||||
|
return get(g:, '_fugitive_last_job', {})
|
||||||
|
elseif type(a:1) == type(0)
|
||||||
|
return s:TempState(bufname(a:1))
|
||||||
|
elseif type(a:1) == type('')
|
||||||
|
return s:TempState(a:1)
|
||||||
|
elseif type(a:1) == type({}) && has_key(a:1, 'file')
|
||||||
|
return s:TempState(a:1.file)
|
||||||
|
else
|
||||||
|
return {}
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:TempReadPre(file) abort
|
function! s:TempReadPre(file) abort
|
||||||
if has_key(s:temp_files, s:cpath(a:file))
|
if has_key(s:temp_files, s:cpath(a:file))
|
||||||
let dict = s:temp_files[s:cpath(a:file)]
|
let dict = s:temp_files[s:cpath(a:file)]
|
||||||
@@ -4741,6 +4755,14 @@ function! s:OpenParse(string, wants_cmd) abort
|
|||||||
endwhile
|
endwhile
|
||||||
if len(args)
|
if len(args)
|
||||||
let file = join(args)
|
let file = join(args)
|
||||||
|
if file ==# '-'
|
||||||
|
let result = fugitive#Result()
|
||||||
|
if has_key(result, 'file')
|
||||||
|
let file = s:fnameescape(result.file)
|
||||||
|
else
|
||||||
|
throw 'fugitive: no previous command output'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
elseif empty(expand('%'))
|
elseif empty(expand('%'))
|
||||||
let file = ''
|
let file = ''
|
||||||
elseif empty(s:DirCommitFile(@%)[1]) && s:Relative('./') !~# '^\./\.git\>'
|
elseif empty(s:DirCommitFile(@%)[1]) && s:Relative('./') !~# '^\./\.git\>'
|
||||||
@@ -5932,10 +5954,19 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo
|
|||||||
endif
|
endif
|
||||||
let validremote = '\.\|\.\=/.*\|[[:alnum:]_-]\+\%(://.\{-\}\)\='
|
let validremote = '\.\|\.\=/.*\|[[:alnum:]_-]\+\%(://.\{-\}\)\='
|
||||||
if arg ==# '-'
|
if arg ==# '-'
|
||||||
if a:count >= 0
|
let remote = ''
|
||||||
return 'echoerr ' . string('fugitive: ''-'' no longer required to get persistent URL if range given')
|
let rev = ''
|
||||||
else
|
let result = fugitive#Result()
|
||||||
return 'echoerr ' . string('fugitive: use :0GBrowse instead of :GBrowse -')
|
if filereadable(get(result, 'file', ''))
|
||||||
|
for line in readfile(result.file, 4096)
|
||||||
|
let rev = s:fnameescape(matchstr(line, '\<https\=://[^[:space:]<>]*[^[:space:]<>.,;:"''!?]'))
|
||||||
|
if len(rev)
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
if empty(rev)
|
||||||
|
return 'echoerr ' . string('fugitive: no URL found in output of last :Git')
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
elseif !exists('l:remote')
|
elseif !exists('l:remote')
|
||||||
let remote = matchstr(arg, '@\zs\%('.validremote.'\)$')
|
let remote = matchstr(arg, '@\zs\%('.validremote.'\)$')
|
||||||
|
|||||||
@@ -590,6 +590,7 @@ Makefile The file named Makefile in the work tree
|
|||||||
!3^2 The second parent of the commit owning buffer #3
|
!3^2 The second parent of the commit owning buffer #3
|
||||||
.git/config The repo config file
|
.git/config The repo config file
|
||||||
: The |fugitive-summary| buffer.
|
: The |fugitive-summary| buffer.
|
||||||
|
- A temp file containing the last |:Git| invocation's output
|
||||||
|
|
||||||
STATUSLINE *fugitive-statusline*
|
STATUSLINE *fugitive-statusline*
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user