예제 #1
0
def test_head_at_no_move(dataset):
    with orcs.head_at(dataset, "master") as moved:
        assert not moved
        create_tree(dataset.path, {"on-master": "on-maser"})
        dataset.add("on-master", message="advance master")
        assert dataset.repo.get_active_branch() == "master"
    assert dataset.repo.get_active_branch() == "master"
예제 #2
0
def test_head_at_empty_branch(dataset):
    dataset.repo.checkout("orph", options=["--orphan"])
    dataset.repo.call_git(["reset", "--hard"])
    assert not dataset.repo.dirty
    with pytest.raises(OrchestratorError) as exc:
        with orcs.head_at(dataset, "master"):
            pass
    assert "No commit" in str(exc.value)
예제 #3
0
def test_head_at_no_move(dataset):
    repo = dataset.repo
    branch_orig = repo.get_active_branch()
    with orcs.head_at(dataset, branch_orig) as moved:
        assert not moved
        create_tree(dataset.path, {"f0": "on original branch"})
        dataset.save("f0", message="advance branch")
        assert repo.get_active_branch() == branch_orig
    assert repo.get_active_branch() == branch_orig
예제 #4
0
def test_head_at_empty_branch(dataset):
    dataset.repo.checkout("orph", options=["--orphan"])
    # FIXME: Use expose method once available.
    dataset.repo._git_custom_command([], ["git", "reset", "--hard"])
    assert not dataset.repo.dirty
    with pytest.raises(OrchestratorError) as exc:
        with orcs.head_at(dataset, "master"):
            pass
    assert "No commit" in str(exc)
예제 #5
0
def test_head_at_empty_branch(dataset):
    repo = dataset.repo
    branch_orig = repo.get_active_branch()
    repo.checkout("orph", options=["--orphan"])
    repo.call_git(["reset", "--hard"])
    assert not repo.dirty
    with pytest.raises(OrchestratorError) as exc:
        with orcs.head_at(dataset, branch_orig):
            pass
    assert "No commit" in str(exc.value)
예제 #6
0
def test_head_at_move(dataset):
    def dataset_path_exists(path):
        return op.exists(op.join(dataset.path, path))

    create_tree(dataset.path, {"pre": "pre"})
    dataset.add("pre")
    with orcs.head_at(dataset, "master~1") as moved:
        assert moved
        assert dataset.repo.get_active_branch() is None
        assert not dataset_path_exists("pre")
        create_tree(dataset.path, {"at-head": "at-head"})
        dataset.add("at-head", message="advance head (not master)")
    assert dataset_path_exists("pre")
    assert not dataset_path_exists("at-head")
    assert dataset.repo.get_active_branch() == "master"
예제 #7
0
def test_head_at_move(dataset):
    repo = dataset.repo
    branch_orig = repo.get_active_branch()

    def dataset_path_exists(path):
        return op.exists(op.join(dataset.path, path))

    create_tree(dataset.path, {"pre": "pre"})
    dataset.save("pre")
    with orcs.head_at(dataset, branch_orig + "~1") as moved:
        assert moved
        assert repo.get_active_branch() is None
        assert not dataset_path_exists("pre")
        create_tree(dataset.path, {"at-head": "at-head"})
        dataset.save("at-head",
                     message="advance head (not {})".format(branch_orig))
    assert dataset_path_exists("pre")
    assert not dataset_path_exists("at-head")
    assert repo.get_active_branch() == branch_orig
예제 #8
0
def test_orc_datalad_run_change_head(job_spec, dataset, shell):
    with chpwd(dataset.path):
        orc = orcs.DataladLocalRunOrchestrator(
            shell, submission_type="local", job_spec=job_spec)
        orc.prepare_remote()
        orc.submit()
        orc.follow()

        create_tree(dataset.path, {"sinceyouvebeengone":
                                   "imsomovingon,yeahyeah"})
        dataset.add(".")

        orc.fetch()
        ref = "refs/reproman/{}".format(orc.jobid)
        assert not dataset.repo.is_ancestor(ref, "HEAD")

        with orcs.head_at(dataset, ref):
            assert dataset.repo.file_has_content("out")
            assert open("out").read() == "content\nmore\n"
예제 #9
0
def test_head_at_unknown_ref(dataset):
    with pytest.raises(OrchestratorError) as exc:
        with orcs.head_at(dataset, "youdontknowme"):
            pass
    assert "youdontknowme" in str(exc.value)
예제 #10
0
def test_head_at_dirty(dataset):
    create_tree(dataset.path, {"dirt": ""})
    with pytest.raises(OrchestratorError):
        with orcs.head_at(dataset, "doesntmatter"):
            pass