Skip to content

Commit

Permalink
Add the ability to specify a release in self-update
Browse files Browse the repository at this point in the history
  • Loading branch information
rbayliss committed Feb 11, 2016
1 parent d4ecf87 commit 4f0197e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cmd/selfupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ var CmdSelfUpdate = cli.Command{
}

func runSelfUpdate(ctx *cli.Context) {
release, err := getRelease("latest")
version := "latest"
if len(ctx.Args()) > 0 {
version = ctx.Args()[0]
}
release, err := getRelease(version)
if err != nil {
util.Fatal("Unable to fetch release data")
}
Expand All @@ -47,7 +51,11 @@ func runSelfUpdate(ctx *cli.Context) {

func getRelease(version string) (release *github.RepositoryRelease, err error) {
client := github.NewClient(nil)
release, _, err = client.Repositories.GetLatestRelease("LastCallMedia", "vagabond")
if version == "latest" {
release, _, err = client.Repositories.GetLatestRelease("LastCallMedia", "vagabond")
} else {
release, _, err = client.Repositories.GetReleaseByTag("LastCallMedia", "vagabond", version)
}

return
}
Expand Down

0 comments on commit 4f0197e

Please sign in to comment.