From 1280c34adb509a9c8bf383a73f505ed1ea71c7a1 Mon Sep 17 00:00:00 2001 From: Zoran Regvart Date: Mon, 25 Sep 2023 08:06:17 +0000 Subject: [PATCH 1/3] Fix reference for GitHub References on GitHub start with `#`[1]. [1] https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls --- README.md | 4 ++-- commit-msg/check-commit-message | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6f14b27..ce76dce 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,8 @@ At this point, executing `git commit` will trigger the `check-commit-msg` hook, |if your commit|use this keyword|value| |-|-------|-----| -|resolves an issue/ticket|resolves, res, resolved| !123(only for GitHub Issues), PROJ-1234| -|only references an issue/ticket|ref, refs, references, refers to| !123(only for GitHub Issues), PROJ-1234| +|resolves an issue/ticket|resolves, res, resolved| #123(only for GitHub Issues), PROJ-1234| +|only references an issue/ticket|ref, refs, references, refers to| #123(only for GitHub Issues), PROJ-1234| *Example git commit message*: ``` diff --git a/commit-msg/check-commit-message b/commit-msg/check-commit-message index 85580ba..cdbd107 100755 --- a/commit-msg/check-commit-message +++ b/commit-msg/check-commit-message @@ -12,7 +12,7 @@ fi # The regex pattern # The (?i) is for case-insensitive matching # The \s* at the end is for optional trailing whitespace -pattern="^(?i)(ref|refs|reference|references|res|resolve|resolves)[ \t]*:[ \t]*(gh-|\!|[A-Za-z]+-)\d+\s*$" +pattern='^(?i)(ref|refs|reference|references|res|resolve|resolves)\s*:\s*(#\d+||[A-Za-z]+-\d+)\s*$' # Scan the entire file for lines matching the pattern if grep -Pq "$pattern" "$input_file"; then @@ -24,13 +24,13 @@ else If this commit resolves an issue, add: - res: !123 # For GitHub issues - res: PROJ-1234 # For other issue tracker IDs + res: #123 // For GitHub issues + res: PROJ-1234 // For other issue tracker IDs If this commit is referencing an issue, but does not resolve it, add: - ref: !123 # For GitHub issues - ref: PROJ-1234 # For other issue tracker IDs + ref: #123 // For GitHub issues + ref: PROJ-1234 // For other issue tracker IDs See the contributing guidelines of this project for more details. From 298f5584d081b0cf9632fc16a7c4c6cbe641d5ac Mon Sep 17 00:00:00 2001 From: Zoran Regvart Date: Mon, 25 Sep 2023 08:06:17 +0000 Subject: [PATCH 2/3] Fix reference for GitHub References on GitHub start with `#`[1]. [1] https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls --- commit-msg/check-commit-message | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/commit-msg/check-commit-message b/commit-msg/check-commit-message index df30a7d..d4cb25b 100755 --- a/commit-msg/check-commit-message +++ b/commit-msg/check-commit-message @@ -12,7 +12,7 @@ fi # The regex pattern # The (?i) is for case-insensitive matching # The \s* at the end is for optional trailing whitespace -pattern='^(?i)(ref|refs|reference|references|res|resolve|resolves)\s*:\s*(#\d+||[A-Za-z]+-\d+)\s*$' +pattern='^(?i)(ref|refs|reference|references|res|resolve|resolves)\s*:\s*((#|gh-)\d+||[A-Za-z]+-\d+)\s*$' # Scan the entire file for lines matching the pattern if grep -Pq "$pattern" "$input_file"; then @@ -35,9 +35,16 @@ else done while working on an issue, amend the commit to include a reference to the issue or ticket like so: +<<<<<<< HEAD reference: PROJ-1234 or reference: #123 (if referencing a GitHub issue) +======= + ref: #123 // For GitHub issues + ref: PROJ-1234 // For other issue tracker IDs + + See the contributing guidelines of this project for more details. +>>>>>>> cde242e (Fix reference for GitHub) Don't have a ticket to reference? You should create one. """ From f96f7d09e63cec8eab6907ff4c6cb12fba674325 Mon Sep 17 00:00:00 2001 From: Zoran Regvart Date: Mon, 25 Sep 2023 08:06:17 +0000 Subject: [PATCH 3/3] Fix reference for GitHub References on GitHub start with `#`[1]. [1] https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls --- commit-msg/check-commit-message | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/commit-msg/check-commit-message b/commit-msg/check-commit-message index d4cb25b..028c50d 100755 --- a/commit-msg/check-commit-message +++ b/commit-msg/check-commit-message @@ -12,7 +12,7 @@ fi # The regex pattern # The (?i) is for case-insensitive matching # The \s* at the end is for optional trailing whitespace -pattern='^(?i)(ref|refs|reference|references|res|resolve|resolves)\s*:\s*((#|gh-)\d+||[A-Za-z]+-\d+)\s*$' +pattern='^(?i)(ref|refs|reference|references|res|resolve|resolves)\s*:\s*((#|gh-)\d+|[A-Za-z]+-\d+)\s*$' # Scan the entire file for lines matching the pattern if grep -Pq "$pattern" "$input_file"; then @@ -35,16 +35,9 @@ else done while working on an issue, amend the commit to include a reference to the issue or ticket like so: -<<<<<<< HEAD reference: PROJ-1234 or reference: #123 (if referencing a GitHub issue) -======= - ref: #123 // For GitHub issues - ref: PROJ-1234 // For other issue tracker IDs - - See the contributing guidelines of this project for more details. ->>>>>>> cde242e (Fix reference for GitHub) Don't have a ticket to reference? You should create one. """