From 93ab5909784e09134e90f15cafa8a5edcc9a00fe Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 4 Apr 2022 11:52:45 +0900 Subject: [PATCH] Include plugins with 'commit' values in PlugSnapshot output Fix #1167 --- plug.vim | 4 ++-- test/run | 4 ++-- test/workflow.vader | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/plug.vim b/plug.vim index 8a195d3..46416b8 100644 --- a/plug.vim +++ b/plug.vim @@ -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 diff --git a/test/run b/test/run index 23544c2..b0482f8 100755 --- a/test/run +++ b/test/run @@ -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 diff --git a/test/workflow.vader b/test/workflow.vader index 8423b86..0adb116 100644 --- a/test/workflow.vader +++ b/test/workflow.vader @@ -1620,10 +1620,12 @@ Execute (Commit hash support): Assert empty(mapcheck('X')) Assert !empty(mapcheck("\")) - " 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):