updater: support ignoring versions

This commit is contained in:
Jared Allard 2025-03-04 16:57:14 -08:00
parent 1119ab0e63
commit 3a197732d8
Signed by: jaredallard
SSH key fingerprint: SHA256:wyRyyv28jBYw8Yp/oABNPUYvbGd6hyZj23XVXEm5G/U
2 changed files with 10 additions and 0 deletions

View file

@ -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.

View file

@ -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