chriswalz / bit

Bit is a modern Git CLI
Apache License 2.0
6.05k stars 106 forks source link

Runtime error on `bit release bump` when no tags #101

Closed twavv closed 3 years ago

twavv commented 3 years ago

Describe the bug I ran into this on accident (running the command in the wrong repo), but would be better to fail more gracefully.

$ bit release bump --debug

runtime error: slice bounds out of range [:-1]
goroutine 1 [running]:
runtime/debug.Stack(0x185a980, 0xc000010018, 0xc00036b528)
        runtime/debug/stack.go:24 +0x9f
github.com/chriswalz/bit/cmd.HandleExit()
        github.com/chriswalz/bit/cmd/util.go:320 +0xd9
panic(0x17680e0, 0xc000028640)
        runtime/panic.go:969 +0x1b9
github.com/chriswalz/bit/cmd.GenBumpedSemVersion(0xc000242500, 0xc00036b888)
        github.com/chriswalz/bit/cmd/util.go:122 +0x2ae
github.com/chriswalz/bit/cmd.glob..func6(0x1b7f180, 0xc00000f0c0, 0x1, 0x2)
        github.com/chriswalz/bit/cmd/release.go:17 +0x1c5
github.com/spf13/cobra.(*Command).execute(0x1b7f180, 0xc00000f0a0, 0x2, 0x2, 0x1b7f180, 0xc00000f0a0)
        github.com/spf13/cobra@v1.1.1/command.go:854 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0x1b7f960, 0x7ffeefbff524, 0x7, 0x1)
        github.com/spf13/cobra@v1.1.1/command.go:958 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.1.1/command.go:895
github.com/chriswalz/bit/cmd.Execute()
        github.com/chriswalz/bit/cmd/bit_cmd.go:58 +0x31
main.bitcli(...)
        github.com/chriswalz/bit/main.go:78
main.main()
        github.com/chriswalz/bit/main.go:66 +0x96a

I think this happens because that repo has no tags. Arguably, it should error, but should be a human readable error message.

lepinkainen commented 3 years ago

Same issue here, repo with no tags. MacOS Big Sur with latest versions of everything.

> bit release bump
runtime error: slice bounds out of range [:-1]
goroutine 1 [running]:
runtime/debug.Stack(0x185a980, 0xc0000b0008, 0xc0003432e0)
    runtime/debug/stack.go:24 +0x9f
github.com/chriswalz/bit/cmd.HandleExit()
    github.com/chriswalz/bit/cmd/util.go:320 +0xd9
panic(0x17680e0, 0xc0000261e0)
    runtime/panic.go:969 +0x1b9
github.com/chriswalz/bit/cmd.GenBumpedSemVersion(0xc0001d8700, 0xc000343640)
    github.com/chriswalz/bit/cmd/util.go:122 +0x2ae
github.com/chriswalz/bit/cmd.glob..func6(0x1b7f180, 0xc000510140, 0x1, 0x1)
    github.com/chriswalz/bit/cmd/release.go:17 +0x1c5
github.com/spf13/cobra.(*Command).execute(0x1b7f180, 0xc000510110, 0x1, 0x1, 0x1b7f180, 0xc000510110)
    github.com/spf13/cobra@v1.1.1/command.go:854 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0x1b7f960, 0xc00040ca80, 0x17ac249, 0x7)
    github.com/spf13/cobra@v1.1.1/command.go:958 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
    github.com/spf13/cobra@v1.1.1/command.go:895
github.com/chriswalz/bit/cmd.glob..func1(0x1b7f960, 0x1bb70e8, 0x0, 0x0)
    github.com/chriswalz/bit/cmd/bit_cmd.go:47 +0x21a
github.com/spf13/cobra.(*Command).execute(0x1b7f960, 0xc0000981b0, 0x0, 0x0, 0x1b7f960, 0xc0000981b0)
    github.com/spf13/cobra@v1.1.1/command.go:854 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0x1b7f960, 0x600, 0x0, 0x0)
    github.com/spf13/cobra@v1.1.1/command.go:958 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
    github.com/spf13/cobra@v1.1.1/command.go:895
github.com/chriswalz/bit/cmd.Execute()
    github.com/chriswalz/bit/cmd/bit_cmd.go:58 +0x31
main.bitcli(...)
    github.com/chriswalz/bit/main.go:78
main.main()
    github.com/chriswalz/bit/main.go:66 +0x96a

OS: darwin amd64
bit version v1.0.1
git version 2.24.3 (Apple Git-128)
chriswalz commented 3 years ago

This issue should is now fixed in version v1.0.2. Please let me know if you're still having problems. Also, consider donating if you're enjoying using Bit :)

use bit update