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
588 stars 90 forks source link

added additional constraint check for ~> matching #22

Closed austinfrey closed 7 years ago

austinfrey commented 7 years ago

this should fix issue #6 where the ~> operator finds an acceptable tag on what should be an unavailable tag.

austinfrey commented 7 years ago

Hi @brikis98 , so my little if statement returns latestTag which, up until this point in the program has not been assigned since no matching tags have been found. An error is thrown and handled after the getLatestAcceptableTag function returns to the main function with an empty latestTag value. I can add an error here, though, if you'd like. Would return latestTag, wrapError(errors.New("Tag does not exist")) be OK?

before the change

fetch  --tag="~>v0.0.4" --repo https://github.com/gruntwork-io/fetch-test-public ~/tag-test
>Downloading tag "v0.0.1" of https://github.com/gruntwork-io/fetch-test-public ...
>Extracting files from <repo>/ to /home/austin/tag-test ...
>Download and file extraction complete.

after the change

fetch --tag="~>v0.0.4" --repo https://github.com/gruntwork-io/fetch-test-public ~/tag-test
ERROR: The commit sha, tag, and branch name are all empty.
brikis98 commented 7 years ago

Ah, gotcha. Yea, please return a custom error message so it's clear what happened. "The commit sha, tag, and branch name are all empty" is not accurate and will confuse users. Once that and the automated test are added, this will be ready to go!

austinfrey commented 7 years ago

Sounds good!

austinfrey commented 7 years ago

test added

austinfrey commented 7 years ago

closing to resubmit as one commit

brikis98 commented 7 years ago

Sounds good!