Skip to content

Commit

Permalink
gofmt, also allow --which-tag without destination dir requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
jinal--shah committed Apr 3, 2018
1 parent eb50161 commit b5c696b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
17 changes: 9 additions & 8 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
Account for only fetching tags that have a prefix with an optional delimiter
before x.y.z (can be a \., \- or \_, or no delimiter)

## --which-tag
FetchTags returns the latest tag or else the one that meets a constraint.

Offer `--which-tag`, which will only display a tag that would have been
downloaded.

* NTH Account for when release asset does not exist - should fail

* Account for when no tag meeting a constraint exists - should fail, not default
to latest.

Expand Down Expand Up @@ -45,6 +37,15 @@ Still need to rename all vars, methods that use Fetch to use something else.

# DONE

## --which-tag
FetchTags returns the latest tag or else the one that meets a constraint.

Offer `--which-tag`, which will only display a tag that would have been
downloaded.


* Account for when release asset does not exist - should fail

## --timeout i

Let user specify net/http timeout (for those larger repos and assets)
Expand Down
2 changes: 1 addition & 1 deletion fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (o *fetchOpts) do(r repo) (err error) {
}

if o.whichTag {
return
return err
}

// If no release assets or from-paths specified, assume
Expand Down
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type fetchOpts struct {
whichTag bool
gpgPubKey string
destDir string
timeout int
timeout int
}

// releaseDl : data to complete download of a release asset
Expand Down Expand Up @@ -191,8 +191,8 @@ func validateOptions(o fetchOpts) error {
return fmt.Errorf("The --%s flag is required.", optRepo)
}

if o.destDir == "" {
return fmt.Errorf("Final argument must be the destination dir.")
if o.destDir == "" && !o.whichTag {
return fmt.Errorf("Final argument must be the destination dir (unless calling --which-tag)")
}

if o.tagConstraint == "" && o.commitSha == "" && o.branch == "" {
Expand All @@ -206,7 +206,7 @@ func validateOptions(o fetchOpts) error {
return fmt.Errorf("The --%s flag can only be used with --%s.", optReleaseAsset, optTag)
}

if o.tagConstraint == "" && o.whichTag {
if o.tagConstraint == "" && o.whichTag {
return fmt.Errorf("The --%s flag makes no sense without --%s.", optWhichTag, optTag)
}

Expand Down

0 comments on commit b5c696b

Please sign in to comment.