Merge pull request #419 from Jguer/impgopkgchange

Implement new gopkgbuild Newer method
This commit is contained in:
J Guerreiro 2018-05-15 12:48:39 +01:00 committed by GitHub
commit 0c49f0f7cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 27 deletions

6
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,8 +17,8 @@
branch = "master"
name = "github.com/mikkeloscar/gopkgbuild"
packages = ["."]
revision = "763d921490d8f4b23b1141c89ce8f9678ac025a7"
revision = "7b0e7c63b22efc73e1c10e6f3117fdc03cd21816"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1

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

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