3

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 %}
astrochun
  • 1,642
  • 2
  • 7
  • 18
  • 1
    We're in the same boat here. Really struggling to work with these templates/data. @astrochun, we're you ever able to make any progress on this? Thanks! – bnjmn Oct 20 '22 at 22:10
  • 1
    @bnjmn, no I haven't found a solution yet though I haven't put much effort. – astrochun Oct 21 '22 at 13:01

0 Answers0