Skip to content

Commit

Permalink
Improve version comparison of miuimon.go
Browse files Browse the repository at this point in the history
  • Loading branch information
linusyang committed Nov 3, 2018
1 parent bb2cb67 commit 0c6cd61
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
*.aria2
/tools/win32/
compare/
/tools/miuimon/miuimon
8 changes: 8 additions & 0 deletions tools/miuimon/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
miuimon: main.go
go get -d -v ./...
go build -o $@ -v -ldflags "-s -w" main.go

clean:
rm -f miuimon

.PHONY: clean
5 changes: 3 additions & 2 deletions tools/miuimon.go → tools/miuimon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"time"

"github.com/google/go-github/github"
gover "github.com/mcuadros/go-version"
"github.com/mmcdole/gofeed"
"github.com/yhat/scrape"
"golang.org/x/net/html"
Expand Down Expand Up @@ -182,14 +183,14 @@ func getNewDeploy(currentVer, currentDeploy string,
version = currentVer
deploy = []byte(currentDeploy)
err = nil
if miuiVer > currentVer || force {
if gover.Compare(miuiVer, currentVer, ">") || force {
version = miuiVer
euVer, euUrl = getEu(miuiVer)
if euVer == miuiVer || force {
deploy = newDeployFile(miuiVer, miuiUrl, euUrl, currentDeploy)
}
}
if miuiVer <= currentVer {
if gover.Compare(miuiVer, currentVer, "<=") {
err = errors.New(fmt.Sprintf("MIUI China (current: %s)", miuiVer))
} else if euVer != miuiVer {
err = errors.New(fmt.Sprintf("xiaomi.eu (current: %s)", euVer))
Expand Down

0 comments on commit 0c6cd61

Please sign in to comment.