Skip to content

Commit

Permalink
Let's use the right API for tags
Browse files Browse the repository at this point in the history
  • Loading branch information
DataDrake committed Aug 4, 2018
1 parent 7a3e69b commit 364a583
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions providers/github/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
// APIReleases is a format string for the Releases API
APIReleases = "https://api.github.com/repos/%s/releases"
// APITags is a format string for the Tags API
APITags = "https://api.github.com/repos/%s/git/refs/tags"
APITags = "https://api.github.com/repos/%s/tags"
// SourceFormat is the format string for Github release tarballs
SourceFormat = "https://github.com/%s/archive/%s.tar.gz"
)
Expand Down Expand Up @@ -67,7 +67,7 @@ func (c Provider) Latest(name string) (r *results.Result, s results.Status) {
if s != results.OK || rs.Empty() {
return
}
r = rs.Last()
r = rs.First()
return
default:
s = results.Unavailable
Expand Down
4 changes: 2 additions & 2 deletions providers/github/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import (

// Tag is a JSON representation of a Github tag
type Tag struct {
Ref string `json:"ref"`
Name string `json:"name"`
}

// Convert turns a Github tag into a Cuppa result
func (t *Tag) Convert(name string) *results.Result {
r := &results.Result{}
pieces := strings.Split(name, "/")
r.Name = pieces[len(pieces)-1]
pieces = strings.Split(t.Ref, "/")
pieces = strings.Split(t.Name, "/")
r.Version = pieces[len(pieces)-1]
r.Location = fmt.Sprintf(SourceFormat, name, r.Version)
return r
Expand Down

0 comments on commit 364a583

Please sign in to comment.