From 73497dae9e7a59444b3bc5cf5b0c34f3a3274f4e Mon Sep 17 00:00:00 2001 From: Karan Jakhar Date: Tue, 14 Feb 2023 16:51:32 +0530 Subject: [PATCH] Handle filenames which has ":" (#9000) * Fixes #8773 issue * added test for #8773 issue * skip test for windows --- dvc/config_schema.py | 2 ++ tests/func/test_add.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/dvc/config_schema.py b/dvc/config_schema.py index 01c32f8b6..96c20995c 100644 --- a/dvc/config_schema.py +++ b/dvc/config_schema.py @@ -51,6 +51,8 @@ def ByUrl(mapping): # Windows absolute paths should really have scheme == "" (local) if os.name == "nt" and len(parsed.scheme) == 1 and parsed.netloc == "": return schemas[""](data) + if parsed.netloc == "": + return schemas[""](data) if parsed.scheme not in schemas: raise Invalid(f"Unsupported URL type {parsed.scheme}://") diff --git a/tests/func/test_add.py b/tests/func/test_add.py index f3898ee4d..ab48de101 100644 --- a/tests/func/test_add.py +++ b/tests/func/test_add.py @@ -342,6 +342,13 @@ def test_double_add_unchanged_dir(tmp_dir, dvc): assert ret == 0 +@pytest.mark.skipif(os.name == "nt", reason="unsupported on Windows") +def test_add_colon_in_filename(tmp_dir, dvc): + tmp_dir.gen("fo:o", "foo") + ret = main(["add", "fo:o"]) + assert ret == 0 + + def test_should_update_state_entry_for_file_after_add(mocker, dvc, tmp_dir): file_md5_counter = mocker.spy(dvc_data.hashfile.hash, "file_md5") tmp_dir.gen("foo", "foo")