From 8ff0d77660d30163016211f5d4b55ca4c6a7cab4 Mon Sep 17 00:00:00 2001 From: Tom Mewett Date: Thu, 23 Jan 2020 10:55:25 +0000 Subject: Add Git source test for depth=1 fetch with exact tag ref --- tests/sources/git.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests') diff --git a/tests/sources/git.py b/tests/sources/git.py index 25ec49347..033db1bf9 100644 --- a/tests/sources/git.py +++ b/tests/sources/git.py @@ -59,6 +59,34 @@ def test_fetch_bad_ref(cli, tmpdir, datafiles): result.assert_task_error(ErrorDomain.SOURCE, None) +@pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") +@pytest.mark.skipif(HAVE_OLD_GIT, reason="old git cannot clone a shallow repo to stage the source") +@pytest.mark.datafiles(os.path.join(DATA_DIR, "template")) +def test_fetch_shallow(cli, tmpdir, datafiles): + project = str(datafiles) + workspacedir = os.path.join(str(tmpdir), "workspace") + + # Create the repo from 'repofiles' subdir + repo = create_repo("git", str(tmpdir)) + repo.create(os.path.join(project, "repofiles")) + first_commit = repo.latest_commit() + repo.add_commit() + repo.add_tag("tag") + + ref = "tag-0-g" + repo.latest_commit() + + element = {"kind": "import", "sources": [repo.source_config(ref=ref)]} + generate_element(project, "target.bst", element) + + result = cli.run(project=project, args=["source", "fetch", "target.bst"]) + result.assert_success() + result = cli.run(project=project, args=["workspace", "open", "--directory", workspacedir, "target.bst"]) + result.assert_success() + + assert subprocess.call(["git", "show", "tag"], cwd=workspacedir) == 0 + assert subprocess.call(["git", "show", first_commit], cwd=workspacedir) != 0 + + @pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, "template")) def test_submodule_fetch_checkout(cli, tmpdir, datafiles): -- cgit v1.2.1