diff --git a/pkg/analyzer/commit.go b/pkg/analyzer/commit_analyzer.go similarity index 100% rename from pkg/analyzer/commit.go rename to pkg/analyzer/commit_analyzer.go diff --git a/pkg/analyzer/default.go b/pkg/analyzer/commit_analyzer_default.go similarity index 100% rename from pkg/analyzer/default.go rename to pkg/analyzer/commit_analyzer_default.go diff --git a/pkg/analyzer/default_test.go b/pkg/analyzer/commit_analyzer_default_test.go similarity index 100% rename from pkg/analyzer/default_test.go rename to pkg/analyzer/commit_analyzer_default_test.go diff --git a/pkg/generator/changelog_generator.go b/pkg/generator/changelog_generator.go new file mode 100644 index 0000000000000000000000000000000000000000..28d1e94cf654deb1a19e448ddb1b31b0cb0971a8 --- /dev/null +++ b/pkg/generator/changelog_generator.go @@ -0,0 +1,15 @@ +package generator + +import ( + "github.com/go-semantic-release/semantic-release/pkg/semrel" +) + +type ChangelogGeneratorConfig struct { + Commits []*semrel.Commit + LatestRelease *semrel.Release + NewVersion string +} + +type ChangelogGenerator interface { + Generate(*ChangelogGeneratorConfig) string +} diff --git a/pkg/generator/changelog/changelog.go b/pkg/generator/changelog_generator_default.go similarity index 85% rename from pkg/generator/changelog/changelog.go rename to pkg/generator/changelog_generator_default.go index b4e1228c1c36b324796a3ed09e451c623f99da98..7932c76989af27bb6aafc8b16c61db9174a0f89f 100644 --- a/pkg/generator/changelog/changelog.go +++ b/pkg/generator/changelog_generator_default.go @@ -1,4 +1,4 @@ -package changelog +package generator import ( "fmt" @@ -9,17 +9,7 @@ import ( "github.com/go-semantic-release/semantic-release/pkg/semrel" ) -type Config struct { - Commits []*semrel.Commit - LatestRelease *semrel.Release - NewVersion string -} - -type Generator interface { - Generate(*Config) string -} - -type DefaultGenerator struct{} +type DefaultChangelogGenerator struct{} func trimSHA(sha string) string { if len(sha) < 9 { @@ -61,7 +51,7 @@ func getSortedKeys(m *map[string]string) []string { return keys } -func (*DefaultGenerator) Generate(changelogConfig *Config) string { +func (*DefaultChangelogGenerator) Generate(changelogConfig *ChangelogGeneratorConfig) string { ret := fmt.Sprintf("## %s (%s)\n\n", changelogConfig.NewVersion, time.Now().UTC().Format("2006-01-02")) typeScopeMap := make(map[string]string) for _, commit := range changelogConfig.Commits { diff --git a/pkg/generator/changelog/changelog_test.go b/pkg/generator/changelog_generator_test.go similarity index 91% rename from pkg/generator/changelog/changelog_test.go rename to pkg/generator/changelog_generator_test.go index 26cebe4a212e9433c3a7e65bc5f99ea112511554..2c3326914dacbd7023321d287449ced373a208b6 100644 --- a/pkg/generator/changelog/changelog_test.go +++ b/pkg/generator/changelog_generator_test.go @@ -1,4 +1,4 @@ -package changelog +package generator import ( "strings" @@ -8,7 +8,7 @@ import ( ) func TestDefaultGenerator(t *testing.T) { - changelogConfig := &Config{} + changelogConfig := &ChangelogGeneratorConfig{} changelogConfig.Commits = []*semrel.Commit{ {}, {SHA: "123456789", Type: "feat", Scope: "app", Message: "commit message"}, @@ -19,7 +19,7 @@ func TestDefaultGenerator(t *testing.T) { } changelogConfig.LatestRelease = &semrel.Release{SHA: "stop"} changelogConfig.NewVersion = "2.0.0" - generator := &DefaultGenerator{} + generator := &DefaultChangelogGenerator{} changelog := generator.Generate(changelogConfig) if !strings.Contains(changelog, "* **app:** commit message (12345678)") || !strings.Contains(changelog, "* commit message (abcd)") || diff --git a/pkg/plugin/manager/manager.go b/pkg/plugin/manager/manager.go index fb5ca7cbd86222fac66438bf58f476e5156abf32..7fd7d18fbc8fcbf836a316726aac3389c07826fd 100644 --- a/pkg/plugin/manager/manager.go +++ b/pkg/plugin/manager/manager.go @@ -4,14 +4,13 @@ import ( "os" "github.com/go-semantic-release/semantic-release/pkg/analyzer" - "github.com/go-semantic-release/semantic-release/pkg/condition" "github.com/go-semantic-release/semantic-release/pkg/condition/defaultci" githubCI "github.com/go-semantic-release/semantic-release/pkg/condition/github" gitlabCI "github.com/go-semantic-release/semantic-release/pkg/condition/gitlab" "github.com/go-semantic-release/semantic-release/pkg/condition/travis" "github.com/go-semantic-release/semantic-release/pkg/config" - "github.com/go-semantic-release/semantic-release/pkg/generator/changelog" + "github.com/go-semantic-release/semantic-release/pkg/generator" "github.com/go-semantic-release/semantic-release/pkg/provider" "github.com/go-semantic-release/semantic-release/pkg/provider/github" "github.com/go-semantic-release/semantic-release/pkg/provider/gitlab" @@ -51,8 +50,8 @@ func (m *Manager) GetCommitAnalyzer() (analyzer.CommitAnalyzer, error) { return &analyzer.DefaultCommitAnalyzer{}, nil } -func (m *Manager) GetChangelogGenerator() (changelog.Generator, error) { - return &changelog.DefaultGenerator{}, nil +func (m *Manager) GetChangelogGenerator() (generator.ChangelogGenerator, error) { + return &generator.DefaultChangelogGenerator{}, nil } func (m *Manager) GetUpdater() (updater.Updater, error) {