From 5fd35bb1b470f38e2ec2287d6bb1b0a722d57535 Mon Sep 17 00:00:00 2001 From: Kurt von Laven Date: Sun, 21 Aug 2022 15:20:45 -0700 Subject: [PATCH 1/2] ci(pre-commit): Run hooks pre-commit by default They already run pre-push, and this behavior is left unchanged. Running hooks pre-commit gives developers more immediate feedback and improves commit quality by blocking an often unnecessary series of fix commits. --- .pre-commit-config.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bcc87a4232..ebbfe154b0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,6 @@ -default_stages: [push] +default_stages: + - commit + - push repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.1.0 From f65da26c3214a38b06862be128338d077c629275 Mon Sep 17 00:00:00 2001 From: Kurt von Laven Date: Sun, 21 Aug 2022 15:34:45 -0700 Subject: [PATCH 2/2] ci(pre-commit): Check existing commit messages Use new commitizen-branch hook to verify correctness of existing commit messages post-commit and pre-push. This guards against cherry-picked commits with invalid commit messages as well as empty commit messages (e.g., created with git commit --allow-empty-message). --- .pre-commit-config.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ebbfe154b0..f67e9f8637 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,6 +17,10 @@ repos: rev: v2.32.2 # automatically updated by Commitizen hooks: - id: commitizen + - id: commitizen-branch + stages: + - post-commit + - push - repo: local hooks: