gruntwork-io / fetch

Download files, folders, and release assets from a specific git commit, branch, or tag of public and private GitHub repos.
https://www.gruntwork.io/
MIT License
595 stars 87 forks source link

Panic when repo has no existing tags #10

Closed brikis98 closed 8 years ago

brikis98 commented 8 years ago

I ran fetch against a repo that didn't have any tags and it panics:

goroutine 1 [running]:
panic(0x7f8a00, 0xc820010030)
    /usr/local/go/src/runtime/panic.go:464 +0x3e6
main.getLatestAcceptableTag(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/josh/go/src/github.com/gruntwork-io/fetch/tag.go:28 +0x6f1
main.runFetch(0xc820090a00, 0x0, 0x0)
    /Users/josh/go/src/github.com/gruntwork-io/fetch/main.go:102 +0xaba
main.runFetchWrapper(0xc820090a00)
    /Users/josh/go/src/github.com/gruntwork-io/fetch/main.go:48 +0x30
github.com/gruntwork-io/fetch/vendor/github.com/codegangsta/cli.(*App).Run(0xc820084840, 0xc82000a0e0, 0x7, 0x7, 0x0, 0x0)
    /Users/josh/go/src/github.com/gruntwork-io/fetch/vendor/github.com/codegangsta/cli/app.go:201 +0x13ce
main.main()
    /Users/josh/go/src/github.com/gruntwork-io/fetch/main.go:43 +0x517

The cause is this code:

if tagConstraint == "" {
  tagConstraint = versions[len(versions)-1].String()
}

The code should check that versions is not empty.