Add a way to check the minimum version supported by a LURE repo
This commit is contained in:
parent
101eeece89
commit
447f71a499
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
/lure
|
||||
/dist/
|
||||
/dist/
|
||||
/version.txt
|
@ -1,6 +1,7 @@
|
||||
before:
|
||||
hooks:
|
||||
- go mod tidy
|
||||
- go generate
|
||||
builds:
|
||||
- id: lure
|
||||
env:
|
||||
|
5
Makefile
5
Makefile
@ -1,4 +1,4 @@
|
||||
lure:
|
||||
lure: version.txt
|
||||
go build
|
||||
|
||||
clean:
|
||||
@ -9,5 +9,8 @@ install: lure
|
||||
|
||||
uninstall:
|
||||
rm -f /usr/local/bin/lure
|
||||
|
||||
version.txt:
|
||||
go generate
|
||||
|
||||
.PHONY: install clean uninstall
|
43
repo.go
43
repo.go
@ -41,6 +41,12 @@ func (p PkgNotFoundError) Error() string {
|
||||
return "package '" + p.pkgName + "' could not be found in any repository"
|
||||
}
|
||||
|
||||
type RepoConfig struct {
|
||||
Repo struct {
|
||||
MinVersion string `toml:"minVersion"`
|
||||
}
|
||||
}
|
||||
|
||||
func addrepoCmd(c *cli.Context) error {
|
||||
name := c.String("name")
|
||||
repoURL := c.String("url")
|
||||
@ -223,6 +229,26 @@ func pullRepos(ctx context.Context) error {
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fl, err := w.Filesystem.Open("lure-repo.toml")
|
||||
if err != nil {
|
||||
log.Warn("Git repository does not appear to be a valid LURE repo").Str("repo", repo.Name).Send()
|
||||
continue
|
||||
}
|
||||
|
||||
var repoCfg RepoConfig
|
||||
err = toml.NewDecoder(fl).Decode(&repoCfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fl.Close()
|
||||
|
||||
currentVer, _, _ := strings.Cut(version, "-")
|
||||
if vercmp(currentVer, repoCfg.Repo.MinVersion) == -1 {
|
||||
log.Warn("LURE repo's minumum LURE version is greater than the current version. Try updating LURE if something doesn't work.").Str("repo", repo.Name).Send()
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
err = os.RemoveAll(repoDir)
|
||||
@ -246,6 +272,23 @@ func pullRepos(ctx context.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fl, err := os.Open(filepath.Join(repoDir, "lure-repo.toml"))
|
||||
if err != nil {
|
||||
log.Warn("Git repository does not appear to be a valid LURE repo").Str("repo", repo.Name).Send()
|
||||
}
|
||||
|
||||
var repoCfg RepoConfig
|
||||
err = toml.NewDecoder(fl).Decode(&repoCfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fl.Close()
|
||||
|
||||
currentVer, _, _ := strings.Cut(version, "-")
|
||||
if vercmp(currentVer, repoCfg.Repo.MinVersion) == -1 {
|
||||
log.Warn("LURE repo's minumum LURE version is greater than the current version. Try updating LURE if something doesn't work.").Str("repo", repo.Name).Send()
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
3
scripts/gen-version.sh
Executable file
3
scripts/gen-version.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
git describe --tags > version.txt
|
@ -19,12 +19,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
//go:generate scripts/gen-version.sh
|
||||
|
||||
//go:embed version.txt
|
||||
var version string
|
||||
|
||||
// vercmp compares two version strings.
|
||||
// It returns 1 if v1 is greater,
|
||||
// 0 if the versions are equal,
|
||||
|
Loading…
Reference in New Issue
Block a user