From 958025b62286038844421d6a93528644f66f02fe Mon Sep 17 00:00:00 2001 From: "Alejandro R. Mosteo" Date: Mon, 25 Sep 2023 16:08:44 +0200 Subject: [PATCH] Fix corner case related to git+file:// URLs --- .vscode/launch.json | 24 +++++++++++++++++++ src/alire/alire-origins.adb | 6 +++-- testsuite/tests/get/git-local/test.py | 5 +++- testsuite/tests/publish/bad-arguments/test.py | 2 +- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 87585ec9b..7f4572754 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -23,6 +23,30 @@ ], "console": "integratedTerminal", "justMyCode": false + }, + { + "name": "(gdb) Launch alr at /tmp/a/xxx", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/bin/alr", + "args": ["-d", "-vv", "with", "libfoo"], + "stopAtEntry": true, + "cwd": "/tmp/a/xxx", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set Disassembly Flavor to Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ] } ] } \ No newline at end of file diff --git a/src/alire/alire-origins.adb b/src/alire/alire-origins.adb index 53378ebd2..9fa6be0f1 100644 --- a/src/alire/alire-origins.adb +++ b/src/alire/alire-origins.adb @@ -402,8 +402,10 @@ package body Alire.Origins is Scheme : constant URI.Schemes := URI.Scheme (URL); Transformed : constant Alire.URL := VCSs.Git.Transform_To_Public (URL); VCS_URL : constant String := - (if Contains (URL, "file:") then - Tail (URL, ':') -- Remove file: that confuses git + (if Contains (URL, "+file://") then + Tail (URL, '+') -- strip the VCS proto only + elsif Contains (URL, "+file:") then + Tail (URL, ':') -- Remove file: w.o. // that confuses git elsif Has_Prefix (URL, "git@") and then Transformed /= URL -- known and transformable then diff --git a/testsuite/tests/get/git-local/test.py b/testsuite/tests/get/git-local/test.py index a1ecf5436..edd30a0bf 100644 --- a/testsuite/tests/get/git-local/test.py +++ b/testsuite/tests/get/git-local/test.py @@ -4,7 +4,7 @@ from glob import glob -from drivers.alr import run_alr +from drivers.alr import init_local_crate, run_alr from drivers.asserts import assert_match from drivers.helpers import compare, contents @@ -36,5 +36,8 @@ 'libfoo_1.0.0_9ddda32b/config/libfoo_config.h' ]) +# Check as dependency +init_local_crate() +run_alr("with", "libfoo") # should succeed print('SUCCESS') diff --git a/testsuite/tests/publish/bad-arguments/test.py b/testsuite/tests/publish/bad-arguments/test.py index 1846e392c..4c6f13b7b 100644 --- a/testsuite/tests/publish/bad-arguments/test.py +++ b/testsuite/tests/publish/bad-arguments/test.py @@ -11,7 +11,7 @@ # Bad combo, explicit file + commit p = run_alr("publish", "file:/fake.zip", "deadbeef", complain_on_error=False) -assert_match(".*Expected a VCS origin but got.*", p.out) +assert_match(".*unknown VCS URL", p.out) # Bad combo, implicit file + commit p = run_alr("publish", "fake.zip", "deadbeef", complain_on_error=False)