diff --git a/pkg/analyzer/commit_analyzer.go b/pkg/analyzer/commit_analyzer.go index 7b1ac64..3178641 100644 --- a/pkg/analyzer/commit_analyzer.go +++ b/pkg/analyzer/commit_analyzer.go @@ -28,9 +28,12 @@ func (da *DefaultCommitAnalyzer) Version() string { } func (da *DefaultCommitAnalyzer) analyzeSingleCommit(rawCommit *semrel.RawCommit) *semrel.Commit { - c := &semrel.Commit{Change: &semrel.Change{}} - c.SHA = rawCommit.SHA - c.Raw = strings.Split(rawCommit.RawMessage, "\n") + c := &semrel.Commit{ + SHA: rawCommit.SHA, + Raw: strings.Split(rawCommit.RawMessage, "\n"), + Change: &semrel.Change{}, + Annotations: rawCommit.Annotations, + } found := commitPattern.FindAllStringSubmatch(c.Raw[0], -1) if len(found) < 1 { return c diff --git a/pkg/analyzer/commit_analyzer_test.go b/pkg/analyzer/commit_analyzer_test.go index 43ca160..17229ae 100644 --- a/pkg/analyzer/commit_analyzer_test.go +++ b/pkg/analyzer/commit_analyzer_test.go @@ -2,6 +2,7 @@ package analyzer import ( "fmt" + "strings" "testing" "github.com/go-semantic-release/semantic-release/v2/pkg/semrel" @@ -24,9 +25,22 @@ func createRawCommit(sha, message string) *semrel.RawCommit { return &semrel.RawCommit{ SHA: sha, RawMessage: message, + Annotations: map[string]string{ + "author_name": "test", + "my-annotation": "true", + }, } } +func TestAnnotations(t *testing.T) { + defaultAnalyzer := &DefaultCommitAnalyzer{} + rawCommit := createRawCommit("a", "feat: new feature") + commit := defaultAnalyzer.analyzeSingleCommit(rawCommit) + require.Equal(t, rawCommit.SHA, commit.SHA) + require.Equal(t, rawCommit.RawMessage, strings.Join(commit.Raw, "\n")) + require.Equal(t, rawCommit.Annotations, commit.Annotations) +} + func TestDefaultAnalyzer(t *testing.T) { testCases := []struct { RawCommit *semrel.RawCommit