Skip to content

Commit 6796710

Browse files
feat: add temp wrapper
1 parent 58006d3 commit 6796710

File tree

1 file changed

+102
-8
lines changed

1 file changed

+102
-8
lines changed

pkg/plugin/buildin/buildin.go

Lines changed: 102 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,112 @@ import (
1818
"github.com/go-semantic-release/semantic-release/v2/pkg/generator"
1919
"github.com/go-semantic-release/semantic-release/v2/pkg/plugin"
2020
"github.com/go-semantic-release/semantic-release/v2/pkg/provider"
21+
"github.com/go-semantic-release/semantic-release/v2/pkg/semrel"
2122
"github.com/go-semantic-release/semantic-release/v2/pkg/updater"
2223
"github.com/spf13/cobra"
2324
)
2425

26+
type tempCommitAnalyzerInterface interface {
27+
Analyze(commits []*semrel.RawCommit) []*semrel.Commit
28+
}
29+
30+
type tempCommitAnalyzerWrapper struct {
31+
tempCommitAnalyzerInterface
32+
}
33+
34+
func (*tempCommitAnalyzerWrapper) Init(m map[string]string) error {
35+
return nil
36+
}
37+
38+
func (*tempCommitAnalyzerWrapper) Name() string {
39+
return "default"
40+
}
41+
42+
func (*tempCommitAnalyzerWrapper) Version() string {
43+
return "dev"
44+
}
45+
46+
type tempCIInterface interface {
47+
Name() string
48+
RunCondition(m map[string]string) error
49+
GetCurrentBranch() string
50+
GetCurrentSHA() string
51+
}
52+
53+
type tempCIWrapper struct {
54+
tempCIInterface
55+
}
56+
57+
func (*tempCIWrapper) Version() string {
58+
return "dev"
59+
}
60+
61+
type tempChangelogGeneratorInterface interface {
62+
Generate(config *generator.ChangelogGeneratorConfig) string
63+
}
64+
65+
type tempChangelogGeneratorWrapper struct {
66+
tempChangelogGeneratorInterface
67+
}
68+
69+
func (*tempChangelogGeneratorWrapper) Init(m map[string]string) error {
70+
return nil
71+
}
72+
73+
func (*tempChangelogGeneratorWrapper) Name() string {
74+
return "default"
75+
}
76+
77+
func (*tempChangelogGeneratorWrapper) Version() string {
78+
return "dev"
79+
}
80+
81+
type tempProviderInterface interface {
82+
Init(map[string]string) error
83+
Name() string
84+
GetInfo() (*provider.RepositoryInfo, error)
85+
GetCommits(sha string) ([]*semrel.RawCommit, error)
86+
GetReleases(re string) ([]*semrel.Release, error)
87+
CreateRelease(*provider.CreateReleaseConfig) error
88+
}
89+
90+
type tempProviderWrapper struct {
91+
tempProviderInterface
92+
}
93+
94+
func (*tempProviderWrapper) Version() string {
95+
return "dev"
96+
}
97+
98+
type tempFilesUpdaterInterface interface {
99+
ForFiles() string
100+
Apply(file, newVersion string) error
101+
}
102+
103+
type tempFilesUpdaterWrapper struct {
104+
tempFilesUpdaterInterface
105+
}
106+
107+
func (*tempFilesUpdaterWrapper) Init(m map[string]string) error {
108+
return nil
109+
}
110+
111+
func (*tempFilesUpdaterWrapper) Name() string {
112+
return "default"
113+
}
114+
115+
func (*tempFilesUpdaterWrapper) Version() string {
116+
return "dev"
117+
}
118+
25119
func RegisterPluginCommands(cmd *cobra.Command) {
26120
cmd.AddCommand([]*cobra.Command{
27121
{
28122
Use: analyzer.CommitAnalyzerPluginName,
29123
Run: func(cmd *cobra.Command, args []string) {
30124
plugin.Serve(&plugin.ServeOpts{
31125
CommitAnalyzer: func() analyzer.CommitAnalyzer {
32-
return &defaultAnalyzer.DefaultCommitAnalyzer{}
126+
return &tempCommitAnalyzerWrapper{&defaultAnalyzer.DefaultCommitAnalyzer{}}
33127
},
34128
})
35129
},
@@ -40,7 +134,7 @@ func RegisterPluginCommands(cmd *cobra.Command) {
40134
Run: func(cmd *cobra.Command, args []string) {
41135
plugin.Serve(&plugin.ServeOpts{
42136
CICondition: func() condition.CICondition {
43-
return &defaultCI.DefaultCI{}
137+
return &tempCIWrapper{&defaultCI.DefaultCI{}}
44138
},
45139
})
46140
},
@@ -51,7 +145,7 @@ func RegisterPluginCommands(cmd *cobra.Command) {
51145
Run: func(cmd *cobra.Command, args []string) {
52146
plugin.Serve(&plugin.ServeOpts{
53147
CICondition: func() condition.CICondition {
54-
return &githubCI.GitHubActions{}
148+
return &tempCIWrapper{&githubCI.GitHubActions{}}
55149
},
56150
})
57151
},
@@ -62,7 +156,7 @@ func RegisterPluginCommands(cmd *cobra.Command) {
62156
Run: func(cmd *cobra.Command, args []string) {
63157
plugin.Serve(&plugin.ServeOpts{
64158
CICondition: func() condition.CICondition {
65-
return &gitlabCI.GitLab{}
159+
return &tempCIWrapper{&gitlabCI.GitLab{}}
66160
},
67161
})
68162
},
@@ -73,7 +167,7 @@ func RegisterPluginCommands(cmd *cobra.Command) {
73167
Run: func(cmd *cobra.Command, args []string) {
74168
plugin.Serve(&plugin.ServeOpts{
75169
ChangelogGenerator: func() generator.ChangelogGenerator {
76-
return &defaultGenerator.DefaultChangelogGenerator{}
170+
return &tempChangelogGeneratorWrapper{&defaultGenerator.DefaultChangelogGenerator{}}
77171
},
78172
})
79173
},
@@ -84,7 +178,7 @@ func RegisterPluginCommands(cmd *cobra.Command) {
84178
Run: func(cmd *cobra.Command, args []string) {
85179
plugin.Serve(&plugin.ServeOpts{
86180
Provider: func() provider.Provider {
87-
return &providerGithub.GitHubRepository{}
181+
return &tempProviderWrapper{&providerGithub.GitHubRepository{}}
88182
},
89183
})
90184
},
@@ -95,7 +189,7 @@ func RegisterPluginCommands(cmd *cobra.Command) {
95189
Run: func(cmd *cobra.Command, args []string) {
96190
plugin.Serve(&plugin.ServeOpts{
97191
Provider: func() provider.Provider {
98-
return &providerGitlab.GitLabRepository{}
192+
return &tempProviderWrapper{&providerGitlab.GitLabRepository{}}
99193
},
100194
})
101195
},
@@ -106,7 +200,7 @@ func RegisterPluginCommands(cmd *cobra.Command) {
106200
Run: func(cmd *cobra.Command, args []string) {
107201
plugin.Serve(&plugin.ServeOpts{
108202
FilesUpdater: func() updater.FilesUpdater {
109-
return &npmUpdater.Updater{}
203+
return &tempFilesUpdaterWrapper{&npmUpdater.Updater{}}
110204
},
111205
})
112206
},

0 commit comments

Comments
 (0)