Commit 24ae2ec2 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'relax-changelog-tag-restriction' into 'master'

Relax tag requirements when generating changelogs

See merge request gitlab-org/gitlab!54832
parents 0eccee7e ffef261a
...@@ -16,12 +16,13 @@ module Repositories ...@@ -16,12 +16,13 @@ module Repositories
# This finder expects that all tags to consider meet the following # This finder expects that all tags to consider meet the following
# requirements: # requirements:
# #
# * They start with the letter "v" # * They start with the letter "v" followed by a version, or immediately start
# * They use semantic versioning for the tag format # with a version
# * They use semantic versioning for the version format
# #
# Tags not meeting these requirements are ignored. # Tags not meeting these requirements are ignored.
class PreviousTagFinder class PreviousTagFinder
TAG_REGEX = /\Av(?<version>#{Gitlab::Regex.unbounded_semver_regex})\z/.freeze TAG_REGEX = /\Av?(?<version>#{Gitlab::Regex.unbounded_semver_regex})\z/.freeze
def initialize(project) def initialize(project)
@project = project @project = project
......
---
title: Relax tag requirements when generating changelogs
merge_request: 54832
author:
type: changed
...@@ -285,8 +285,8 @@ Example response: ...@@ -285,8 +285,8 @@ Example response:
Generate changelog data based on commits in a repository. Generate changelog data based on commits in a repository.
Given a version (using semantic versioning) and a range of commits, Given a version (using [semantic versioning](https://semver.org/)) and a range
GitLab generates a changelog for all commits that use a particular of commits, GitLab generates a changelog for all commits that use a particular
[Git trailer](https://git-scm.com/docs/git-interpret-trailers). [Git trailer](https://git-scm.com/docs/git-interpret-trailers).
The output of this process is a new section in a changelog file in the Git The output of this process is a new section in a changelog file in the Git
...@@ -312,15 +312,15 @@ Supported attributes: ...@@ -312,15 +312,15 @@ Supported attributes:
If the `from` attribute is unspecified, GitLab uses the Git tag of the last If the `from` attribute is unspecified, GitLab uses the Git tag of the last
version that came before the version specified in the `version` attribute. For version that came before the version specified in the `version` attribute. For
this to work, your project must create Git tags for versions using the this to work, your project must create Git tags for versions using one of the
following format: following formats:
```plaintext - `vX.Y.Z`
vX.Y.Z - `X.Y.Z`
```
Where `X.Y.Z` is a version that follows semantic versioning. For example, Where `X.Y.Z` is a version that follows [semantic
consider a project with the following tags: versioning](https://semver.org/). For example, consider a project with the
following tags:
- v1.0.0 - v1.0.0
- v1.1.0 - v1.1.0
......
...@@ -12,16 +12,19 @@ RSpec.describe Repositories::PreviousTagFinder do ...@@ -12,16 +12,19 @@ RSpec.describe Repositories::PreviousTagFinder do
tag1 = double(:tag1, name: 'v1.0.0') tag1 = double(:tag1, name: 'v1.0.0')
tag2 = double(:tag2, name: 'v1.1.0') tag2 = double(:tag2, name: 'v1.1.0')
tag3 = double(:tag3, name: 'v2.0.0') tag3 = double(:tag3, name: 'v2.0.0')
tag4 = double(:tag4, name: '1.0.0') tag4 = double(:tag4, name: '0.9.0')
tag5 = double(:tag4, name: 'v0.8.0-pre1')
allow(project.repository) allow(project.repository)
.to receive(:tags) .to receive(:tags)
.and_return([tag1, tag3, tag2, tag4]) .and_return([tag1, tag3, tag2, tag4, tag5])
expect(finder.execute('2.1.0')).to eq(tag3) expect(finder.execute('2.1.0')).to eq(tag3)
expect(finder.execute('2.0.0')).to eq(tag2) expect(finder.execute('2.0.0')).to eq(tag2)
expect(finder.execute('1.5.0')).to eq(tag2) expect(finder.execute('1.5.0')).to eq(tag2)
expect(finder.execute('1.0.1')).to eq(tag1) expect(finder.execute('1.0.1')).to eq(tag1)
expect(finder.execute('1.0.0')).to eq(tag4)
expect(finder.execute('0.9.0')).to eq(tag5)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment