Skip to content

Commit 734d9a1

Browse files
nfischerjunegunn
authored andcommitted
Use 'rtp' option to filter diff (#798)
Previously, `:PlugDiff` would show every new commit to a plugin's git repo. This makes sense for the general case, but makes less sense when a plugin lives in a subdirectory of the repo (and is configured with the 'rtp' option). This makes it difficult to determine which commits relate to the plugin and which are unrelated. This changes `:PlugDiff` to filter out any commits outside of the 'rtp' folder. Some consequences: * This does not change the `:PlugUpdate` UI. This means `:PlugUpdate` may pull down non-plugin commits, display that it has updated the plugin, and then `:PlugDiff` will show no updates (since such commits fall out of the 'rtp' path). * It also means there's no UI to revert non-plugin updates, as they don't show up in `:PlugDiff`.
1 parent b6050d6 commit 734d9a1

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

plug.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2420,7 +2420,11 @@ function! s:diff()
24202420
call s:append_ul(2, origin ? 'Pending updates:' : 'Last update:')
24212421
for [k, v] in plugs
24222422
let range = origin ? '..origin/'.v.branch : 'HEAD@{1}..'
2423-
let diff = s:system_chomp('git log --graph --color=never '.join(map(['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range], 's:shellesc(v:val)')), v.dir)
2423+
let cmd = 'git log --graph --color=never '.join(map(['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range], 's:shellesc(v:val)'))
2424+
if has_key(v, 'rtp')
2425+
let cmd .= ' -- '.s:shellesc(v.rtp)
2426+
endif
2427+
let diff = s:system_chomp(cmd, v.dir)
24242428
if !empty(diff)
24252429
let ref = has_key(v, 'tag') ? (' (tag: '.v.tag.')') : has_key(v, 'commit') ? (' '.v.commit) : ''
24262430
call append(5, extend(['', '- '.k.':'.ref], map(s:lines(diff), 's:format_git_log(v:val)')))

test/workflow.vader

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,51 @@ Execute (PlugDiff):
537537
Assert !empty(mapcheck("\<cr>"))
538538
q
539539

540+
Execute (Do not show diff for commits outside of rtp):
541+
call plug#begin()
542+
call plug#end()
543+
PlugClean!
544+
545+
call plug#begin()
546+
Plug 'file://'.expand('$PLUG_FIXTURES').'/xxx'
547+
Plug 'file://'.expand('$PLUG_FIXTURES').'/yyy', { 'rtp': 'rtp' }
548+
call plug#end()
549+
PlugInstall
550+
Log getline(1, '$')
551+
552+
call system('cd "$PLUG_FIXTURES/xxx" && git commit --allow-empty -m update-xxx && git tag -f xxx')
553+
call system('cd "$PLUG_FIXTURES/yyy" && git commit --allow-empty -m update-yyy && git tag -f yyy')
554+
555+
let g:plugs.yyy.tag = 'yyy'
556+
PlugUpdate
557+
Log getline(1, '$')
558+
559+
PlugDiff
560+
" 1 plugin(s) updated.
561+
" [==]
562+
"
563+
" Last update:
564+
" ------------
565+
"
566+
" - xxx:
567+
" * 7faa9b2 update-xxx (0 seconds ago)
568+
"
569+
" Pending updates:
570+
" ----------------
571+
"
572+
" N/A
573+
"
574+
Log getline(1, '$')
575+
AssertEqual 14, line('$')
576+
AssertEqual '1 plugin(s) updated.', getline(1)
577+
AssertEqual '[==]', getline(2)
578+
AssertEqual 'Last update:', getline(4)
579+
AssertEqual '- xxx:', getline(7)
580+
Assert !empty(mapcheck('o'))
581+
Assert !empty(mapcheck('X'))
582+
Assert !empty(mapcheck("\<cr>"))
583+
q
584+
540585
**********************************************************************
541586
~ On-demand loading / Partial installation/update ~
542587
**********************************************************************

0 commit comments

Comments
 (0)