tools.vpm: improve handling of urls that end with .git (#19758)

This commit is contained in:
Turiiya 2023-11-04 09:11:48 +01:00 committed by GitHub
parent bb463246b6
commit 55db150fe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -43,7 +43,7 @@ fn vpm_install(requested_modules []string, opts []string) {
eprintln('Errors while parsing module url "${raw_url}" : ${err}') eprintln('Errors while parsing module url "${raw_url}" : ${err}')
continue continue
} }
mod_name := url.path.all_after_last('/') mod_name := url.path.all_after_last('/').replace('.git', '')
if mod_name in installed_modules { if mod_name in installed_modules {
already_installed << mod_name already_installed << mod_name
i_deleted << i i_deleted << i
@ -150,7 +150,7 @@ fn vpm_install_from_vcs(modules []string, vcs &VCS) {
} }
// Module identifier based on URL. // Module identifier based on URL.
// E.g.: `https://github.com/owner/awesome-v-project` -> `owner/awesome_v_project` // E.g.: `https://github.com/owner/awesome-v-project` -> `owner/awesome_v_project`
mut ident := url.path#[1..].replace('-', '_') mut ident := url.path#[1..].replace('-', '_').replace('.git', '')
owner, repo_name := ident.split_once('/') or { owner, repo_name := ident.split_once('/') or {
errors++ errors++
eprintln('Errors while retrieving module name for: "${url}"') eprintln('Errors while retrieving module name for: "${url}"')

View File

@ -63,6 +63,9 @@ fn test_install_already_existent() {
} }
assert mod.name == 'markdown' assert mod.name == 'markdown'
assert mod.dependencies == []string{} assert mod.dependencies == []string{}
// The same module but with the `.git` extension added.
os.execute_or_exit('${v} install https://github.com/vlang/markdown.git')
assert res.output.contains('already exists')
} }
fn test_install_once() { fn test_install_once() {