The GitLab Changelog API amends CHANGELOG.md with commit title and merge request information. However, it does it in a way to only work within GitLab UI (i.e., project-name@long-hash
). My use case is to also publish the CHANGELOG.md using mkdocs through the GitLab CI/CD. Thus, having an absolute URL to each commit and merge request is what I need. By default, the Changelog API does not do this.
It generates something like this:
[Commit message](group/repo@abcdef123456hash).
What I would like is something like:
[Commit message](https://gitlab.com/group/repo/-/commit/abcdef123456hash).
For merge requests, it does:
group@repo!42
Desire is:
https://gitlab.com/group/repo/-/merge_requests/42
The template_data mentions several variables but there's no way to get an absolute URL it seems.
For reference, my changelog_config.yml
template
is:
template: |
{% if categories %}
{% each categories %}
### {{ title }} ({% if single_change %}1 change{% else %}{{ count }} changes{% end %})
{% each entries %}
- [{{ title }}]({{ commit.reference }})\
{% if author.credit %} by {{ author.reference }}{% end %}\
{% if commit.trailers.MR %}\
([merge request]({{ commit.trailers.MR }}))\
{% else %}\
{% if merge_request %}\
([merge request]({{ merge_request.reference }}))\
{% end %}\
{% end %}
{% end %}
{% end %}
{% else %}
No changes.
{% end %}