git-chglog / git-chglog

CHANGELOG generator implemented in Go (Golang).
https://godoc.org/github.com/git-chglog/git-chglog
MIT License
2.68k stars 235 forks source link

Add option for 'no links' #141

Open tommyalatalo opened 3 years ago

tommyalatalo commented 3 years ago

When using git-chglog along with a tool as goreleaser, or any other release procedure where you need to add a tag manually in CI and annotate it, it would be great to be able to disable the html and markdown links from the output, to make the annotation cleaner.

What I'm doing in CI is the below:

git tag -a -m "$(git-chglog --next-tag $(svu next) $(svu next))))" "$(svu next)";

the output is the changes from my last tag to the current commit, with the correct version for "next. But the annotation looks something like this:

<a name="v1.30.0"></a>

* log redis address on startup
* update toolkit to v1.0.20
* update toolkit to v1.0.18

It would be a great option to have '--no-links' so that you can disable the html tags for this use case, so that the output would be cleaner:

v1.30.0
* log redis address on startup
* update toolkit to v1.0.20
* update toolkit to v1.0.18
khos2ow commented 3 years ago

I originally assigned this to myself for implementation, but on the second thought I think there's no code change is needed as this can be controlled solely through CHANGELOG.tpl.md, for example if taking .chglog/CHANGELOG.tpl.md being used for this repository itself.

- <a name="unreleased"></a>
- ## [Unreleased]
+ ## Unreleased

...

{{ range .Versions }}
- <a name="{{ .Tag.Name }}"></a>
- ## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
+ ## {{ .Tag.Name }} - {{ datetime "2006-01-02" .Tag.Date }}

...

- {{- if .Versions }}
- [Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD
- {{ range .Versions -}}
- {{ if .Tag.Previous -}}
- [{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
- {{ end -}}
- {{ end -}}
- {{ end -}}

Can you try this and let us know if this still doesn't solve your use-case?

clok commented 3 years ago

I was thinking along the same lines, that this should be achievable via template changes. If this works out, it may be worth considering the addition of a "no-links" template.

tommyalatalo commented 3 years ago

Yeah adding another template works, but as clok mentioned it might be a good idea to add another default template as an option. It would actually be quite good to have the default template that we have now (markdown with links), and one which renders entirely as plain text, for use in git commit messages and/or tag annotations. This because the markdown syntax with # for headers requires you to enable the --cleanup=whitespace flag for the git tag command in order for git not to hide any lines starting with #.