hashicorp / go-changelog

Changelog generation based on files in a directory.
Mozilla Public License 2.0
107 stars 20 forks source link

Entries without a link #3

Closed hanshasselberg closed 4 years ago

hanshasselberg commented 4 years ago

We are starting to use go-changelog for Consul and there is an edgecase that I would like to solve. For changes in Consul Enterprise we don't have a PR or issue that we could link to because this repository is private. Now I am trying to find a way to generate changelog entries without a link to a PR or issue.

Our current note template:

{{- define "note" -}}
{{.Body}} [[GH-{{- .Issue -}}](https://github.com/hashicorp/consul/issues/{{- .Issue -}})]
{{- end -}}

I would like it to look like this:

{{- define "note" -}}
{{.Body}}{{if .Link}} [[GH-{{- .Issue -}}](https://github.com/hashicorp/consul/issues/{{- .Issue -}})]{{end}}
{{- end -}}

Displaying links should be the default, you would want to opt out manually, maybe like this:

```release-note:enhancement:no-link
Added the `bar` interface.
```

What do you think about that?

paddycarver commented 4 years ago

Hmm. The multiple : in the codeblock type feels dangerous to me, and I think I'd like to avoid overloading that.

Considering these changelog entry files need to be named something anyways, and the implication for this name is that it won't be used as a link (which differs from other names), how would you feel about a convention that files with a named prefixed with . or _ or something don't generate links in the changelog? Then your template code could work as written, or with minor tweaking to detect the prefix.

hanshasselberg commented 4 years ago

@paddycarver I haven't considered changes to the filename, but I like that.

Just to be clear, a file named .1234.txt with this content wouldn't generate a link:

```release-note:enhancement
Added the `bar` interface.
```
paddycarver commented 4 years ago

Yeah, that's essentially what I'm propoosing. Technically, I think the only change we'd really need to make would be making strings.HasPrefix available from the template, then the template could look like this:

{{- define "note" -}}
{{.Body}}{{if not stringHasPrefix .Issue "."}} [[GH-{{- .Issue -}}](https://github.com/hashicorp/consul/issues/{{- .Issue -}})]{{end}}
{{- end -}}

That way each repo can set its own convention, if they need issues that begin with . for whatever reason.