From 758c5173c8da5ce17aeb020399d584814650b524 Mon Sep 17 00:00:00 2001 From: hau Date: Tue, 10 Nov 2020 15:47:54 +0700 Subject: [PATCH] feat: add RawHeader in conventional commit --- pkg/convention/commit.go | 3 +++ .../testdata/TestNewCommit/Commit_message_with_no_body.golden | 1 + ...h_not_character_to_draw_attention_to_breaking_change.golden | 1 + .../testdata/TestNewCommit/Commit_message_with_scope.golden | 1 + 4 files changed, 6 insertions(+) diff --git a/pkg/convention/commit.go b/pkg/convention/commit.go index 124ac26..1f87122 100644 --- a/pkg/convention/commit.go +++ b/pkg/convention/commit.go @@ -18,6 +18,7 @@ var ( ) type Commit struct { + RawHeader string Type string Scope string Description string @@ -44,6 +45,8 @@ func parseHeader(header string, commit *Commit) error { return errors.New("wrong header format") } + commit.RawHeader = header + headerSubmatches := headerRegex.FindStringSubmatch(header) commit.Type = headerSubmatches[1] diff --git a/pkg/convention/testdata/TestNewCommit/Commit_message_with_no_body.golden b/pkg/convention/testdata/TestNewCommit/Commit_message_with_no_body.golden index 3f4313d..d2adbf8 100644 --- a/pkg/convention/testdata/TestNewCommit/Commit_message_with_no_body.golden +++ b/pkg/convention/testdata/TestNewCommit/Commit_message_with_no_body.golden @@ -1,4 +1,5 @@ { + "RawHeader": "docs: correct spelling of CHANGELOG", "Type": "docs", "Scope": "", "Description": "correct spelling of CHANGELOG" diff --git a/pkg/convention/testdata/TestNewCommit/Commit_message_with_not_character_to_draw_attention_to_breaking_change.golden b/pkg/convention/testdata/TestNewCommit/Commit_message_with_not_character_to_draw_attention_to_breaking_change.golden index 5c03cdf..e0cec80 100644 --- a/pkg/convention/testdata/TestNewCommit/Commit_message_with_not_character_to_draw_attention_to_breaking_change.golden +++ b/pkg/convention/testdata/TestNewCommit/Commit_message_with_not_character_to_draw_attention_to_breaking_change.golden @@ -1,4 +1,5 @@ { + "RawHeader": "refactor!: drop support for Node 6", "Type": "refactor", "Scope": "", "Description": "drop support for Node 6" diff --git a/pkg/convention/testdata/TestNewCommit/Commit_message_with_scope.golden b/pkg/convention/testdata/TestNewCommit/Commit_message_with_scope.golden index fbab8ee..5e56feb 100644 --- a/pkg/convention/testdata/TestNewCommit/Commit_message_with_scope.golden +++ b/pkg/convention/testdata/TestNewCommit/Commit_message_with_scope.golden @@ -1,4 +1,5 @@ { + "RawHeader": "feat(lang): add polish language", "Type": "feat", "Scope": "lang", "Description": "add polish language"