diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /app/finders/repositories/previous_tag_finder.rb | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'app/finders/repositories/previous_tag_finder.rb')
-rw-r--r-- | app/finders/repositories/previous_tag_finder.rb | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/app/finders/repositories/previous_tag_finder.rb b/app/finders/repositories/previous_tag_finder.rb deleted file mode 100644 index b5e786c30e9..00000000000 --- a/app/finders/repositories/previous_tag_finder.rb +++ /dev/null @@ -1,57 +0,0 @@ -# frozen_string_literal: true - -module Repositories - # A finder class for getting the tag of the last release before a given - # version. - # - # Imagine a project with the following tags: - # - # * v1.0.0 - # * v1.1.0 - # * v2.0.0 - # - # If the version supplied is 2.1.0, the tag returned will be v2.0.0. And when - # the version is 1.1.1, or 1.2.0, the returned tag will be v1.1.0. - # - # This finder expects that all tags to consider meet the following - # requirements: - # - # * They start with the letter "v" followed by a version, or immediately start - # with a version - # * They use semantic versioning for the version format - # - # Tags not meeting these requirements are ignored. - class PreviousTagFinder - TAG_REGEX = /\Av?(?<version>#{Gitlab::Regex.unbounded_semver_regex})\z/.freeze - - def initialize(project) - @project = project - end - - def execute(new_version) - tags = {} - versions = [new_version] - - @project.repository.tags.each do |tag| - matches = tag.name.match(TAG_REGEX) - - next unless matches - - # When using this class for generating changelog data for a range of - # commits, we want to compare against the tag of the last _stable_ - # release; not some random RC that came after that. - next if matches[:prerelease] - - version = matches[:version] - tags[version] = tag - versions << version - end - - VersionSorter.sort!(versions) - - index = versions.index(new_version) - - tags[versions[index - 1]] if index&.positive? - end - end -end |