Skip to content

Commit

Permalink
add temporary svn, hg and nosync supports
Browse files Browse the repository at this point in the history
  • Loading branch information
tsukkee committed May 3, 2011
1 parent d661baf commit 9d3546e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
15 changes: 12 additions & 3 deletions autoload/vundle/config.vim
Expand Up @@ -23,7 +23,7 @@ func! vundle#config#require(bundles) abort
endf

func! vundle#config#init_bundle(name, opts)
let opts = extend(s:parse_options(a:opts), s:parse_name(substitute(a:name,"['".'"]\+','','g')))
let opts = extend(s:parse_options(a:opts), s:parse_name(substitute(a:name,"['".'"]\+','','g')), 'keep')

This comment has been minimized.

Copy link
@gmarik

gmarik May 3, 2011

can't see where keep is used...

This comment has been minimized.

Copy link
@gmarik

gmarik May 3, 2011

hah, i didn't know about 'keep'

This comment has been minimized.

Copy link
@tsukkee

tsukkee May 3, 2011

Author Owner

I use 'keep' to set arguments of :Bundle above an return value of s:parse_name().
This also can be written like bellow:
let opts = extend(s:parse_name(substitute(a:name,"['".'"]+','','g')), s:parse_options(a:opts)), 'force')
For more detail, please see :help extend().

return extend(opts, copy(s:bundle))
endf

Expand All @@ -44,16 +44,25 @@ func! s:parse_name(arg)
\ || arg =~? '^\w[a-z0-9-]\+/[^/]\+$'
let uri = 'https://github.com/'.split(arg, ':')[-1]
let name = substitute(split(uri,'\/')[-1], '\.git\s*$','','i')
let type = 'git'
elseif arg =~? '^\s*\(git@\|git://\)\S\+'
\ || arg =~? '(file|https\?)://'
\ || arg =~? '\(file\|https\?\|svn\)://'
\ || arg =~? '\.git\s*$'
let uri = arg
let name = split( substitute(uri,'/\?\.git\s*$','','i') ,'\/')[-1]
if uri =~? 'svn'

This comment has been minimized.

Copy link
@gmarik

gmarik May 3, 2011

this is a risky business, though...;)

This comment has been minimized.

Copy link
@tsukkee

tsukkee May 3, 2011

Author Owner

Yes, I know... but it's difficult to detect an repository type from uri :)

let type = 'svn'
elseif uri =~? 'hg' || uri =~? 'https\?://bitbucket'
let type = 'hg'
else
let type = 'git'
endif
else
let name = arg
let uri = 'https://github.com/vim-scripts/'.name.'.git'
let type = 'git'
endif
return {'name': name, 'uri': uri }
return {'name': name, 'uri': uri, 'type': type}
endf

func! s:rtp_rm_a()
Expand Down
27 changes: 23 additions & 4 deletions autoload/vundle/installer.vim
Expand Up @@ -62,12 +62,31 @@ func! s:helptags(rtp) abort
endf

func! s:sync(bang, bundle) abort
let git_dir = expand(a:bundle.path().'/.git')
if isdirectory(git_dir)
if a:bundle.type == 'nosync' | return 1 | endif

let repo_dir = expand(a:bundle.path().'/.'.a:bundle.type)
if isdirectory(repo_dir)
if !(a:bang) | return 0 | endif
let cmd = 'cd '.shellescape(a:bundle.path()).' && git pull'
let cmd = 'cd '.shellescape(a:bundle.path()).' && '
if a:bundle.type == 'svn'
let cmd .= 'svn up'
elseif a:bundle.type == 'hg'
let cmd .= 'hg pull && hg up'
elseif a:bundle.type == 'git'
let cmd .= 'git pull'
else
let cmd = ''
endif
else
let cmd = 'git clone '.a:bundle.uri.' '.shellescape(a:bundle.path())
if a:bundle.type == 'svn'
let cmd = 'svn checkout '.a:bundle.uri.' '.shellescape(a:bundle.path())
elseif a:bundle.type == 'hg'
let cmd = 'hg clone '.a:bundle.uri.' '.shellescape(a:bundle.path())
elseif a:bundle.type == 'git'
let cmd = 'git clone '.a:bundle.uri.' '.shellescape(a:bundle.path())
else
let cmd = ''
endif
endif
silent exec '!'.cmd
return 1
Expand Down

2 comments on commit 9d3546e

@gmarik
Copy link

@gmarik gmarik commented on 9d3546e May 3, 2011

Choose a reason for hiding this comment

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

Cool!
That's actually what I've been working on too...)

@tsukkee
Copy link
Owner Author

@tsukkee tsukkee commented on 9d3546e May 3, 2011

Choose a reason for hiding this comment

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

Thanks, but this is very temporary version.
I believe you will be able to make much better one!

Please sign in to comment.