From d9ffe511cf3078c6e9d96264f2150a2d6dca5dba Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Fri, 15 Feb 2013 15:16:30 +0000 Subject: [PATCH 1/9] CHNAGED: Added function to make list of bundles with commits,branches and tags --- autoload/vundle/scripts.vim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/autoload/vundle/scripts.vim b/autoload/vundle/scripts.vim index ded6a46a..dab9ec51 100644 --- a/autoload/vundle/scripts.vim +++ b/autoload/vundle/scripts.vim @@ -74,6 +74,20 @@ func! s:view_changelog() wincmd P | wincmd H endf +func! vundle#scripts#get_bundles() + let branch_bundles = filter(copy(g:bundles), "has_key(v:val, 'branch')") + let commit_bundles = filter(copy(g:bundles), "has_key(v:val, 'commit')") + let tag_bundles = filter(copy(g:bundles), "has_key(v:val, 'tag')") + let plain_bundles = filter(copy(g:bundles), "! has_key(v:val, 'tag') && ! has_key(v:val, 'commit') && ! has_key(v:val, 'branch')") + + let branch_bundle_names = map(copy(branch_bundles), 'printf("%s, branch:%s", v:val.name_spec, v:val.branch )') + let commit_bundle_names = map(copy(commit_bundles), 'printf("%s, commit:%s", v:val.name_spec, v:val.commit )') + let tag_bundle_names = map(copy(tag_bundles) , 'printf("%s, tag:%s", v:val.name_spec, v:val.tag )') + let plain_bundle_names = map(copy(plain_bundles) , 'v:val.name_spec') + + return extend(extend(extend(plain_bundle_names, branch_bundle_names), commit_bundle_names), tag_bundle_names) +endf + func! vundle#scripts#bundle_names(names) return map(copy(a:names), ' printf("Bundle ' ."'%s'".'", v:val) ') endf From d31be49a6ec0dd32a2b5c22461a1355d8a99f901 Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Fri, 15 Feb 2013 15:16:49 +0000 Subject: [PATCH 2/9] CHANGED: Installer uses newly created function --- autoload/vundle/installer.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index c4d05802..ff37a617 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -3,7 +3,7 @@ func! vundle#installer#new(bang, ...) abort \ g:bundles : \ map(copy(a:000), 'vundle#config#bundle(v:val, {})') - let names = vundle#scripts#bundle_names(map(copy(bundles), 'v:val.name_spec')) + let names = vundle#scripts#bundle_names(vundle#scripts#get_bundles()) call vundle#scripts#view('Installer',['" Installing bundles to '.expand(g:bundle_dir, 1)], names + ['Helptags']) call s:process(a:bang, (a:bang ? 'add!' : 'add')) @@ -125,7 +125,8 @@ func! vundle#installer#helptags(bundles) abort endf func! vundle#installer#list(bang) abort - let bundles = vundle#scripts#bundle_names(map(copy(g:bundles), 'v:val.name_spec')) + + let bundles = vundle#scripts#bundle_names(vundle#scripts#get_bundles()) call vundle#scripts#view('list', ['" My Bundles'], bundles) redraw echo len(g:bundles).' bundles configured' From 3c61f0349ff4332757eab9925f19c0ce26e596b1 Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Fri, 15 Feb 2013 15:18:49 +0000 Subject: [PATCH 3/9] CHANGED: parses passed options and adds the corresponding item to dictionary --- autoload/vundle/config.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/autoload/vundle/config.vim b/autoload/vundle/config.vim index 55c7d7d0..8131f345 100644 --- a/autoload/vundle/config.vim +++ b/autoload/vundle/config.vim @@ -33,11 +33,13 @@ endf func! s:parse_options(opts) " TODO: improve this if len(a:opts) != 1 | return {} | endif - if type(a:opts[0]) == type({}) return a:opts[0] else - return {'rev': a:opts[0]} + let foo = split(a:opts[0], ':') + let type = foo[0] + let name = foo[1] + return {type : name} endif endf From 9008ff04350662025b799e6327b03d7e36246ab1 Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Fri, 15 Feb 2013 16:43:44 +0000 Subject: [PATCH 4/9] CHANGED: Refactored to append any given options --- autoload/vundle/scripts.vim | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/autoload/vundle/scripts.vim b/autoload/vundle/scripts.vim index dab9ec51..1d6a460c 100644 --- a/autoload/vundle/scripts.vim +++ b/autoload/vundle/scripts.vim @@ -89,7 +89,19 @@ func! vundle#scripts#get_bundles() endf func! vundle#scripts#bundle_names(names) - return map(copy(a:names), ' printf("Bundle ' ."'%s'".'", v:val) ') + return map(copy(a:names), ' s:split_name(v:val) ') +endf + +func! s:split_name(name) + let split_n = split(a:name, ', ') + if len(split_n) > 1 + let ret_val = printf("Bundle '%s', '%s'", split_n[0], split_n[1]) + else + let ret_val = printf("Bundle '%s'", split_n[0]) + endif + echom 'Retval:' ret_val + + return ret_val endf func! vundle#scripts#view(title, headers, results) From a0d33895e3b79d987be4cf51f1a2a27e612bf4e9 Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Fri, 15 Feb 2013 16:59:21 +0000 Subject: [PATCH 5/9] CHANGED: rev information gets passed along through all steps --- autoload/vundle/config.vim | 5 +---- autoload/vundle/installer.vim | 4 +++- autoload/vundle/scripts.vim | 22 +++++++++++++--------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/autoload/vundle/config.vim b/autoload/vundle/config.vim index 8131f345..f629ea4a 100644 --- a/autoload/vundle/config.vim +++ b/autoload/vundle/config.vim @@ -36,10 +36,7 @@ func! s:parse_options(opts) if type(a:opts[0]) == type({}) return a:opts[0] else - let foo = split(a:opts[0], ':') - let type = foo[0] - let name = foo[1] - return {type : name} + return {'rev' : a:opts[0]} endif endf diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index ff37a617..e3ccee50 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -99,8 +99,10 @@ endf func! vundle#installer#install(bang, name) abort if !isdirectory(g:bundle_dir) | call mkdir(g:bundle_dir, 'p') | endif + let args = split(a:name,', ') - let b = vundle#config#init_bundle(a:name, {}) + let opts = (len(args) > 1) ? [substitute(args[1],"'",'','g')] : {} + let b = vundle#config#init_bundle(args[0], opts) return s:sync(a:bang, b) endf diff --git a/autoload/vundle/scripts.vim b/autoload/vundle/scripts.vim index 1d6a460c..c615dce2 100644 --- a/autoload/vundle/scripts.vim +++ b/autoload/vundle/scripts.vim @@ -75,17 +75,21 @@ func! s:view_changelog() endf func! vundle#scripts#get_bundles() - let branch_bundles = filter(copy(g:bundles), "has_key(v:val, 'branch')") - let commit_bundles = filter(copy(g:bundles), "has_key(v:val, 'commit')") - let tag_bundles = filter(copy(g:bundles), "has_key(v:val, 'tag')") - let plain_bundles = filter(copy(g:bundles), "! has_key(v:val, 'tag') && ! has_key(v:val, 'commit') && ! has_key(v:val, 'branch')") - - let branch_bundle_names = map(copy(branch_bundles), 'printf("%s, branch:%s", v:val.name_spec, v:val.branch )') - let commit_bundle_names = map(copy(commit_bundles), 'printf("%s, commit:%s", v:val.name_spec, v:val.commit )') - let tag_bundle_names = map(copy(tag_bundles) , 'printf("%s, tag:%s", v:val.name_spec, v:val.tag )') + "let branch_bundles = filter(copy(g:bundles), "has_key(v:val, 'branch')") + "let commit_bundles = filter(copy(g:bundles), "has_key(v:val, 'commit')") + "let tag_bundles = filter(copy(g:bundles), "has_key(v:val, 'tag')") + "let plain_bundles = filter(copy(g:bundles), "! has_key(v:val, 'tag') && ! has_key(v:val, 'commit') && ! has_key(v:val, 'branch')") + let plain_bundles = filter(copy(g:bundles), "! has_key(v:val, 'rev')") + let rev_bundles = filter(copy(g:bundles), "has_key(v:val, 'rev')") + + "let branch_bundle_names = map(copy(branch_bundles), 'printf("%s, branch:%s", v:val.name_spec, v:val.branch )') + "let commit_bundle_names = map(copy(commit_bundles), 'printf("%s, commit:%s", v:val.name_spec, v:val.commit )') + "let tag_bundle_names = map(copy(tag_bundles) , 'printf("%s, tag:%s", v:val.name_spec, v:val.tag )') let plain_bundle_names = map(copy(plain_bundles) , 'v:val.name_spec') + let rev_bundle_names = map(copy(rev_bundles) , 'printf("%s, %s", v:val.name_spec, v:val.rev )') - return extend(extend(extend(plain_bundle_names, branch_bundle_names), commit_bundle_names), tag_bundle_names) + "return extend(extend(extend(plain_bundle_names, branch_bundle_names), commit_bundle_names), tag_bundle_names) + return extend(plain_bundle_names, rev_bundle_names) endf func! vundle#scripts#bundle_names(names) From 94ce46181cd7e12d9533a81276ec94b5887d3679 Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Fri, 15 Feb 2013 18:33:22 +0000 Subject: [PATCH 6/9] CHANGED: Removed debug echo --- autoload/vundle/scripts.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/autoload/vundle/scripts.vim b/autoload/vundle/scripts.vim index c615dce2..58373efd 100644 --- a/autoload/vundle/scripts.vim +++ b/autoload/vundle/scripts.vim @@ -103,7 +103,6 @@ func! s:split_name(name) else let ret_val = printf("Bundle '%s'", split_n[0]) endif - echom 'Retval:' ret_val return ret_val endf From c529fc3e656e8764ab1dad37004a513efb2ad903 Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Fri, 15 Feb 2013 18:34:08 +0000 Subject: [PATCH 7/9] CHANGED: Refactored run and log calls --- autoload/vundle/installer.vim | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index e3ccee50..c2685dfa 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -223,11 +223,7 @@ func! s:sync(bang, bundle) abort let initial_sha = '' endif - let out = s:system(cmd) - call s:log('') - call s:log('Bundle '.a:bundle.name_spec) - call s:log('$ '.cmd) - call s:log('> '.out) + call s:run_and_log(a:bundle, cmd) if 0 != v:shell_error return 'error' @@ -247,6 +243,15 @@ func! s:sync(bang, bundle) abort return 'updated' endf +func! s:run_and_log(bundle, cmd) + let out = s:system(a:cmd) + + call s:log('') + call s:log('Bundle '.a:bundle.name_spec) + call s:log('$ '.a:cmd) + call s:log('> '.out) +endf + func! g:shellesc(cmd) abort if (has('win32') || has('win64')) if &shellxquote != '(' " workaround for patch #445 From 1deac65ccffead17553d8cb72e0218afc69febee Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Fri, 15 Feb 2013 18:34:28 +0000 Subject: [PATCH 8/9] CHANGED: Added checkout of revision --- autoload/vundle/installer.vim | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index c2685dfa..6a86b163 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -225,6 +225,13 @@ func! s:sync(bang, bundle) abort call s:run_and_log(a:bundle, cmd) + if has_rev + let cmd = 'cd '.shellescape(a:bundle.path()).' && git checkout '.a:bundle.rev + let cmd = g:shellesc_cd(cmd) + + call s:run_and_log(a:bundle, cmd) + endif + if 0 != v:shell_error return 'error' end From 12cc81aae8d0858bca537b8e949e15902da24111 Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Fri, 15 Feb 2013 18:35:31 +0000 Subject: [PATCH 9/9] CHANGED: Added logic to only pull if on any branch and always checkout to master if no revision set --- autoload/vundle/installer.vim | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 6a86b163..7ed65c13 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -211,13 +211,33 @@ func! s:sync(bang, bundle) abort let git_dir = expand(a:bundle.path().'/.git/', 1) if isdirectory(git_dir) || filereadable(expand(a:bundle.path().'/.git', 1)) if !(a:bang) | return 'todate' | endif - let cmd = 'cd '.shellescape(a:bundle.path()).' && git pull && git submodule update --init --recursive' - let cmd = g:shellesc_cd(cmd) + let has_rev = has_key(a:bundle, 'rev') let get_current_sha = 'cd '.shellescape(a:bundle.path()).' && git rev-parse HEAD' let get_current_sha = g:shellesc_cd(get_current_sha) - let initial_sha = s:system(get_current_sha)[0:15] + + if !has_rev + let cmd = 'cd '.shellescape(a:bundle.path()).' && git checkout master' + let cmd = g:shellesc_cd(cmd) + + let initial_sha = s:system(get_current_sha)[0:15] + call s:run_and_log(a:bundle, cmd) + + let on_branch = '' + else + let cmd = 'cd '.shellescape(a:bundle.path()).' && git branch --contains | grep \* | grep "no branch"' + let cmd = g:shellesc_cd(cmd) + let on_branch = s:system(cmd) + + let initial_sha = s:system(get_current_sha)[0:15] + endif + + if len(on_branch) == 0 + let cmd = 'cd '.shellescape(a:bundle.path()).' && git pull && git submodule update --init --recursive' + let cmd = g:shellesc_cd(cmd) + endif + else let cmd = 'git clone --recursive '.shellescape(a:bundle.uri).' '.shellescape(a:bundle.path()) let initial_sha = ''