Include plugins with 'commit' values in PlugSnapshot output

Fix #1167
This commit is contained in:
Junegunn Choi 2022-04-04 11:52:45 +09:00
parent e300178a0e
commit 93ab590978
No known key found for this signature in database
GPG key ID: 254BC280FEF9C627
3 changed files with 8 additions and 6 deletions

View file

@ -2766,9 +2766,9 @@ function! s:snapshot(force, ...) abort
1 1
let anchor = line('$') - 3 let anchor = line('$') - 3
let names = sort(keys(filter(copy(g:plugs), let names = sort(keys(filter(copy(g:plugs),
\'has_key(v:val, "uri") && !has_key(v:val, "commit") && isdirectory(v:val.dir)'))) \'has_key(v:val, "uri") && isdirectory(v:val.dir)')))
for name in reverse(names) for name in reverse(names)
let sha = s:git_revision(g:plugs[name].dir) let sha = has_key(g:plugs[name], 'commit') ? g:plugs[name].commit : s:git_revision(g:plugs[name].dir)
if !empty(sha) if !empty(sha)
call append(anchor, printf("silent! let g:plugs['%s'].commit = '%s'", name, sha)) call append(anchor, printf("silent! let g:plugs['%s'].commit = '%s'", name, sha))
redraw redraw

View file

@ -62,7 +62,7 @@ EOF
gitinit() ( gitinit() (
cd "$PLUG_FIXTURES/$1" cd "$PLUG_FIXTURES/$1"
git init git init -b master
git commit -m 'commit' --allow-empty git commit -m 'commit' --allow-empty
) )
@ -98,7 +98,7 @@ DOC
rm -rf $TEMP/new-branch rm -rf $TEMP/new-branch
cd $TEMP cd $TEMP
git init new-branch git init new-branch -b master
cd new-branch cd new-branch
mkdir plugin mkdir plugin
echo 'let g:foo = 1' > plugin/foo.vim echo 'let g:foo = 1' > plugin/foo.vim

View file

@ -1620,10 +1620,12 @@ Execute (Commit hash support):
Assert empty(mapcheck('X')) Assert empty(mapcheck('X'))
Assert !empty(mapcheck("\<cr>")) Assert !empty(mapcheck("\<cr>"))
" Nor in PlugSnapshot output " The exact hash values in PlugSnapshot output
PlugSnapshot PlugSnapshot
Log getline(1, '$') Log getline(1, '$')
AssertEqual 8, line('$') AssertEqual "silent! let g:plugs['goyo.vim'].commit = 'ffffffff'", getline(6)
AssertEqual "silent! let g:plugs['vim-emoji'].commit = '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a'", getline(7)
AssertEqual 10, line('$')
q q
Execute (Commit hash support - cleared): Execute (Commit hash support - cleared):