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
let anchor = line('$') - 3
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)
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)
call append(anchor, printf("silent! let g:plugs['%s'].commit = '%s'", name, sha))
redraw

View File

@ -62,7 +62,7 @@ EOF
gitinit() (
cd "$PLUG_FIXTURES/$1"
git init
git init -b master
git commit -m 'commit' --allow-empty
)
@ -98,7 +98,7 @@ DOC
rm -rf $TEMP/new-branch
cd $TEMP
git init new-branch
git init new-branch -b master
cd new-branch
mkdir plugin
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("\<cr>"))
" Nor in PlugSnapshot output
" The exact hash values in PlugSnapshot output
PlugSnapshot
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
Execute (Commit hash support - cleared):