(*cli.Context)
| 36 | ) |
| 37 | |
| 38 | func selfUpdate(*cli.Context) (err error) { |
| 39 | up := github.NewReleaseUpdater() |
| 40 | |
| 41 | // 检查更新 |
| 42 | latest, yes, err := up.CheckForUpdates(semver.MustParse(build.ShortVersion), "voidint", "g") |
| 43 | if err != nil { |
| 44 | return cli.Exit(errstring(err), 1) |
| 45 | } |
| 46 | if !yes { |
| 47 | fmt.Printf("You are up to date! g v%s is the latest version.\n", build.ShortVersion) |
| 48 | return nil |
| 49 | } |
| 50 | fmt.Printf("A new version of g(%s) is available\n", latest.TagName) |
| 51 | |
| 52 | // 应用更新 |
| 53 | if err = up.Apply(latest, findAsset, findChecksum); err != nil { |
| 54 | return cli.Exit(errstring(err), 1) |
| 55 | } |
| 56 | fmt.Println("Update completed") |
| 57 | return nil |
| 58 | } |
| 59 | |
| 60 | func findAsset(items []github.Asset) (idx int) { |
| 61 | ext := "tar.gz" |
nothing calls this directly
no test coverage detected
searching dependent graphs…