|
19 | 19 | DVC_STUDIO_URL,
|
20 | 20 | )
|
21 | 21 | from dvc.exceptions import DvcException, ReproductionError
|
| 22 | +from dvc.repo import Repo |
22 | 23 | from dvc.repo.experiments.exceptions import ExperimentExistsError
|
23 | 24 | from dvc.repo.experiments.queue.base import BaseStashQueue
|
24 | 25 | from dvc.repo.experiments.refs import CELERY_STASH
|
@@ -808,3 +809,27 @@ def test_experiments_run_with_submodule_dependencies(dvc, scm, make_tmp_dir, dep
|
808 | 809 | dvc.stage.add(cmd="echo foo", deps=[dep], name="foo")
|
809 | 810 |
|
810 | 811 | assert dvc.experiments.run()
|
| 812 | + |
| 813 | + |
| 814 | +def test_experiments_run_in_linked_git_worktree( |
| 815 | + dvc, scm, tmp_path_factory: pytest.TempPathFactory, monkeypatch |
| 816 | +): |
| 817 | + from dulwich.worktree import add_worktree |
| 818 | + |
| 819 | + baseline = scm.get_rev() |
| 820 | + |
| 821 | + wt = tmp_path_factory.mktemp("worktrees") / "worktree" |
| 822 | + add_worktree(scm.dulwich.repo, wt, branch="wt-main") |
| 823 | + |
| 824 | + monkeypatch.chdir(wt) |
| 825 | + |
| 826 | + wt_dvc = Repo(os.fspath(wt)) |
| 827 | + (wt / "foo").write_bytes(b"foo") |
| 828 | + wt_dvc.stage.add(cmd="cp foo bar", deps=["foo"], outs=["bar"], name="cp") |
| 829 | + |
| 830 | + results = wt_dvc.experiments.run(name="my-exp") |
| 831 | + assert results |
| 832 | + rev = first(results) |
| 833 | + assert rev |
| 834 | + # If `bar` exists, we know that the stage was run. |
| 835 | + assert (wt / "bar").read_bytes() == b"foo" |
0 commit comments