Implement new gopkgbuild Newer method

Signed-off-by: Jguer <me@jguer.space>
This commit is contained in:
Jguer 2018-05-14 22:22:47 +01:00
parent 9437bf1576
commit 3dc5238bd2
4 changed files with 13 additions and 27 deletions

4
Gopkg.lock generated
View file

@ -5,7 +5,7 @@
branch = "master" branch = "master"
name = "github.com/jguer/go-alpm" name = "github.com/jguer/go-alpm"
packages = ["."] packages = ["."]
revision = "11d6aadda57c8fb4f93969333cb990677d28d4f9" revision = "6150b61c07385c54c6dd8087b9be05cf8b064424"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -17,7 +17,7 @@
branch = "master" branch = "master"
name = "github.com/mikkeloscar/gopkgbuild" name = "github.com/mikkeloscar/gopkgbuild"
packages = ["."] packages = ["."]
revision = "32274fc52aa8f5eb28711da734179e9aea27b31f" revision = "7b0e7c63b22efc73e1c10e6f3117fdc03cd21816"
[solve-meta] [solve-meta]
analyzer-name = "dep" analyzer-name = "dep"

View file

@ -546,9 +546,10 @@ func downloadPkgBuilds(pkgs []*rpc.Pkg, targets stringSet, bases map[string][]*r
pkgbuild, err := gopkg.ParseSRCINFO(dir) pkgbuild, err := gopkg.ParseSRCINFO(dir)
if err == nil { if err == nil {
version, err := gopkg.NewCompleteVersion(pkg.Version) versionRPC, errR := gopkg.NewCompleteVersion(pkg.Version)
if err == nil { versionPKG, errP := gopkg.NewCompleteVersion(pkgbuild.Version())
if !version.Newer(pkgbuild.Version()) { if errP == nil && errR == nil {
if !versionRPC.Newer(versionPKG) {
str := bold(cyan("::") + " PKGBUILD up to date, Skipping (%d/%d): %s\n") str := bold(cyan("::") + " PKGBUILD up to date, Skipping (%d/%d): %s\n")
fmt.Printf(str, k+1, len(pkgs), cyan(formatPkgbase(pkg, bases))) fmt.Printf(str, k+1, len(pkgs), cyan(formatPkgbase(pkg, bases)))
continue continue

View file

@ -616,7 +616,7 @@ func isLowerAlpha(c rune) bool {
// check if c is a valid pkgname char // check if c is a valid pkgname char
func isValidPkgnameChar(c rune) bool { func isValidPkgnameChar(c rune) bool {
return isLowerAlpha(c) || isDigit(c) || c == '@' || c == '.' || c == '_' || c == '+' || c == '-' return isAlphaNumeric(c) || c == '@' || c == '.' || c == '_' || c == '+' || c == '-'
} }
// check if c is a valid pkgver char // check if c is a valid pkgver char

View file

@ -74,33 +74,18 @@ func NewCompleteVersion(s string) (*CompleteVersion, error) {
return nil, fmt.Errorf("invalid version format: %s", s) return nil, fmt.Errorf("invalid version format: %s", s)
} }
// Older returns true if a is older than the argument version string // Older returns true if a is older than the argument version
func (a *CompleteVersion) Older(v string) bool { func (a *CompleteVersion) Older(b *CompleteVersion) bool {
b, err := NewCompleteVersion(v)
if err != nil {
return false
}
return a.cmp(b) == -1 return a.cmp(b) == -1
} }
// Newer returns true if a is newer than the argument version string // Newer returns true if a is newer than the argument version
func (a *CompleteVersion) Newer(v string) bool { func (a *CompleteVersion) Newer(b *CompleteVersion) bool {
b, err := NewCompleteVersion(v)
if err != nil {
return false
}
return a.cmp(b) == 1 return a.cmp(b) == 1
} }
// Equal returns true if a is equal to the argument version string // Equal returns true if a is equal to the argument version
func (a *CompleteVersion) Equal(v string) bool { func (a *CompleteVersion) Equal(b *CompleteVersion) bool {
b, err := NewCompleteVersion(v)
if err != nil {
return false
}
return a.cmp(b) == 0 return a.cmp(b) == 0
} }