Changelog API does not return expected values when custom versioning regex is used
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=420041) </details> <!--IssueSummary end--> ### Summary When a custom regex is used for versioning, the changelog API does not return versions based on the custom version patterning. For example, if there is a requirement to have leading zeros in a release version, such as version `01.02.03` and a custom regex is used, the API strips the leading zeros and the result is `1.2.3` . ### Steps to reproduce ### Example Project ### What is the current _bug_ behavior? Custom regex is ignored and is using an unbounded semver regex to validate the string is a 'real' version ### What is the expected _correct_ behavior? Getting changelog by version should respect the custom regex. ### Relevant logs and/or screenshots ```bash $ curl -H 'PRIVATE-TOKEN: token' 'https://example.gitlab.com/api/v4/projects/1234/repository/changelog?version=09.01.00' {"error":"version is invalid"} $ curl -H 'PRIVATE-TOKEN: token' 'https://example.gitlab.com/api/v4/projects/1234/repository/changelog?version=09.11.00' {"notes":"## 09.11.00 (2023-07-26)\n\nNo changes.\n"} $ curl -H 'PRIVATE-TOKEN: token' 'https://example.gitlab.com/api/v4/projects/1234/repository/changelog?version=09.01.00+phony1.1.1' {"notes":"## 09.01.00 phony1.1.1 (2023-07-26)\n\nNo changes.\n"} ``` ### ### Output of checks ### Possible fixes I think we might have used the wrong regex in [this code block](https://gitlab.com/gitlab-org/gitlab/-/blob/37760a5048cef05d2255737002835114ffeee511/lib/api/repositories.rb#L17) . It should probably point to the regex in [this code block](https://gitlab.com/gitlab-org/gitlab/-/blob/09612fea8bceb47ca2935844f4a8e1855a3f5898/lib/gitlab/changelog/config.rb). Something like this? (I must admit I'm poor with ruby but the idea is to use the regex of the project and not the `unbounded_semver_regex` ) ```ruby - regexp: Gitlab::Regex.unbounded_semver_regex, + regexp: Gitlab::Changelog::Config.new(<project>).tag_regex, ``` The spec would also need to be updated
issue