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"
name = "github.com/jguer/go-alpm"
packages = ["."]
revision = "11d6aadda57c8fb4f93969333cb990677d28d4f9"
revision = "6150b61c07385c54c6dd8087b9be05cf8b064424"
[[projects]]
branch = "master"
@ -17,7 +17,7 @@
branch = "master"
name = "github.com/mikkeloscar/gopkgbuild"
packages = ["."]
revision = "32274fc52aa8f5eb28711da734179e9aea27b31f"
revision = "7b0e7c63b22efc73e1c10e6f3117fdc03cd21816"
[solve-meta]
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)
if err == nil {
version, err := gopkg.NewCompleteVersion(pkg.Version)
if err == nil {
if !version.Newer(pkgbuild.Version()) {
versionRPC, errR := gopkg.NewCompleteVersion(pkg.Version)
versionPKG, errP := gopkg.NewCompleteVersion(pkgbuild.Version())
if errP == nil && errR == nil {
if !versionRPC.Newer(versionPKG) {
str := bold(cyan("::") + " PKGBUILD up to date, Skipping (%d/%d): %s\n")
fmt.Printf(str, k+1, len(pkgs), cyan(formatPkgbase(pkg, bases)))
continue

View file

@ -616,7 +616,7 @@ func isLowerAlpha(c rune) bool {
// check if c is a valid pkgname char
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

View file

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