"""Exercise Git's target object, index, reference and PCRE code offline.""" from pathlib import Path import os import subprocess source = Path.cwd() binary = source / "git-2.47.3/git" work = source / "git-check" work.mkdir() os.chdir(work) os.environ.update(GIT_CONFIG_NOSYSTEM="1", HOME=str(work), GIT_TERMINAL_PROMPT="0", GIT_AUTHOR_NAME="Vinix", GIT_AUTHOR_EMAIL="test@invalid", GIT_COMMITTER_NAME="Vinix", GIT_COMMITTER_EMAIL="test@invalid") def git(*args, data=None): return subprocess.check_output(["vinix-run", str(binary), *args], input=data, text=True).strip() git("init", "-q", "--template=") (work / "file").write_text("Vinix\n") git("add", "file") tree = git("write-tree") commit = git("commit-tree", tree, data="First commit\n") git("update-ref", "HEAD", commit) if git("show", "HEAD:file") != "Vinix" or git("grep", "-P", "(?=Vini)Vinix") != "file:Vinix": raise SystemExit("target Git object or PCRE result did not match") if not (source / "git-2.47.3/git-remote-http").is_file(): raise SystemExit("target Git HTTP transport is missing")