-
Yorick Peterse authored
When generating a changelog without an explicit start commit, we try to find the tag of the previous release. Prior to this commit, the regex used for this was fixed. This creates a problem for projects that use a different tag format, including our very own Omnibus project. Omnibus uses RC tags in the following format: 13.10.0+rc41.ee.0 According to semantic versioning, this isn't a pre-release tag. Instead, the `rc412.ee.0` suffix is part of the build metadata. Changing Omnibus to use a correct tag format would be time consuming, and delay rolling out the use of the new changelog API for our own projects. In addition, other projects could suffer from similar problems where a tag perhaps includes a valid version, but our fixed regex doesn't match it. In this commit we fix this by adding support for custom regular expressions to extract versions from tag names. We use the re2 engine for this instead of Ruby's regex engine, based on the issues with this as outlined in our documentation [1]. Using a re2 pattern, we try to extract the major, minor, patch, and build metadata components. We still skip tags that produce a prerelease component. If a tag doesn't produce at least the major, minor and patch components, it's ignored. The default pattern we use is based on the official semver regex, with added support of tags starting with the letter "v" (to keep the change backwards compatible). Users wishing to use a custom format can probably use a much simpler pattern, as they only need to support their own use formats. For example, for Omnibus we could simply use something along the lines of the following pattern (minus newlines): ^ (?P<major>\d+) \.(?P<minor>\d+) \.(?P<patch>\d+) (\+(?P<prerelease>rc\d+))? (\.(?P<buildmetadata>\w+\.\d+))? $ See https://gitlab.com/gitlab-com/gl-infra/delivery/-/issues/1551 for more information. [1]: https://docs.gitlab.com/ee/development/secure_coding_guidelines.html#regular-expressions-guidelines
e23a470f