From 09560847cad32de2d0aeccb6e599d9bc1fa6e70e Mon Sep 17 00:00:00 2001 From: Matt Furden Date: Wed, 4 Apr 2012 19:26:13 -0700 Subject: [PATCH] Create Changelog when performing BundleInstall! Keeps track of the current commit with a vundle_update tag before perfoming an update and adds all commits pulled in the update to a Changelog accessible via pressing 'u' after BundleInstall! completes. --- README.md | 12 ++++++------ autoload/vundle.vim | 2 ++ autoload/vundle/installer.vim | 15 +++++++++++++++ autoload/vundle/scripts.vim | 29 +++++++++++++++++++++++++++++ doc/vundle.txt | 3 ++- 5 files changed, 54 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9b44641..9de30ce 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Bundle 'git://git.wincent.com/command-t.git' " ... - filetype plugin indent on " required! + filetype plugin indent on " required! " " Brief help " :BundleList - list configured bundles @@ -62,7 +62,7 @@ *Windows users* see [Vundle for Windows](https://github.com/gmarik/vundle/wiki/Vundle-for-Windows) Installing requires [Git] and triggers [Git clone](http://gitref.org/creating/#clone) for each configured repo to `~/.vim/bundle/`. - + 4. Consider [donating](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=T44EJZX8RBUWY) [*Thank you*](http://j.mp/rSbm01) for supporting this project! ) @@ -145,7 +145,7 @@ see [wiki](/gmarik/vundle/wiki) [all available vim scripts]:http://vim-scripts.org/vim/scripts.html [install]:https://github.com/gmarik/vundle/blob/master/doc/vundle.txt#L110-124 -[update]:https://github.com/gmarik/vundle/blob/master/doc/vundle.txt#L128-133 -[search]:https://github.com/gmarik/vundle/blob/master/doc/vundle.txt#L135-157 -[clean]:https://github.com/gmarik/vundle/blob/master/doc/vundle.txt#L167-179 -[interactive mode]:https://github.com/gmarik/vundle/blob/master/doc/vundle.txt#L183-209 +[update]:https://github.com/gmarik/vundle/blob/master/doc/vundle.txt#L128-134 +[search]:https://github.com/gmarik/vundle/blob/master/doc/vundle.txt#L136-158 +[clean]:https://github.com/gmarik/vundle/blob/master/doc/vundle.txt#L168-180 +[interactive mode]:https://github.com/gmarik/vundle/blob/master/doc/vundle.txt#L184-210 diff --git a/autoload/vundle.vim b/autoload/vundle.vim index 096f7cc..b81650a 100644 --- a/autoload/vundle.vim +++ b/autoload/vundle.vim @@ -37,6 +37,8 @@ endif func! vundle#rc(...) abort let g:bundle_dir = len(a:000) > 0 ? expand(a:1, 1) : expand('$HOME/.vim/bundle', 1) + let g:updated_bundles = [] let g:vundle_log = [] + let g:vundle_changelog = ['Updated Bundles:'] call vundle#config#init() endf diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index e2a8291..f1e6dbf 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -204,6 +204,7 @@ func! s:sync(bang, bundle) abort let cmd = substitute(cmd, '^cd ','cd /d ','') " add /d switch to change drives let cmd = '"'.cmd.'"' " enclose in quotes endif + call s:add_update_tag(a:bundle) else let cmd = 'git clone '.a:bundle.uri.' '.shellescape(a:bundle.path()) endif @@ -222,6 +223,7 @@ func! s:sync(bang, bundle) abort return 'todate' end + call s:add_to_updated_bundle_list(a:bundle) return 'updated' endf @@ -229,6 +231,19 @@ func! s:system(cmd) abort return system(a:cmd) endf +func! s:add_update_tag(bundle) abort + call s:system('cd '.shellescape(a:bundle.path()). + \ ' && git tag -a vundle_update -m "Last Vundle Update" -f') +endfunc + +func! s:add_to_updated_bundle_list(bundle) abort + let current_commit = s:system('cd '.shellescape(a:bundle.path()).' && git rev-list HEAD') + let initial_commit = s:system('cd '.shellescape(a:bundle.path()).' && git rev-list vundle_update') + if (0 == v:shell_error) && (initial_commit != current_commit) + call add(g:updated_bundles, a:bundle) + endif +endfunc + func! s:log(str) abort let fmt = '%y%m%d %H:%M:%S' call add(g:vundle_log, '['.strftime(fmt).'] '.a:str) diff --git a/autoload/vundle/scripts.vim b/autoload/vundle/scripts.vim index 324c281..1d4b185 100644 --- a/autoload/vundle/scripts.vim +++ b/autoload/vundle/scripts.vim @@ -33,6 +33,33 @@ func! s:view_log() wincmd P | wincmd H endf +func! s:create_changelog() abort + for bundle in g:updated_bundles + let updates = system('cd '.shellescape(bundle.path()). + \ ' && git log --pretty=format:"%s %an, %ar" --graph'. + \ ' vundle_update..HEAD') + call add(g:vundle_changelog, '') + call add(g:vundle_changelog, 'Updated Bundle: '.bundle.name) + for update in split(updates, '\n') + let update = substitute(update, '\s\+$', '', '') + call add(g:vundle_changelog, ' '.update) + endfor + endfor +endf + +func! s:view_changelog() + call s:create_changelog() + + if !exists('g:vundle_changelog_file') + let g:vundle_changelog_file = tempname() + endif + + call writefile(g:vundle_changelog, g:vundle_changelog_file) + silent pedit `=g:vundle_changelog_file` + + wincmd P | wincmd H +endf + func! vundle#scripts#bundle_names(names) return map(copy(a:names), ' printf("Bundle ' ."'%s'".'", v:val) ') endf @@ -80,6 +107,7 @@ func! vundle#scripts#view(title, headers, results) com! -buffer -nargs=0 VundleLog call s:view_log() + com! -buffer -nargs=0 VundleChangelog call s:view_changelog() nnoremap q :silent bd! nnoremap D :exec 'Delete'.getline('.') @@ -91,6 +119,7 @@ func! vundle#scripts#view(title, headers, results) nnoremap I :exec 'InstallAndRequire'.substitute(getline('.'), '^Bundle ', 'Bundle! ', '') nnoremap l :VundleLog + nnoremap u :VundleChangelog nnoremap h :h vundle nnoremap ? :norm h diff --git a/doc/vundle.txt b/doc/vundle.txt index 3049fc9..57e7260 100644 --- a/doc/vundle.txt +++ b/doc/vundle.txt @@ -132,6 +132,7 @@ run > :BundleInstall! " NOTE: bang(!) installs or updates configured scripts. +press u after updates complete to see the changelog of all updated bundles. 4.4 SEARCHING ~ *vundle-scripts-search* *BundleSearch* @@ -175,7 +176,7 @@ confirms removal of unused script-dirs from `.vim/bundle/`. *BundleClean!* > - :BundleClean! + :BundleClean! removes unused dirs with no questions.