test: keep bare git fixtures on master

This commit is contained in:
AJV20 committed 2026-05-28 10:37:38 -04:00
1 parent 04e0f905dd
commit 790fc70e87
1 file changed
+17 -6
+17 -6
View File
@@ -47,6 +47,20 @@ def _init_repo(path):
return path
def _init_bare_repo(path):
init = subprocess.run(
["git", "init", "--bare", "-b", "master", str(path)],
shell=False,
text=True,
capture_output=True,
timeout=20,
)
if init.returncode != 0:
_git(path.parent, "init", "--bare", str(path))
_git(path, "symbolic-ref", "HEAD", "refs/heads/master")
return path
def _commit_all(path, message="initial"):
_git(path, "add", ".")
_git(path, "commit", "-m", message)
@@ -513,8 +527,7 @@ def test_staged_commit_message_prompt_uses_only_staged_diff(tmp_path):
def test_git_fetch_pull_and_push_with_upstream(tmp_path):
from api.workspace_git import git_fetch, git_pull, git_push, git_status
remote = tmp_path / "remote.git"
_git(tmp_path, "init", "--bare", str(remote))
remote = _init_bare_repo(tmp_path / "remote.git")
origin = _init_repo(tmp_path / "origin")
(origin / "tracked.txt").write_text("one\n", encoding="utf-8")
@@ -550,8 +563,7 @@ def test_git_fetch_pull_and_push_with_upstream(tmp_path):
def test_git_branches_lists_local_remote_and_upstream(tmp_path):
from api.workspace_git import git_branches
remote = tmp_path / "remote.git"
_git(tmp_path, "init", "--bare", str(remote))
remote = _init_bare_repo(tmp_path / "remote.git")
origin = _init_repo(tmp_path / "origin")
(origin / "tracked.txt").write_text("one\n", encoding="utf-8")
_commit_all(origin)
@@ -575,8 +587,7 @@ def test_git_branches_lists_local_remote_and_upstream(tmp_path):
def test_git_checkout_local_new_remote_dirty_and_invalid_refs(tmp_path):
from api.workspace_git import GitWorkspaceError, git_branches, git_checkout
remote = tmp_path / "remote.git"
_git(tmp_path, "init", "--bare", str(remote))
remote = _init_bare_repo(tmp_path / "remote.git")
origin = _init_repo(tmp_path / "origin")
(origin / "tracked.txt").write_text("one\n", encoding="utf-8")
_commit_all(origin)