Skip to content

Commit

Permalink
tools.vpm: improve handling of urls that end with .git (#19758)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Nov 4, 2023
1 parent bb46324 commit 55db150
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/tools/vpm/install.v
Expand Up @@ -43,7 +43,7 @@ fn vpm_install(requested_modules []string, opts []string) {
eprintln('Errors while parsing module url "${raw_url}" : ${err}')
continue
}
mod_name := url.path.all_after_last('/')
mod_name := url.path.all_after_last('/').replace('.git', '')
if mod_name in installed_modules {
already_installed << mod_name
i_deleted << i
Expand Down Expand Up @@ -150,7 +150,7 @@ fn vpm_install_from_vcs(modules []string, vcs &VCS) {
}
// Module identifier based on URL.
// 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 {
errors++
eprintln('Errors while retrieving module name for: "${url}"')
Expand Down
3 changes: 3 additions & 0 deletions cmd/tools/vpm/install_test.v
Expand Up @@ -63,6 +63,9 @@ fn test_install_already_existent() {
}
assert mod.name == 'markdown'
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() {
Expand Down

0 comments on commit 55db150

Please sign in to comment.