Skip to content

Commit

Permalink
Create Changelog when performing BundleInstall!
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zolrath committed Apr 10, 2012
1 parent dd8356a commit 0956084
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 7 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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! )
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions autoload/vundle.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 15 additions & 0 deletions autoload/vundle/installer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -222,13 +223,27 @@ func! s:sync(bang, bundle) abort
return 'todate'
end

call s:add_to_updated_bundle_list(a:bundle)
return 'updated'
endf

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)

This comment has been minimized.

Copy link
@gmarik

gmarik Apr 17, 2012

i don't think the above 3 lines are needed here , as return 'updated'(:227) means that there were changes made.
You can probably just add it tog:updated_bundles

This comment has been minimized.

Copy link
@zolrath

zolrath Apr 17, 2012

Author Owner

The only problem with return 'updated' is that both new Bundles and Updated Bundles return 'updated'
The check for git rev-list vundle_update returning a v:shell_error makes sure that we don't get garbage output with new bundles, though comparing the two commits is entirely unnecessary.

Without checking for v:shell_error:

Updated Bundle: ZoomWin
Compare at: https://github.com/vim-scripts/ZoomWin/compare/fatal: amb...HEAD
  fatal: ambiguous argument 'vundle_update..HEAD': unknown revision or path not in the working tree.
  Use '--' to separate paths from revisions

This comment has been minimized.

Copy link
@gmarik

gmarik Apr 17, 2012

I see, maybe we need to add new status then, so we can distinguish betwen new/updates

This comment has been minimized.

Copy link
@zolrath

zolrath Apr 17, 2012

Author Owner

Added a new status in the newest 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)
Expand Down
29 changes: 29 additions & 0 deletions autoload/vundle/scripts.vim
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,33 @@ func! s:view_log()
wincmd P | wincmd H
endf

func! s:create_changelog() abort
for bundle in g:updated_bundles

This comment has been minimized.

Copy link
@gmarik

gmarik Apr 17, 2012

Can we also have :ChangeLog not depend on g:vundle_changelog?
Since we have tags :ChangeLog may be generated any time (therefore do not depend on :BundleInstall)

This comment has been minimized.

Copy link
@zolrath

zolrath Apr 17, 2012

Author Owner

My first pass simply went through and compared all the vundle_update tags to HEAD and built a Changelog for the modified Bundles but it took significantly longer to build the Changelog. I thought it had frozen the first time I ran that version, which doesn't seem like a good user experience.
Thoughts?

This comment has been minimized.

Copy link
@gmarik

gmarik Apr 17, 2012

yeah, this will require making it unbuffered (write updates to the window itself instead of array).
Can't be 100% positive if it's possible tho )

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
Expand Down Expand Up @@ -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 <buffer> q :silent bd!<CR>
nnoremap <buffer> D :exec 'Delete'.getline('.')<CR>
Expand All @@ -91,6 +119,7 @@ func! vundle#scripts#view(title, headers, results)
nnoremap <buffer> I :exec 'InstallAndRequire'.substitute(getline('.'), '^Bundle ', 'Bundle! ', '')<CR>
nnoremap <buffer> l :VundleLog<CR>
nnoremap <buffer> u :VundleChangelog<CR>
nnoremap <buffer> h :h vundle<CR>
nnoremap <buffer> ? :norm h<CR>
Expand Down
3 changes: 2 additions & 1 deletion doc/vundle.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down Expand Up @@ -175,7 +176,7 @@ confirms removal of unused script-dirs from `.vim/bundle/`.

*BundleClean!*
>
:BundleClean!
:BundleClean!
removes unused dirs with no questions.

Expand Down

4 comments on commit 0956084

@gmarik
Copy link

@gmarik gmarik commented on 0956084 Apr 17, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing else I guess.

Let me know what you think!
Thank you!

@zolrath
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I implemented the new and updated status changes in the newest commit!
If you'd like to look at the previous implementation that iterated over each Bundle looking for updates with the tags I've included both versions in a gist: https://gist.github.com/2409649

As is I would prefer to go with the version that builds an updated_bundle list as we update Bundles so the user has a fluid experience.

@gmarik
Copy link

@gmarik gmarik commented on 0956084 Apr 18, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge latest Vundle and let me know what you think!

@gmarik
Copy link

@gmarik gmarik commented on 0956084 Apr 18, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for gist, i'm ok going with updated_bundles as initial version, since we've minimized extra work down to tag creation during installation process...

Please sign in to comment.