Skip to content

Commit

Permalink
change self-updater library to work with ARM cpus
Browse files Browse the repository at this point in the history
  • Loading branch information
creativeprojects committed Nov 8, 2020
1 parent f9fa0bf commit b30cbe5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/creativeprojects/resticprofile
go 1.13

require (
github.com/creativeprojects/go-selfupdate v0.1.1
github.com/adrg/xdg v0.2.2
github.com/blang/semver v3.5.1+incompatible
github.com/capnspacehook/taskmaster v0.0.0-20190802050140-eebf732b5748
Expand All @@ -14,7 +15,6 @@ require (
github.com/mitchellh/mapstructure v1.3.3
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pelletier/go-toml v1.8.1 // indirect
github.com/rhysd/go-github-selfupdate v1.2.2
github.com/rickb777/date v1.14.3
github.com/shirou/gopsutil/v3 v3.20.10
github.com/smartystreets/assertions v1.0.0 // indirect
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Masterminds/semver/v3 v3.1.0 h1:Y2lUDsFKVRSYGojLJ1yLxSXdMmMYTYls0rCvoqmMUQk=
github.com/Masterminds/semver/v3 v3.1.0/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
Expand Down Expand Up @@ -71,6 +73,9 @@ github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfc
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creativeprojects/clog v0.6.0 h1:xkXbgwOrZ6alPT8j4PneaLLZ0kKXeVi9PFjGcacl4Dg=
github.com/creativeprojects/clog v0.6.0/go.mod h1:JKXBQnvWR1NBQ52d7ddtUd7qHHxyGHuwtVx5ltgUM34=
github.com/creativeprojects/go-selfupdate v0.1.1 h1:r5sWo8Q8YgXh8atKU0RQIfDKNeu6SIn2AvsYJ3SipUs=
github.com/creativeprojects/go-selfupdate v0.1.1/go.mod h1:NyVuo4vfPNDDiTi7Wl94LzV7UccxmpmrP8bvPj+nc74=
github.com/creativeprojects/resticprofile v0.1.0/go.mod h1:pHDefWc4IcjsaPX/wvySQg3JPydThSRFogqewO4SJQQ=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
10 changes: 4 additions & 6 deletions update.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import (
"os"
"runtime"

"github.com/blang/semver"
"github.com/creativeprojects/clog"
"github.com/creativeprojects/go-selfupdate/selfupdate"
"github.com/creativeprojects/resticprofile/term"
"github.com/rhysd/go-github-selfupdate/selfupdate"
)

func confirmAndSelfUpdate(debug bool) error {
if debug {
selfupdate.EnableLog()
selfupdate.SetLogger(clog.NewStandardLogger(clog.LevelDebug, clog.GetDefaultLogger()))
}
latest, found, err := selfupdate.DetectLatest("creativeprojects/resticprofile")
if err != nil {
Expand All @@ -24,13 +23,12 @@ func confirmAndSelfUpdate(debug bool) error {
return fmt.Errorf("latest version for %s/%s could not be found from github repository", runtime.GOOS, runtime.GOARCH)
}

v := semver.MustParse(version)
if latest.Version.LTE(v) {
if latest.LessThan(version) {
clog.Infof("Current version (%s) is the latest", version)
return nil
}

if !term.AskYesNo(os.Stdin, fmt.Sprint("Do you want to update to version ", latest.Version), true) {
if !term.AskYesNo(os.Stdin, fmt.Sprintf("Do you want to update to version %s", latest.Version()), true) {
fmt.Println("Never mind")
return nil
}
Expand Down

0 comments on commit b30cbe5

Please sign in to comment.