Skip to content

Commit d025d9e

Browse files
feat: add plugin name aliases
1 parent 233dd1b commit d025d9e

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

cmd/plugin-registry-update/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func run(log *logrus.Logger, cmd *cobra.Command, _ []string) error {
7575
if fullUpdate {
7676
log.Warn("triggering full registry update...")
7777
} else {
78-
log.Infof("triggering update for plugin: %s@%s.", pluginName, pluginVersion)
78+
log.Infof("triggering update for plugin: %s@%s", pluginName, pluginVersion)
7979
}
8080

8181
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)

internal/config/plugins.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ var Plugins = plugin.Plugins{
1919
Repo: "go-semantic-release/changelog-generator-default",
2020
},
2121
{
22-
Type: "commit-analyzer",
23-
Name: "default",
24-
Repo: "go-semantic-release/commit-analyzer-cz",
22+
Type: "commit-analyzer",
23+
Name: "cz",
24+
Aliases: []string{"default"},
25+
Repo: "go-semantic-release/commit-analyzer-cz",
2526
},
2627
{
2728
Type: "condition",

internal/plugin/plugin.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import (
1313
)
1414

1515
type Plugin struct {
16-
Type string
17-
Name string
18-
Repo string
16+
Type string
17+
Name string
18+
Aliases []string
19+
Repo string
1920
}
2021

2122
var CollectionPrefix = "dev"
@@ -39,6 +40,14 @@ func (p *Plugin) GetFullName() string {
3940
return fmt.Sprintf("%s-%s", p.Type, p.Name)
4041
}
4142

43+
func (p *Plugin) GetAliases() []string {
44+
aliases := make([]string, len(p.Aliases))
45+
for i, aName := range p.Aliases {
46+
aliases[i] = fmt.Sprintf("%s-%s", p.Type, aName)
47+
}
48+
return aliases
49+
}
50+
4251
func (p *Plugin) getDocRef(db *firestore.Client) *firestore.DocumentRef {
4352
return db.Collection(CollectionPrefix + "-plugins").Doc(p.GetFullName())
4453
}
@@ -253,10 +262,17 @@ func (p *Plugin) GetRelease(ctx context.Context, db *firestore.Client, version s
253262
type Plugins []*Plugin
254263

255264
func (l Plugins) Find(name string) *Plugin {
265+
name = strings.ToLower(name)
256266
for _, p := range l {
257-
if p.GetFullName() == strings.ToLower(name) {
267+
if p.GetFullName() == name {
258268
return p
259269
}
270+
// check aliases
271+
for _, alias := range p.GetAliases() {
272+
if alias == name {
273+
return p
274+
}
275+
}
260276
}
261277
return nil
262278
}

0 commit comments

Comments
 (0)