diff --git a/go.mod b/go.mod index b46bd94..cd49b20 100644 --- a/go.mod +++ b/go.mod @@ -2,10 +2,14 @@ module github.com/go-semantic-release/mock-plugin go 1.21 -require github.com/go-semantic-release/semantic-release/v2 v2.28.0 +require ( + github.com/go-semantic-release/semantic-release/v2 v2.28.0 + github.com/stretchr/testify v1.8.4 +) require ( github.com/Masterminds/semver/v3 v3.2.1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/color v1.15.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/golang/protobuf v1.5.3 // indirect @@ -21,6 +25,7 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/oklog/run v1.1.0 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/spf13/afero v1.9.5 // indirect github.com/spf13/cast v1.5.1 // indirect github.com/spf13/cobra v1.7.0 // indirect diff --git a/mock/commit_analyzer.go b/mock/commit_analyzer.go index dc7c45c..335db2f 100644 --- a/mock/commit_analyzer.go +++ b/mock/commit_analyzer.go @@ -16,6 +16,7 @@ func analyzeCommit(rawCommit *semrel.RawCommit) *semrel.Commit { msg = splitMessages[0] cType = "" } + rawCommit.Annotations["mock"] = "true" return &semrel.Commit{ SHA: rawCommit.SHA, Raw: splitMessages, diff --git a/mock/files_updater.go b/mock/files_updater.go index ffc6bdd..592c581 100644 --- a/mock/files_updater.go +++ b/mock/files_updater.go @@ -5,7 +5,7 @@ import "github.com/go-semantic-release/semantic-release/v2/pkg/updater" var _ updater.FilesUpdater = &Mock{} func (m *Mock) ForFiles() string { - m.Log.Println("listing files to update") + m.Log.Println("allowing *.mock files") return ".*\\.mock" } diff --git a/mock/provider.go b/mock/provider.go index c406f52..99cc6d0 100644 --- a/mock/provider.go +++ b/mock/provider.go @@ -19,35 +19,48 @@ func (m *Mock) GetInfo() (*provider.RepositoryInfo, error) { func (m *Mock) GetCommits(fromSha, toSha string) ([]*semrel.RawCommit, error) { m.Log.Printf("getting commits from %s to %s", fromSha, toSha) + annotations := map[string]string{ + "mock": "true", + "author_name": "mock", + } return []*semrel.RawCommit{ { - SHA: "1", - RawMessage: "feat: add feature", - Annotations: map[string]string{ - "author_name": "mock", - }, + SHA: "1", + RawMessage: "feat: add feature", + Annotations: annotations, }, { - SHA: "2", - RawMessage: "fix: bug fix", - Annotations: map[string]string{ - "author_name": "mock", - }, + SHA: "2", + RawMessage: "fix: bug fix", + Annotations: annotations, + }, + { + SHA: "2", + RawMessage: "chore: update dependencies", + Annotations: annotations, }, }, nil } -func (m *Mock) GetReleases(re string) ([]*semrel.Release, error) { - m.Log.Printf("getting releases: %s", re) +func (m *Mock) GetReleases(rawRe string) ([]*semrel.Release, error) { + m.Log.Printf("getting releases (%s)", rawRe) return []*semrel.Release{ { - SHA: "0", + SHA: "a", Version: "1.0.0", }, + { + SHA: "b", + Version: "1.1.0", + }, + { + SHA: "c", + Version: "1.1.1", + }, }, nil } func (m *Mock) CreateRelease(rc *provider.CreateReleaseConfig) error { - m.Log.Printf("creating release: %s", rc.NewVersion) + m.Log.Printf("creating release %s on branch %s", rc.NewVersion, rc.Branch) return nil }