Closed stardiviner closed 12 years ago
You're right. We could use hooks for that. Do you want to write the code which gets current hash first, then writes the log to vam's log function afterwards?
See
let s:c['pre_update_hook_functions'] = get(s:c, 'pre_update_hook_functions', ['vam#install#CreatePatch'])
let s:c['post_update_hook_functions'] = get(s:c, 'post_update_hook_functions', ['vam#install#ApplyPatch'])
Maybe call them vam#install#GitLogPostUpdateHook and vam#intsall#GitDiffPostUpdateHook.
You can add additional hooks easily. Thus check for an existing .git directory, then run your code.
We can talk about whether we want to add global options such as add git_short_log_to_log or git_diff_to_log or whether asking users to set pre/post_update_hook_functions is enough?
I learned VimL for three days, maybe four days, so I do not have ability to write code for VAM. (shape my own idea into code is cool, but I cannot now.)
Hooks are good method.
I think a better way is support default hooks, but they are enabled with options. and VAM also support a common easy way to let user custom their hooks. If VAM support common easy way to let user custom hooks, I think this will be a big feature. Just like a wrapper to manipulate repo info. But in other words, I feel it is not necessary to build a big tool to do this. (confused on myself, :) )
more think about VAM: VAM is a tool to fetch plugins, user custom behavior of saving plugin, show update info, etc. So VAM is a tool like this:
Github \
Mercurial \ / how to save plugin
tar.gz \ / show update info
vim.org + VAM + (maybe contribute code in VAM subdirectories directly...)
.... / \ Users can do much more as they think.
Excerpts from stardiviner's message of Mon Aug 06 11:01:29 +0200 2012:
I learned VimL for three days, maybe four days, which should be enough. Have a look at the function ApplyPatch, copy paste it and you're done.
if isdirectory(a:pluginDir.'/.git')
call vam#utils#ExecInDir(a:pluginDir, 'git log ..'')
endif
Then add to your .vimrc (somewhere at the beginning)
let g:vim_addon_manager = {} let g:vim_addon_manager.post_update_hook_functions = [ "vam#install#ApplyPatch", "YourNewGitFunction"]
Then you can test. Testing is easy by using "get reset --hard HEAD~5" in a plugin repo (your changes which should not exist would be lost) - so that 5 log messages will appear again.
I think this is fun rather than hard work, do you agree? Let me know if you have trouble with anything else. When you're done sent a patch.
I copy this:
if isdirectory(a:pluginDir . '/.git')
call vam#utils#ExecInDir(a:pluginDir, 'git --pretty=format:%s HEAD..FETCH_HEAD')
endif
into vim-addon-manager/autoload/vam/install.vim
file.
Then I write in vimrc
with:
function! VAMShowUpdates() abort
!git fetch origin
!git log --pretty=format:%s HEAD..FETCH_HEAD
endfunction
Is this correct ?
I try to run :UpdateAddons
command, no update found, test later.
Seems does not work, VAM does not show up those updates.
See last commit
Very cool. Even I can not understand your commit...
I hope to see commit messages. so that I can know what changed, for example:
git fetch
->git log --pretty=format:%s HEAD..FETCH_HEAD
. then merge them. If someone has a better way, welcome.About some plugin which is not managed with Git, maybe VAM can parse their doc, README files, to checkout the updated diff log. (I think this is very diffcult.)
But I think this feature on git must be implemented, of course, other VCS can too.