Переглянути джерело

Include plugins with 'commit' values in PlugSnapshot output

Fix #1167
Junegunn Choi 3 роки тому
батько
коміт
93ab590978
3 змінених файлів з 8 додано та 6 видалено
  1. 2 2
      plug.vim
  2. 2 2
      test/run
  3. 4 2
      test/workflow.vader

+ 2 - 2
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

+ 2 - 2
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

+ 4 - 2
test/workflow.vader

@@ -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):