Handle filenames which has ":" (#9000)

* Fixes #8773 issue

* added test for #8773 issue

* skip test for windows
This commit is contained in:
Karan Jakhar
2023-02-14 11:21:32 +00:00
committed by GitHub
parent eff775c760
commit 73497dae9e
2 changed files with 9 additions and 0 deletions
+2
View File
@@ -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}://")
+7
View File
@@ -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")