@@ -27,6 +27,12 @@ const DefaultNewContributorsIcon = "\U0001F389" // party popper 🎉
2727// DefaultBreakingChangesIcon is the default icon for the breaking changes section.
2828const DefaultBreakingChangesIcon = "\u26A0 \uFE0F " // warning sign ⚠️
2929
30+ // DefaultContributorFormat is the default Go template for contributor entries (with name).
31+ const DefaultContributorFormat = "- {{.Name}} ([@{{.Username}}](https://{{.Host}}/{{.Username}}))"
32+
33+ // DefaultContributorFormatNoName is the Go template for contributor entries without name.
34+ const DefaultContributorFormatNoName = "- [@{{.Username}}](https://{{.Host}}/{{.Username}})"
35+
3036// Config holds the internal configuration for the changelog generator plugin.
3137type Config struct {
3238 // Enabled controls whether the plugin is active.
@@ -111,6 +117,7 @@ type ContributorsConfig struct {
111117 Enabled bool
112118 Format string
113119 Icon string
120+ ShowName bool
114121 ShowNewContributors bool
115122 NewContributorsFormat string
116123 NewContributorsIcon string
@@ -132,7 +139,8 @@ func DefaultConfig() *Config {
132139 ExcludePatterns : DefaultExcludePatterns (),
133140 Contributors : & ContributorsConfig {
134141 Enabled : true ,
135- Format : "- [@{{.Username}}](https://{{.Host}}/{{.Username}})" ,
142+ Format : DefaultContributorFormat ,
143+ ShowName : true ,
136144 ShowNewContributors : true ,
137145 },
138146 }
@@ -263,15 +271,19 @@ func convertContributorsConfig(cfg *config.ChangelogGeneratorConfig) *Contributo
263271 return defaultContributorsConfig (cfg .UseDefaultIcons )
264272 }
265273
274+ showName := cfg .Contributors .GetShowName ()
275+
266276 contrib := & ContributorsConfig {
267277 Enabled : cfg .Contributors .Enabled ,
268278 Format : cfg .Contributors .Format ,
269279 Icon : cfg .Contributors .Icon ,
280+ ShowName : showName ,
270281 ShowNewContributors : cfg .Contributors .GetShowNewContributors (),
271282 NewContributorsFormat : cfg .Contributors .NewContributorsFormat ,
272283 NewContributorsIcon : cfg .Contributors .NewContributorsIcon ,
273284 }
274285
286+ applyDefaultContributorFormat (contrib )
275287 applyDefaultContributorIcons (contrib , cfg .UseDefaultIcons )
276288 return contrib
277289}
@@ -280,7 +292,8 @@ func convertContributorsConfig(cfg *config.ChangelogGeneratorConfig) *Contributo
280292func defaultContributorsConfig (useDefaultIcons bool ) * ContributorsConfig {
281293 contrib := & ContributorsConfig {
282294 Enabled : true ,
283- Format : "- {{.Name}} ([@{{.Username}}](https://{{.Host}}/{{.Username}}))" ,
295+ Format : DefaultContributorFormat ,
296+ ShowName : true ,
284297 ShowNewContributors : true ,
285298 }
286299 if useDefaultIcons {
@@ -290,6 +303,19 @@ func defaultContributorsConfig(useDefaultIcons bool) *ContributorsConfig {
290303 return contrib
291304}
292305
306+ // applyDefaultContributorFormat sets the default format when no custom format is specified.
307+ // When ShowName is false and no custom format is set, it uses the no-name format.
308+ func applyDefaultContributorFormat (contrib * ContributorsConfig ) {
309+ if contrib .Format != "" {
310+ return
311+ }
312+ if contrib .ShowName {
313+ contrib .Format = DefaultContributorFormat
314+ } else {
315+ contrib .Format = DefaultContributorFormatNoName
316+ }
317+ }
318+
293319// applyDefaultContributorIcons applies default icons if UseDefaultIcons is enabled.
294320func applyDefaultContributorIcons (contrib * ContributorsConfig , useDefaultIcons bool ) {
295321 if ! useDefaultIcons {
0 commit comments