From 55db150fe12b2f0f75598fd43e88dba4ae2b70fd Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Sat, 4 Nov 2023 09:11:48 +0100 Subject: [PATCH] tools.vpm: improve handling of urls that end with .git (#19758) --- cmd/tools/vpm/install.v | 4 ++-- cmd/tools/vpm/install_test.v | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/tools/vpm/install.v b/cmd/tools/vpm/install.v index c45d1af7b15b7e..397929ae97a988 100644 --- a/cmd/tools/vpm/install.v +++ b/cmd/tools/vpm/install.v @@ -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 @@ -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}"') diff --git a/cmd/tools/vpm/install_test.v b/cmd/tools/vpm/install_test.v index d92c9755091b14..cde26497a4535e 100644 --- a/cmd/tools/vpm/install_test.v +++ b/cmd/tools/vpm/install_test.v @@ -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() {