Changelog API does not return expected values when custom versioning regex is used
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
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
$ 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 . It should probably point to the regex in this code block.
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
)
- regexp: Gitlab::Regex.unbounded_semver_regex,
+ regexp: Gitlab::Changelog::Config.new(<project>).tag_regex,
The spec would also need to be updated