| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a467e99 commit 75ba2c3
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,7 @@ | |||
| 4 | 4 | # 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/ | |
| 5 | 5 | ||
| 6 | 6 | import os | |
| 7 | + import shutil | ||
| 7 | 8 | import subprocess | |
| 8 | 9 | import sys | |
| 9 | 10 | from io import BytesIO | |
@@ -24,8 +25,9 @@ def _write(repo, path, content): | |||
| 24 | 25 | repo.index.add([str(full_path)]) | |
| 25 | 26 | ||
| 26 | 27 | ||
| 27 | - @pytest.fixture | ||
| 28 | - def rev_parse_repo(tmp_path): | ||
| 28 | + @pytest.fixture(scope="module") | ||
| 29 | + def rev_parse_baseline(tmp_path_factory): | ||
| 30 | + tmp_path = tmp_path_factory.mktemp("rev-parse") | ||
| 29 | 31 | repo = Repo.init(tmp_path) | |
| 30 | 32 | with repo.config_writer() as writer: | |
| 31 | 33 | writer.set_value("user", "name", "GitPython Tests") | |
@@ -52,14 +54,30 @@ def rev_parse_repo(tmp_path): | |||
| 52 | 54 | repo.create_head("aaaaaaaa", merge) | |
| 53 | 55 | repo.create_tag("@foo", ref=merge) | |
| 54 | 56 | ||
| 55 | - return { | ||
| 56 | - "repo": repo, | ||
| 57 | - "root": root, | ||
| 58 | - "release": release, | ||
| 59 | - "side": side_commit, | ||
| 60 | - "merge": merge, | ||
| 61 | - "main": main, | ||
| 62 | - } | ||
| 57 | + commits = {"root": root.hexsha, "release": release.hexsha, "side": side_commit.hexsha, "merge": merge.hexsha} | ||
| 58 | + branch_name = main.name | ||
| 59 | + repo.close() | ||
| 60 | + return tmp_path, commits, branch_name | ||
| 61 | + | ||
| 62 | + | ||
| 63 | + @pytest.fixture | ||
| 64 | + def rev_parse_repo(tmp_path, rev_parse_baseline): | ||
| 65 | + path, commits, branch_name = rev_parse_baseline | ||
| 66 | + shutil.copytree(path, tmp_path / "repo", symlinks=True) | ||
| 67 | + with Repo(tmp_path / "repo") as repo: | ||
| 68 | + yield {"repo": repo, "main": repo.heads[branch_name], **{key: repo.commit(sha) for key, sha in commits.items()}} | ||
| 69 | + | ||
| 70 | + | ||
| 71 | + def test_rev_parse_copies_are_isolated(rev_parse_repo, rev_parse_baseline): | ||
| 72 | + repo = rev_parse_repo["repo"] | ||
| 73 | + path, _, _ = rev_parse_baseline | ||
| 74 | + repo.create_tag("private-copy") | ||
| 75 | + _write(repo, "README.md", "private") | ||
| 76 | + repo.index.commit("private commit") | ||
| 77 | + with Repo(path) as baseline: | ||
| 78 | + assert "private-copy" not in baseline.tags | ||
| 79 | + assert baseline.head.commit == rev_parse_repo["merge"] | ||
| 80 | + assert Path(path, "README.md").read_text() == "release\n" | ||
| 63 | 81 | ||
| 64 | 82 | ||
| 65 | 83 | def test_rev_parse_names_hex_and_describe_forms(rev_parse_repo): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments