@@ -2383,7 +2383,9 @@ function! s:git_validate(spec, check_branch)
23832383 let err = join ([' Invalid URI: ' .remote,
23842384 \ ' Expected: ' .a: spec .uri,
23852385 \ ' PlugClean required.' ], " \n " )
2386- elseif a: check_branch && has_key (a: spec , ' commit' )
2386+ elseif ! a: check_branch
2387+ return [' ' , 0 ]
2388+ elseif has_key (a: spec , ' commit' )
23872389 let sha = s: git_revision (a: spec .dir )
23882390 if empty (sha)
23892391 let err = join (add (result, ' PlugClean required.' ), " \n " )
@@ -2392,18 +2394,16 @@ function! s:git_validate(spec, check_branch)
23922394 \ a: spec .commit[:6 ], sha[:6 ]),
23932395 \ ' PlugUpdate required.' ], " \n " )
23942396 endif
2397+ elseif has_key (a: spec , ' tag' )
2398+ let tag = s: system_chomp (' git describe --exact-match --tags HEAD 2>&1' , a: spec .dir )
2399+ if a: spec .tag !=# tag && a: spec .tag !~ ' \*'
2400+ let err = printf (' Invalid tag: %s (expected: %s). Try PlugUpdate.' ,
2401+ \ (empty (tag ) ? ' N/A' : tag ), a: spec .tag )
2402+ endif
23952403 elseif a: check_branch
23962404 let current_branch = result[0 ]
2397- " Check tag
23982405 let origin_branch = s: git_origin_branch (a: spec )
2399- if has_key (a: spec , ' tag' )
2400- let tag = s: system_chomp (' git describe --exact-match --tags HEAD 2>&1' , a: spec .dir )
2401- if a: spec .tag !=# tag && a: spec .tag !~ ' \*'
2402- let err = printf (' Invalid tag: %s (expected: %s). Try PlugUpdate.' ,
2403- \ (empty (tag ) ? ' N/A' : tag ), a: spec .tag )
2404- endif
2405- " Check branch
2406- elseif origin_branch !=# current_branch
2406+ if origin_branch !=# current_branch
24072407 let err = printf (' Invalid branch: %s (expected: %s). Try PlugUpdate.' ,
24082408 \ current_branch, origin_branch)
24092409 endif
0 commit comments