debian-mirror-gitlab/app/finders/packages/go/version_finder.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.1 KiB
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
module Packages
module Go
class VersionFinder
include Gitlab::Golang
attr_reader :mod
def initialize(mod)
@mod = mod
end
def execute
@mod.project.repository.tags
.filter { |tag| semver_tag? tag }
.map { |tag| @mod.version_by(ref: tag) }
.filter { |ver| ver.valid? }
end
def find(target)
case target
when String
if pseudo_version? target
semver = parse_semver(target)
2021-04-29 21:17:54 +05:30
version = parse_pseudo_version(semver)
commit = validate_pseudo_version(@mod.project, version)
2020-07-28 23:09:34 +05:30
Packages::Go::ModuleVersion.new(@mod, :pseudo, commit, name: target, semver: semver)
else
@mod.version_by(ref: target)
end
when Gitlab::Git::Ref
@mod.version_by(ref: target)
when ::Commit, Gitlab::Git::Commit
@mod.version_by(commit: target)
else
2021-06-08 01:23:25 +05:30
raise ArgumentError, 'not a valid target'
2020-07-28 23:09:34 +05:30
end
end
end
end
end