Skip to content

Commit

Permalink
add bit update <version>
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswalz committed Oct 20, 2020
1 parent f975015 commit 3b11b4e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cmd/rootShell.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
var ShellCmd = &cobra.Command{
Use: "bit",
Short: "Bit is a Git CLI that predicts what you want to do",
Long: `v0.7.1`,
Long: `v0.7.3`,
Run: func(cmd *cobra.Command, args []string) {
completerSuggestionMap, bitCmdMap := CreateSuggestionMap(cmd)

Expand Down Expand Up @@ -141,7 +141,7 @@ func GitCommandsPromptUsed(args []string, suggestionMap map[string][]prompt.Sugg
// expected usage format
// bit (checkout|switch|co) [-b] branch-name
if args[len(args)-1] == "--version" {
fmt.Println("bit version v0.7.1")
fmt.Println("bit version v0.7.3")
}
if isBranchChangeCommand(sub) {
branchName := ""
Expand Down
23 changes: 14 additions & 9 deletions cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,36 @@ import (
// updateCmd represents the update command
var updateCmd = &cobra.Command{
Use: "update",
Short: "Updates bit to the latest version",
Long: ``,
Short: "Updates bit to the latest or specified version",
Long: `bit update
bit update v0.7.3 (note: v is required)`,
Run: func(cmd *cobra.Command, args []string) {
targetVersion := ""
if len(args) == 1 {
targetVersion = args[0][1:]
}

version := "v0.7.1"
currentVersion := "v0.7.3"

// open-source edition
p := &update.Manager{
Command: "bit",
Store: &github.Store{
Owner: "chriswalz",
Repo: "bit",
Version: version[1:],
Version: currentVersion[1:],
},
}

// fetch latest or specified release
release, err := getLatestOrSpecified(p, version[1:])
release, err := getLatestOrSpecified(p, targetVersion)
if err != nil {
fmt.Println(errors.Wrap(err, "fetching latest release").Error())
fmt.Println(errors.Wrap(err, "fetching latest or specified release").Error())
return
}

// no updates
if version == release.Version {
if currentVersion == release.Version {
fmt.Println("No updates available, you're good :)")
return
}
Expand Down Expand Up @@ -71,10 +76,10 @@ var updateCmd = &cobra.Command{
return
}

fmt.Printf("Updated bit %s to %s in %s", version, release.Version, dst)
fmt.Printf("Updated bit %s to %s in %s", currentVersion, release.Version, dst)

},
Args: cobra.NoArgs,
Args: cobra.MaximumNArgs(1),
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func HandleExit() {
fmt.Println(v)
fmt.Println(string(debug.Stack()))
fmt.Println("OS:", runtime.GOOS, runtime.GOARCH)
fmt.Println("bit version v0.7.1")
fmt.Println("bit version v0.7.3")
PrintGitVersion()

}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func main() {
// verify is git repo
if !bitcmd.IsGitRepo() {
if len(os.Args) == 2 && os.Args[1] == "--version" {
fmt.Println("bit version v0.7.0")
fmt.Println("bit version v0.7.3")
bitcmd.PrintGitVersion()
return
}
Expand Down

0 comments on commit 3b11b4e

Please sign in to comment.