Add a command that shows the version or commit

Ref #512
This commit is contained in:
Michael F. Schönitzer 2018-06-12 20:55:56 +02:00 committed by EinfachToll
parent f60923eaa3
commit 9f8b0082db

View File

@ -9,6 +9,11 @@ if exists("g:loaded_vimwiki") || &cp
endif endif
let g:loaded_vimwiki = 1 let g:loaded_vimwiki = 1
" Set to version number for release, otherwise -1 for dev-branch
let s:plugin_vers = -1
" Get the directory the script is installed in
let s:plugin_dir = expand('<sfile>:p:h:h')
let s:old_cpo = &cpo let s:old_cpo = &cpo
set cpo&vim set cpo&vim
@ -186,6 +191,23 @@ function! s:set_windowlocal_options()
endfunction endfunction
function! s:get_version()
if s:plugin_vers != -1
echo "Stable version: " . s:plugin_vers
else
let a:plugin_rev = system("git --git-dir " . s:plugin_dir . "/.git rev-parse --short HEAD")
let a:plugin_branch = system("git --git-dir " . s:plugin_dir . "/.git rev-parse --abbrev-ref HEAD")
let a:plugin_date = system("git --git-dir " . s:plugin_dir . "/.git show -s --format=%ci")
if v:shell_error == 0
echo "Branch: " . a:plugin_branch
echo "Revision: " . a:plugin_rev
echo "Date: " . a:plugin_date
else
echo "Unknown version"
endif
endif
endfunction
" Initialization of Vimwiki starts here. Make sure everything below does not " Initialization of Vimwiki starts here. Make sure everything below does not
@ -279,6 +301,8 @@ command! -count=1 VimwikiMakeTomorrowDiaryNote
command! VimwikiDiaryGenerateLinks command! VimwikiDiaryGenerateLinks
\ call vimwiki#diary#generate_diary_section() \ call vimwiki#diary#generate_diary_section()
command! VimwikiShowVersion call s:get_version()
let s:map_prefix = vimwiki#vars#get_global('map_prefix') let s:map_prefix = vimwiki#vars#get_global('map_prefix')