diff --git a/src/griffe/git.py b/src/griffe/git.py index 84f213f8..3e88102c 100644 --- a/src/griffe/git.py +++ b/src/griffe/git.py @@ -57,6 +57,7 @@ def _get_latest_tag(path: str | Path) -> str: text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + check=False, ) output = process.stdout.strip() if process.returncode != 0 or not output: @@ -99,6 +100,7 @@ def _tmp_worktree(repo: str | Path = ".", ref: str = "HEAD") -> Iterator[Path]: process = subprocess.run( ["git", "-C", repo, "worktree", "add", "-b", branch, location, ref], capture_output=True, + check=False, ) if process.returncode: raise RuntimeError(f"Could not create git worktree: {process.stderr.decode()}") @@ -106,9 +108,9 @@ def _tmp_worktree(repo: str | Path = ".", ref: str = "HEAD") -> Iterator[Path]: try: yield Path(location) finally: - subprocess.run(["git", "-C", repo, "worktree", "remove", branch], stdout=subprocess.DEVNULL) - subprocess.run(["git", "-C", repo, "worktree", "prune"], stdout=subprocess.DEVNULL) - subprocess.run(["git", "-C", repo, "branch", "-D", branch], stdout=subprocess.DEVNULL) + subprocess.run(["git", "-C", repo, "worktree", "remove", branch], stdout=subprocess.DEVNULL, check=False) + subprocess.run(["git", "-C", repo, "worktree", "prune"], stdout=subprocess.DEVNULL, check=False) + subprocess.run(["git", "-C", repo, "branch", "-D", branch], stdout=subprocess.DEVNULL, check=False) def load_git( diff --git a/tests/test_git.py b/tests/test_git.py index d83b3223..528c1043 100644 --- a/tests/test_git.py +++ b/tests/test_git.py @@ -59,15 +59,15 @@ def git_repo(tmp_path: Path) -> Path: """ repo_path = tmp_path / REPO_NAME repo_path.mkdir() - run(["git", "-C", str(repo_path), "init"]) - run(["git", "-C", str(repo_path), "config", "user.name", "Name"]) - run(["git", "-C", str(repo_path), "config", "user.email", "my@email.com"]) + run(["git", "-C", str(repo_path), "init"], check=True) + run(["git", "-C", str(repo_path), "config", "user.name", "Name"], check=True) + run(["git", "-C", str(repo_path), "config", "user.email", "my@email.com"], check=True) for tagdir in REPO_SOURCE.iterdir(): ver = tagdir.name _copy_contents(tagdir, repo_path) - run(["git", "-C", str(repo_path), "add", "."]) - run(["git", "-C", str(repo_path), "commit", "-m", f"feat: {ver} stuff"]) - run(["git", "-C", str(repo_path), "tag", ver]) + run(["git", "-C", str(repo_path), "add", "."], check=True) + run(["git", "-C", str(repo_path), "commit", "-m", f"feat: {ver} stuff"], check=True) + run(["git", "-C", str(repo_path), "tag", ver], check=True) return repo_path