From 9f4d47801155bf4ae266bfc18a71f038d3da3842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Sat, 15 Jun 2024 10:56:31 +0200 Subject: [PATCH] Install pre-commit on create_commit_pull_request --- github_app_geo_project/module/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/github_app_geo_project/module/utils.py b/github_app_geo_project/module/utils.py index 7063878c206..7e5dc963152 100644 --- a/github_app_geo_project/module/utils.py +++ b/github_app_geo_project/module/utils.py @@ -540,6 +540,16 @@ def create_commit_pull_request( branch: str, new_branch: str, message: str, body: str, repo: github.Repository.Repository ) -> tuple[bool, github.PullRequest.PullRequest | None]: """Do a commit, then create a pull request.""" + if os.path.exists(".pre-commit-config.yaml"): + proc = subprocess.run( # nosec # pylint: disable=subprocess-run-check + ["pre-commit", "install"], + capture_output=True, + encoding="utf-8", + timeout=10, + ) + proc_message = ansi_proc_message(proc) + proc_message.title = "Install pre-commit" + _LOGGER.debug(proc_message) if not create_commit(message): return False, None return create_pull_request(branch, new_branch, message, body, repo)