Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

packager.add() URL detection #37

Open
sporian-smckown opened this issue Sep 27, 2022 · 1 comment
Open

packager.add() URL detection #37

sporian-smckown opened this issue Sep 27, 2022 · 1 comment

Comments

@sporian-smckown
Copy link

Not an issue per se but an FYI that might suggest a code change.

Deciding if a URL supplied in a packager.add() call is a 'name/repo' for github or not may need to be expanded. Here's a couple of SSH based Git URLs that vim-packager currently misinterprets:

function! s:packager_init(packager) abort
  call a:packager.add('kristijanhusak/vim-packager', { 'type': 'opt' })
  ...
  call a:packager.add('ssh://proj.sporian.com:29418/~smckown/vim-mkbuild.git')
  call a:packager.add('repo.titaniummirror.com:vim-mkbuild.git')
  ...
  call plug#end()
endfunction

My quick and dirty solution is to assume that no valid GitHUb 'name/repo' URL will contain either '@' or ':'.

diff --git i/autoload/packager/plugin.vim w/autoload/packager/plugin.vim
index 73c6425..34040c7 100644
--- i/autoload/packager/plugin.vim
+++ w/autoload/packager/plugin.vim
@@ -27,7 +27,7 @@ function! s:plugin.new(name, opts, packager) abort
     let l:rtp = substitute(l:rtp, '[\\\/]', '__', 'g')
     let l:instance.rtp_dir = printf('%s__%s', l:instance.dir, l:rtp)
   endif
-  let l:instance.url = a:name =~? '^\(http\|git@\).*'
+  let l:instance.url = a:name =~? '\(@\|:\)'
         \ ? a:name
         \ : l:instance.local ? a:name : printf('https://github.com/%s', a:name)
   let l:instance.event_messages = []
@xi
Copy link

xi commented Aug 7, 2023

Not an issue per se

I think this is a real issue. I can think of two cases that are broken with the current detection:

  • SSH with a username that is not "git", e.g. [email protected]/myrepo.git
  • Repos that are only available via the git protocol, e.g. git://example.com/myrepo

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants