From e80344598746d83c036b517187379048e9dfffce Mon Sep 17 00:00:00 2001 From: Hau Nguyen Date: Mon, 25 Dec 2023 16:18:24 +0700 Subject: [PATCH] feat(convention): allow type, scope has digit --- internal/convention/commit_test.go | 6 ++++++ internal/convention/option.go | 3 ++- .../TestNewCommit/Commit_message_with_scope#01.golden | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 internal/convention/testdata/TestNewCommit/Commit_message_with_scope#01.golden diff --git a/internal/convention/commit_test.go b/internal/convention/commit_test.go index 3811eab..74a0508 100644 --- a/internal/convention/commit_test.go +++ b/internal/convention/commit_test.go @@ -34,6 +34,12 @@ func TestNewCommit(t *testing.T) { Message: "feat(lang): add polish language", }, }, + { + name: "Commit message with scope", + c: git.Commit{ + Message: "feat(bump00): allow bump minor", + }, + }, { name: "Uppercase", c: git.Commit{ diff --git a/internal/convention/option.go b/internal/convention/option.go index b970495..801214c 100644 --- a/internal/convention/option.go +++ b/internal/convention/option.go @@ -20,7 +20,8 @@ const ( var ( ErrEmptyCommit = errors.New("empty commit") - headerRegex = regexp.MustCompile(`(?P[a-zA-Z]+)(?P\([a-zA-Z]+\))?(?P!)?:\s(?P.+)`) + // Self build + headerRegex = regexp.MustCompile(`(?P[a-zA-Z0-9]+)(?P\([a-zA-Z0-9]+\))?(?P!)?:\s(?P.+)`) ) type OptionFn func(*Commit) error diff --git a/internal/convention/testdata/TestNewCommit/Commit_message_with_scope#01.golden b/internal/convention/testdata/TestNewCommit/Commit_message_with_scope#01.golden new file mode 100644 index 0000000..562da90 --- /dev/null +++ b/internal/convention/testdata/TestNewCommit/Commit_message_with_scope#01.golden @@ -0,0 +1,5 @@ +{ + "RawHeader": "feat(bump00): allow bump minor (0001-01-01)", + "Type": "feat", + "Scope": "bump00" +} \ No newline at end of file