Skip to content

Commit

Permalink
allow printing bit version outside a git repo. fixes #51
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswalz committed Oct 16, 2020
1 parent 71c26f8 commit 2af08c0
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .goreleaser.yml
Expand Up @@ -86,7 +86,7 @@ brews:

# Caveats for the user of your binary.
# Default is empty.
caveats: "How to use this binary"
# caveats: "How to use this binary"

# Your app's homepage.
# Default is empty.
Expand All @@ -112,8 +112,8 @@ brews:
# ...

# Packages your package depends on.
dependencies:
- name: git
#dependencies:
# - name: git

# Packages that conflict with your package.
#conflicts:
Expand Down
7 changes: 6 additions & 1 deletion a.MD
Expand Up @@ -103,4 +103,9 @@ COMP_POINT=25 COMP_LINE="bit status" bitcomplete

apt-get install language-pack-es
locale -e
LC_ALL=es_MX.utf8 git status
LC_ALL=es_MX.utf8 git status


https://github.com/chriswalz/bit/releases/download/v0.6.5/bit_0.6.5_Darwin_x86_64.tar.gz

https://github.com/chriswalz/bit/releases/v0.6.5/bit_0.6.5_Darwin_x86_64.tar.gz
2 changes: 1 addition & 1 deletion cmd/git.go
Expand Up @@ -173,7 +173,7 @@ func AllGitAliases() (cc []*cobra.Command) {
return cc
}

func printGitVersion() {
func PrintGitVersion() {
msg, err := exec.Command("git", "--version").CombinedOutput()
if err != nil {
//fmt.Println(err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/rootShell.go
Expand Up @@ -13,7 +13,7 @@ import (
var ShellCmd = &cobra.Command{
Use: "bit",
Short: "Bit is a Git CLI that predicts what you want to do",
Long: `v0.6.1`,
Long: `v0.6.6`,
Run: func(cmd *cobra.Command, args []string) {
completerSuggestionMap, bitCmdMap := CreateSuggestionMap(cmd)

Expand Down Expand Up @@ -136,7 +136,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.6.1")
fmt.Println("bit version v0.6.6")
}
if isBranchCompletionCommand(sub) {
branchName := ""
Expand Down
4 changes: 2 additions & 2 deletions cmd/util.go
Expand Up @@ -226,8 +226,8 @@ func HandleExit() {
fmt.Println(v)
fmt.Println(string(debug.Stack()))
fmt.Println("OS:", runtime.GOOS, runtime.GOARCH)
fmt.Println("bit version v0.6.1")
printGitVersion()
fmt.Println("bit version v0.6.6")
PrintGitVersion()

}
}
Expand Down
5 changes: 5 additions & 0 deletions main.go
Expand Up @@ -34,6 +34,11 @@ func main() {
// defer needed to handle funkyness with CTRL + C & go-prompt
defer bitcmd.HandleExit()
if !bitcmd.IsGitRepo() {
if len(os.Args) == 2 && os.Args[1] == "--version" {
fmt.Println("bit version v0.6.6")
bitcmd.PrintGitVersion()
return
}
fmt.Println("fatal: not a git repository (or any of the parent directories): .git")
return
}
Expand Down

0 comments on commit 2af08c0

Please sign in to comment.