test(git-sandbox): share origin_and_repo setup across gc fixtures
CI / security-codeql (push) Canceled after 0s
CI / test-unit (push) Canceled after 0s
CI / test-integration (push) Canceled after 0s
CI / test-env-virtual (push) Canceled after 0s
CI / test-env-nix (push) Canceled after 0s
CI / test-e2e (push) Canceled after 0s
CI / test-virgin-user (push) Canceled after 0s
CI / test-virgin-root (push) Canceled after 0s
CI / lint-shell (push) Canceled after 0s
CI / lint-python (push) Canceled after 0s
CI / lint-docker (push) Canceled after 0s
CI / quality (push) Canceled after 0s
CI / security-codeql (push) Canceled after 0s
CI / test-unit (push) Canceled after 0s
CI / test-integration (push) Canceled after 0s
CI / test-env-virtual (push) Canceled after 0s
CI / test-env-nix (push) Canceled after 0s
CI / test-e2e (push) Canceled after 0s
CI / test-virgin-user (push) Canceled after 0s
CI / test-virgin-root (push) Canceled after 0s
CI / lint-shell (push) Canceled after 0s
CI / lint-python (push) Canceled after 0s
CI / lint-docker (push) Canceled after 0s
CI / quality (push) Canceled after 0s
quality/check on PR 21 flagged 4 clean.clones findings: the same bare origin, repo and init commit setup in test_branch_gc.py and risk_fixture.py. Both now call one helper in tests/support/git_sandbox.py. PR: https://github.com/kevinveenbirkenbach/package-manager/pull/21 Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cee58bcef1
commit
4c603a0087
3 files changed
+26
-16
No files matched your search
@@ -33,6 +33,28 @@ def git(cwd: str, *args: str) -> str:
|
||||
).stdout.strip()
|
||||
|
||||
|
||||
def origin_and_repo(root: str) -> tuple[str, str]:
|
||||
"""
|
||||
Args:
|
||||
root: the directory that holds both repositories.
|
||||
|
||||
Returns:
|
||||
The paths of the bare `origin.git` and of `repo`, whose `main`
|
||||
tracks origin and carries one pushed commit adding `init.txt`.
|
||||
"""
|
||||
origin = os.path.join(root, "origin.git")
|
||||
repo = os.path.join(root, "repo")
|
||||
git(root, "init", "--bare", "-b", "main", origin)
|
||||
git(root, "init", "-b", "main", repo)
|
||||
git(repo, "remote", "add", "origin", origin)
|
||||
with open(os.path.join(repo, "init.txt"), "w") as fh:
|
||||
fh.write("init")
|
||||
git(repo, "add", "init.txt")
|
||||
git(repo, "commit", "-m", "init")
|
||||
git(repo, "push", "-u", "origin", "main")
|
||||
return origin, repo
|
||||
|
||||
|
||||
def isolated_root(case: unittest.TestCase, env: dict[str, str]) -> str:
|
||||
"""
|
||||
Args:
|
||||
|
||||
Reference in new issue
Block a user