Skip to content

Commit

Permalink
Support pre-commit modification con commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jun 17, 2024
1 parent 4df0f4e commit 82cf5f8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions github_app_geo_project/module/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def has_changes(include_un_followed: bool = False) -> bool:
return proc.returncode != 0


async def create_commit(message: str) -> bool:
async def create_commit(message: str, pre_commit_check: bool = True) -> bool:
"""Do a commit."""
proc = subprocess.run( # nosec # pylint: disable=subprocess-run-check
["git", "add", "--all"], capture_output=True, encoding="utf-8", timeout=30
Expand All @@ -573,13 +573,16 @@ async def create_commit(message: str) -> bool:
_LOGGER.warning(proc_message)
return False
_, success, _ = await run_timeout(
["git", "commit", f"--message={message}"],
["git", "commit", f"--message={message}", *([] if pre_commit_check else ["--no-verify"])],
None,
600,
"Commit",
"Error committing files",
"Timeout committing files",
)
if not success and pre_commit_check:
# On pre-commit issues, add them to the commit, and try again without the pre-commit
success = await create_commit(message, False)
return success


Expand Down

0 comments on commit 82cf5f8

Please sign in to comment.