summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Mewett <tom.mewett@codethink.co.uk>2020-01-23 10:55:25 +0000
committerTom Mewett <tom.mewett@codethink.co.uk>2020-01-24 17:00:14 +0000
commit8ff0d77660d30163016211f5d4b55ca4c6a7cab4 (patch)
tree5bcb9c09c39017873a5e614aede0fb06b74f2bd7
parent1a057b0e54392cc3a25362a6e96b224605b396c3 (diff)
downloadbuildstream-tmewett/git-source.tar.gz
Add Git source test for depth=1 fetch with exact tag reftmewett/git-source
-rw-r--r--tests/sources/git.py28
1 files changed, 28 insertions, 0 deletions
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
@@ -60,6 +60,34 @@ def test_fetch_bad_ref(cli, tmpdir, datafiles):
@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):
project = str(datafiles)