Skip to content

Commit

Permalink
release: skip git hooks
Browse files Browse the repository at this point in the history
Git hooks require the dev environment, however conductor may not be in
the same environment.  So commit without git hooks (--no-verify).

However, if Python files are modified, then pre-commit hooks should be
run.  If that's the case, exit gracefully with an appropriate message.
  • Loading branch information
suvayu committed Aug 31, 2024
1 parent 9d2b312 commit 85d8505
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion orchestra/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,14 @@ def create_tags(
repo.git.add("pyproject.toml")
added = len([i for i in repo.index.diff("HEAD")])

# NOTE: exit gracefully if python files were modified, as we
# may not be able to run pre-commit hooks (depends on env setup)
if py_files := list(filter(lambda p: p.endswith(".py"), modified)):
msg = f"{repo.working_tree_dir}: python files modified: {py_files}\n"
msg += "Please commit in the dev environment so that pre-commit hooks can be run."
console.print(msg)
ErrorCodes.COMMIT_ERR.exit()

if added > 0:
try:
msg = invoke_editor(repo, next_version)
Expand All @@ -309,7 +317,7 @@ def create_tags(
console.print(format_exc(err, "Aborting commit!"))
ErrorCodes.COMMIT_ERR.exit()
else:
repo.index.commit(msg)
repo.index.commit(msg, skip_hooks=True)

console.print(
f"Creating tag: {next_version} @ [yellow]{repo.head.commit.hexsha[:7]}"
Expand Down

0 comments on commit 85d8505

Please sign in to comment.