You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to implement a changelog generator similar to the angular preset for conventional-changelog, as this is what we're migrating away from.
My first attempt was this:
[changelog]
header = "# Changelog\n\n"# This is similar to the "angular" preset, but skips releases with no commits, uppercases the first letter of each commit message, sorts feat over bug fixes and includes body = """{% if version %}\ {% if previous %}\ {% if previous.version %}\ ## [{{ version | trim_start_matches(pat="v") }}](https://github.com/org/repo/compare/{{ previous.version }}...{{ version }}) ({{ timestamp | date(format="%Y-%m-%d") }}) {% else %}\ ## [{{ version | trim_start_matches(pat="v") }}](https://github.com/org/repo/releases/tag/{{ version }}) ({{ timestamp | date(format="%Y-%m-%d") }}) {% endif %}\ {% endif %}\{% else %}\ ## [unreleased]{% endif %}\{% for group, commits in commits | group_by(attribute="group") %} ### {{ group | striptags | upper_first }} {% for commit in commits %} * {% if commit.scope %}**{{commit.scope}}:** {% endif %}{{ commit.message | upper_first }} ([{{commit.id | truncate(length=7, end="")}}](https://github.com/org/repo/commit/{{commit.id}})) {%- endfor -%} {% raw %}\n{% endraw %}\{% endfor %}\n"""
[git]
# regex for preprocessing the commit messagescommit_preprocessors = [
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/org/repo/issues/${2}))"}, # replace issue refs with links
]
This is fast and does what we want, but it's hard codes the repo URL in several places, and we have multiple repos we generate changelogs for, so it would be a lot of duplication. We would prefer to be able to reuse one config and pass the repo url/remote either as a variable, get it from the git remote or something in between (like #112).
I tried to use replace_command (thanks for pointing it out for me on Discord), and that kind of worked:
This way I could use the REPO_URL variable instead of hard coding the url in the config. However:
git cliff runs 3-4x slower this way.
This only works for the commit messages. I'm sure I could also get the commit issue link handled here, but I could not use it for the version links, could I? Those are not critical for our use case, but I still think replace_command isn't a great option for us.
I don't know if there are any needs for other variables than this, so maybe the #112 / #121 proposals are more reasonable than this, if you are willing to reconsider.
Thanks again for your awesome work!
The text was updated successfully, but these errors were encountered:
I got around this problem by using a special variable-like token <REPO_URL> where I wanted my repo url and then post-process the output with sed. It's similar to #155, but that only works through the config (which I don't want, I want to share the same config for multiple repos).
git cliff | sed 's|<REPO_URL>|https://github.com/myorg/myrepo|g'> CHANGELOG.md
You can't use an actual variable syntax $REPO_URL as the token though. That will come out as nothing in many places.
I wanted to implement a changelog generator similar to the angular preset for conventional-changelog, as this is what we're migrating away from.
My first attempt was this:
This is fast and does what we want, but it's hard codes the repo URL in several places, and we have multiple repos we generate changelogs for, so it would be a lot of duplication. We would prefer to be able to reuse one config and pass the repo url/remote either as a variable, get it from the git remote or something in between (like #112).
I tried to use replace_command (thanks for pointing it out for me on Discord), and that kind of worked:
This way I could use the
REPO_URL
variable instead of hard coding the url in the config. However:I don't know if there are any needs for other variables than this, so maybe the #112 / #121 proposals are more reasonable than this, if you are willing to reconsider.
Thanks again for your awesome work!
The text was updated successfully, but these errors were encountered: