From 1becb87547ffa729d1ae56bad95878e35a3b4be3 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Fri, 5 Sep 2025 10:45:58 +0200 Subject: [PATCH] maint(resources): honor configure comment character in commit message Git allows to specify a comment character different from the default `#`. This is helpful when using markdown in commit messages, especially when adding a user test section that has to start with `# User testing` in order for the test bot to detect it. This change modifies the `prepare-commit-msg` hook and adds a check for a configured `core.commentString` or `core.commentChar`. If both are not set it falls back to the default `#` character. You can set a different comment character with `git config core.commentChar //`. Build-bot: skip Test-bot: skip --- resources/git-hooks/prepare-commit-msg | 29 ++++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/resources/git-hooks/prepare-commit-msg b/resources/git-hooks/prepare-commit-msg index 4fd7bdffea..0db32abff3 100755 --- a/resources/git-hooks/prepare-commit-msg +++ b/resources/git-hooks/prepare-commit-msg @@ -114,18 +114,25 @@ function prepend_scope() { fi fi + commentchar="#" + if [[ -n "$(git config core.commentString)" ]]; then + commentchar="$(git config core.commentString)" + elif [[ -n "$(git config core.commentChar)" ]]; then + commentchar="$(git config core.commentChar)" + fi + postfix=$( cat < -# - Use imperative, present tense ('attach' not 'attaches', 'attached' etc) -# - Don't include a period at the end of the title -# - Always include a blank line before trailers -# - More: https://github.com/keymanapp/keyman/wiki/Pull-Request-and-Commit-workflow-notes +\n${commentchar} Keyman Conventional Commit suggestions: +${commentchar} +${commentchar} - Link to a Sentry issue with git trailer: +${commentchar} Fixes: _MODULE_-_ID_ +${commentchar} - Give credit to co-authors: +${commentchar} Co-authored-by: _Name_ <_email_> +${commentchar} - Use imperative, present tense ('attach' not 'attaches', 'attached' etc) +${commentchar} - Don't include a period at the end of the title +${commentchar} - Always include a blank line before trailers +${commentchar} - More: https://github.com/keymanapp/keyman/wiki/Pull-Request-and-Commit-workflow-notes EOF ) @@ -170,4 +177,4 @@ case $COMMIT_SOURCE in # Known possibilities: message (-m), template (-t) exit 0 ;; -esac \ No newline at end of file +esac