Skip to content

fix(check_message): strip commit.verbose diff before validating - #50

Open
jeromepin wants to merge 1 commit into
masterfrom
fix/strip-verbose-diff-from-commit-message
Open

jeromepin wants to merge 1 commit into
masterfrom
fix/strip-verbose-diff-from-commit-message

Conversation

@jeromepin

Copy link
Copy Markdown

With commit.verbose=true, git appends the staged diff below a scissors line in the edited commit message file (example). The diff isn't comment-prefixed, so sed '/^#/d' leaves the diff in place, right after the commit header with no blank line, failing the structure check.

I tested too by disabling commit.verbose and it still works.

Why ? Because I like being reminded of what I did when typing my commit message 👍

Before

chore(test): test test
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch chore/foo
# Changes to be committed:
# modified:   lumapps/modules/terragrunt/go-k8s-prerequisites/storage_class.tf
#
# Untracked files:
# ...
# ------------------------ >8 ------------------------
# Do not modify or remove the line above.
# Everything below it will be ignored.
diff --git c/lumapps/modules/terragrunt/go-k8s-prerequisites/storage_class.tf i/lumapps/modules/terragrunt/go-k8s-prerequisites/storage_class.tf
index 7a0edea2e4..85046256a0 100644
--- c/lumapps/modules/terragrunt/go-k8s-prerequisites/storage_class.tf
+++ i/lumapps/modules/terragrunt/go-k8s-prerequisites/storage_class.tf
@@ -2,8 +2,9 @@ resource "kubernetes_storage_class" "gce_ssd_zonal" {
   metadata {
     name = "ssd-zonal"
   }
-  storage_provisioner = "kubernetes.io/gce-pd"
-  reclaim_policy      = "Retain"
+  storage_provisioner    = "kubernetes.io/gce-pd"
+  reclaim_policy         = "Retain"
+  allow_volume_expansion = true
   parameters = {
     type = "pd-ssd"
   }
@@ -34,4 +35,4 @@ resource "kubernetes_storage_class" "filestore_ssd" {
     tier    = "BASIC_SSD"
     network = var.network_name
   }
-}
\ No newline at end of file
+}

would raise :

Commit Message Validator.................................................Failed
- hook id: commit-message-validator
- exit code: 1

Options:
  JIRA=
  TEMP=1
  NO_REVERT_SHA1=
checking commit message:

#BEGIN#
chore(test): test test
diff --git c/lumapps/modules/terragrunt/go-k8s-prerequisites/storage_class.tf i/lumapps/modules/terragrunt/go-k8s-prerequisites/storage_class.tf
index 7a0edea2e4..85046256a0 100644
--- c/lumapps/modules/terragrunt/go-k8s-prerequisites/storage_class.tf
+++ i/lumapps/modules/terragrunt/go-k8s-prerequisites/storage_class.tf
@@ -2,8 +2,9 @@ resource "kubernetes_storage_class" "gce_ssd_zonal" {
   metadata {
     name = "ssd-zonal"
   }
-  storage_provisioner = "kubernetes.io/gce-pd"
-  reclaim_policy      = "Retain"
+  storage_provisioner    = "kubernetes.io/gce-pd"
+  reclaim_policy         = "Retain"
+  allow_volume_expansion = true
   parameters = {
     type = "pd-ssd"
   }
@@ -34,4 +35,4 @@ resource "kubernetes_storage_class" "filestore_ssd" {
     tier    = "BASIC_SSD"
     network = var.network_name
   }
-}
\ No newline at end of file
+}
#END#

missing empty line in commit message between header and body or body and footer

After

Commit are working again

With commit.verbose=true, git appends the staged diff below a scissors
line in the edited commit message file. The diff isn't comment-prefixed,
so sed '/^#/d' left it in place, right after the header with no blank
line, tripping the structure check.
@jeromepin
jeromepin requested review from a team and lumautomation as code owners September 21, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant