Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name = "github2gerrit"
dynamic = ["version"]
description = "Submit a GitHub pull request to a Gerrit repository."
readme = "README.md"
requires-python = ">=3.11,<3.14"
requires-python = ">=3.11"
license = "Apache-2.0"
authors = [
{ name = "Matthew Watkins", email = "mwatkins@linuxfoundation.org" }
Expand All @@ -21,28 +21,29 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Version Control",
"Typing :: Typed",
]
dependencies = [
# CLI framework (Typer)
"typer>=0.12.5",
"typer>=0.20.0",

# Rich formatting for CLI output
"rich>=13.0.0",
"rich>=14.2.0",

# GitHub API client
"PyGithub>=2.3.0",
"PyGithub>=2.8.1",

# Gerrit REST client
"pygerrit2>=2.0.0",
"pygerrit2>=2.0.15",

# git-review CLI used for pushing to Gerrit
"git-review>=2.3.1",
"git-review>=2.5.0",

# YAML parsing for commit normalization
"PyYAML>=6.0.1",
"PyYAML>=6.0.3",
]

[project.urls]
Expand Down Expand Up @@ -80,17 +81,17 @@ exclude = [
[project.optional-dependencies]
dev = [
# Test
"pytest>=8.3.2",
"pytest-cov>=5.0.0",
"coverage[toml]>=7.6.1",
"responses>=0.25.0",
"pytest>=9.0.2",
"pytest-cov>=7.0.0",
"coverage[toml]>=7.6.9",
"responses>=0.25.8",

# Lint/format
"ruff>=0.6.3",
"mypy>=1.11.2",
"mypy>=1.17.1",

# Type checking helpers
"pytest-mock>=3.14.0",
"pytest-mock>=3.15.1",
"types-requests>=2.31.0",
"types-click>=7.1.8",
]
Expand Down
11 changes: 7 additions & 4 deletions src/github2gerrit/rich_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,15 @@ def safe_console_print(
progress_tracker.suspend()

try:
if RICH_AVAILABLE and not err:
if err:
# Use typer.echo for stderr to ensure CliRunner captures it
import typer

typer.echo(message, err=True)
elif RICH_AVAILABLE:
console.print(message, style=style)
else:
print(
message, file=None if not err else __import__("sys").stderr
)
print(message)
finally:
if progress_tracker:
progress_tracker.resume()
Expand Down
8 changes: 6 additions & 2 deletions tests/fixtures/make_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def _run_git(
merged_env = dict(os.environ)
if env:
merged_env.update(env)
# Isolate test repos from parent repo state (important when running under pre-commit)
merged_env.pop("GIT_INDEX_FILE", None)
merged_env.pop("GIT_DIR", None)
merged_env.pop("GIT_WORK_TREE", None)
# Force agent-less, non-interactive SSH for tests
merged_env["SSH_AUTH_SOCK"] = ""
merged_env["SSH_AGENT_PID"] = ""
Expand Down Expand Up @@ -138,7 +142,7 @@ def add(self, paths: Iterable[str | Path]) -> None:

def add_commit(self, message: str, paths: Iterable[str | Path]) -> None:
self.add(paths)
self.git(["commit", "-m", message])
self.git(["commit", "--no-verify", "-m", message])

def current_branch(self) -> str:
cp = self.git(["rev-parse", "--abbrev-ref", "HEAD"])
Expand Down Expand Up @@ -173,7 +177,7 @@ def _initial_commit(repo: Repo, *, default_branch: str) -> None:
# Create a minimal initial commit
repo.write(".gitignore", "# test fixture\n")
repo.git(["add", ".gitignore"])
repo.git(["commit", "-m", "Initial commit"])
repo.git(["commit", "--no-verify", "-m", "Initial commit"])


def init_repo(
Expand Down
12 changes: 10 additions & 2 deletions tests/test_ssh_artifact_prevention.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def temp_workspace():
env = dict(os.environ)
env.pop("SSH_AUTH_SOCK", None)
env.pop("SSH_AGENT_PID", None)
# Isolate test repos from parent repo state (important when running under pre-commit)
env.pop("GIT_INDEX_FILE", None)
env.pop("GIT_DIR", None)
env.pop("GIT_WORK_TREE", None)
env["GIT_CONFIG_GLOBAL"] = "/dev/null"
env["GIT_CONFIG_SYSTEM"] = "/dev/null"

Expand Down Expand Up @@ -69,7 +73,7 @@ def temp_workspace():
env=env.copy(),
)
subprocess.run(
["git", "commit", "-m", "Initial test commit"],
["git", "commit", "--no-verify", "-m", "Initial test commit"],
cwd=workspace,
check=True,
env=env.copy(),
Expand Down Expand Up @@ -220,6 +224,10 @@ def test_git_operations_exclude_ssh_artifacts(temp_workspace):
env = dict(os.environ)
env.pop("SSH_AUTH_SOCK", None)
env.pop("SSH_AGENT_PID", None)
# Isolate test repos from parent repo state (important when running under pre-commit)
env.pop("GIT_INDEX_FILE", None)
env.pop("GIT_DIR", None)
env.pop("GIT_WORK_TREE", None)
env["GIT_CONFIG_GLOBAL"] = "/dev/null"
env["GIT_CONFIG_SYSTEM"] = "/dev/null"

Expand All @@ -234,7 +242,7 @@ def test_git_operations_exclude_ssh_artifacts(temp_workspace):
env=env.copy(),
)
subprocess.run(
["git", "commit", "-m", "Add test file"],
["git", "commit", "--no-verify", "-m", "Add test file"],
cwd=temp_workspace,
check=True,
env=env.copy(),
Expand Down
Loading
Loading