예제 #1
0
def test_git_stash_clear(tmp_dir, scm, ref):
    from dvc.scm.git import Stash

    tmp_dir.scm_gen({"file": "0"}, commit="init")
    tmp_dir.gen("file", "1")

    stash = Stash(scm, ref=ref)
    stash.push()

    tmp_dir.gen("file", "2")
    stash.push()

    stash.clear()
    assert len(stash) == 0

    parts = list(stash.ref.split("/"))
    assert not os.path.exists(os.path.join(os.fspath(tmp_dir), ".git", *parts))
    assert not os.path.exists(
        os.path.join(os.fspath(tmp_dir), ".git", "logs", *parts))
예제 #2
0
def test_git_stash_clear(tmp_dir, scm, ref):
    from dvc.scm.git import Stash

    tmp_dir.scm_gen({"file": "0"}, commit="init")
    tmp_dir.gen("file", "1")

    stash = Stash(scm, ref=ref)
    stash.push()

    tmp_dir.gen("file", "2")
    stash.push()

    stash.clear()
    assert len(stash) == 0

    parts = list(stash.ref.split("/"))
    assert not os.path.exists(os.path.join(os.fspath(tmp_dir), ".git", *parts))
    # NOTE: some backends will completely remove reflog file on clear, some
    # will only truncate it, either case means an empty stash
    log_path = os.path.join(os.fspath(tmp_dir), ".git", "logs", *parts)
    assert not os.path.exists(log_path) or not open(log_path).read()