Skip to content

Artifact does not get added to .gitignore on failed multi-add #4143

@pared

Description

@pared

Following test passes:

def test_add_multiple_with_exception(tmp_dir, scm, dvc, mocker):
    tmp_dir.gen({"file": "file content", "other": "other file content"})
    original_move = dvc.cache.local.tree.move

    def raise_move(from_info, to_info, mode=None):
        if str(from_info) == "other":
            raise Exception
        else:
            original_move(from_info, to_info, mode)

    assert not (tmp_dir / ".gitignore").exists()
    mocker.patch.object(dvc.cache.local.tree, "move", side_effect=raise_move)
    try:
        dvc.add(["file", "other"])
    except:
        pass
    assert (tmp_dir / "file.dvc").exists()
    assert (tmp_dir / ".gitignore").exists()
    assert (tmp_dir / ".gitignore").read_text() == ''

How it should be?
.gitignore should contain file even though the whole add command failed. As of now, we end up successfully adding file to dvc but it is not ignored. At least we should be informed about potential problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDid we break something?p2-mediumMedium priority, should be done, but less important

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions