diff --git a/dvc/repo/ls.py b/dvc/repo/ls.py index 498d02bc6e..50b29fe395 100644 --- a/dvc/repo/ls.py +++ b/dvc/repo/ls.py @@ -28,7 +28,7 @@ def ls(url, path=None, rev=None, recursive=None, dvc_only=False): """ from . import Repo - with Repo.open(url, rev, subrepos=True, uninitialized=True) as repo: + with Repo.open(url, rev=rev, subrepos=True, uninitialized=True) as repo: path_info = PathInfo(repo.root_dir) if path: path_info /= path diff --git a/tests/func/test_ls.py b/tests/func/test_ls.py index 61eb95e390..911890cfda 100644 --- a/tests/func/test_ls.py +++ b/tests/func/test_ls.py @@ -273,6 +273,24 @@ def test_ls_repo_with_removed_dvc_dir_with_path_file(tmp_dir, dvc, scm): match_files(files, ((("file",), True),)) +def test_ls_repo_with_rev(erepo_dir): + with erepo_dir.chdir(): + erepo_dir.scm_gen(FS_STRUCTURE, commit="init") + erepo_dir.dvc_gen(DVC_STRUCTURE, commit="dvc") + + rev = erepo_dir.scm.list_all_commits()[1] + files = Repo.ls(os.fspath(erepo_dir), rev=rev) + match_files( + files, + ( + ((".dvcignore",), False), + ((".gitignore",), False), + (("README.md",), False), + (("model",), False), + ), + ) + + def test_ls_remote_repo(erepo_dir): with erepo_dir.chdir(): erepo_dir.scm_gen(FS_STRUCTURE, commit="init")