From 7c99fca0dc38fc363477c0d9ff98b27ab873f61c Mon Sep 17 00:00:00 2001 From: Arthur Pastel Date: Fri, 6 Feb 2026 23:57:52 +0100 Subject: [PATCH] feat: add .gitignore to .codspeed folder on creation Prevents local benchmark results from being accidentally committed. Co-Authored-By: Claude Opus 4.6 --- src/pytest_codspeed/plugin.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pytest_codspeed/plugin.py b/src/pytest_codspeed/plugin.py index c17c779..ca0db18 100644 --- a/src/pytest_codspeed/plugin.py +++ b/src/pytest_codspeed/plugin.py @@ -310,7 +310,10 @@ def pytest_sessionfinish(session: pytest.Session, exitstatus): session.config.rootpath / f".codspeed/results_{time() * 1000:.0f}.json" ) data = {**get_environment_metadata(), **plugin.instrument.get_result_dict()} + created = not result_path.parent.exists() result_path.parent.mkdir(parents=True, exist_ok=True) + if created: + (result_path.parent / ".gitignore").write_text("*\n") result_path.write_text(json.dumps(data, indent=2))