updater: support ignoring versions
This commit is contained in:
parent
1119ab0e63
commit
3a197732d8
2 changed files with 10 additions and 0 deletions
|
@ -141,6 +141,10 @@ type GitOptions struct {
|
||||||
// when a tag is used and the version is able to be parsed as a
|
// when a tag is used and the version is able to be parsed as a
|
||||||
// semver. Defaults to false.
|
// semver. Defaults to false.
|
||||||
ConsiderPreReleases bool `yaml:"consider_pre_releases"`
|
ConsiderPreReleases bool `yaml:"consider_pre_releases"`
|
||||||
|
|
||||||
|
// IgnoreVersions is a list of versions to always ignore (looking at
|
||||||
|
// you, Zed).
|
||||||
|
IgnoreVersions []string `yaml:"ignore_versions"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// APTOptions contains the options for the APT resolver.
|
// APTOptions contains the options for the APT resolver.
|
||||||
|
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/blang/semver/v4"
|
"github.com/blang/semver/v4"
|
||||||
|
@ -69,6 +70,11 @@ func getGitVersion(ce *packages.Package) (string, error) {
|
||||||
// Strip the "refs/tags/" prefix.
|
// Strip the "refs/tags/" prefix.
|
||||||
tag := strings.TrimPrefix(fqTag, "refs/tags/")
|
tag := strings.TrimPrefix(fqTag, "refs/tags/")
|
||||||
|
|
||||||
|
// Ignore the version if told to do so.
|
||||||
|
if slices.Contains(ce.GitOptions.IgnoreVersions, tag) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Attempt to parse as a semver, for other options.
|
// Attempt to parse as a semver, for other options.
|
||||||
if sv, err := semver.ParseTolerant(tag); err == nil {
|
if sv, err := semver.ParseTolerant(tag); err == nil {
|
||||||
isPreRelease := len(sv.Pre) > 0
|
isPreRelease := len(sv.Pre) > 0
|
||||||
|
|
Loading…
Add table
Reference in a new issue