Skip to content

Commit

Permalink
releases: use specific release-of-tag endpoint
Browse files Browse the repository at this point in the history
This should be more efficient since we don't need to iterate over the list
of all releases, and hopefully it will also list incomplete assets (though I
can't test this).

Updates github-release#26.
  • Loading branch information
aktau committed Mar 29, 2017
1 parent f974db7 commit 70ed556
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

const (
RELEASE_LIST_URI = "/repos/%s/%s/releases"
RELEASE_BY_TAG_URI = "/repos/%s/%s/releases/tags/%s" // /repos/:owner/:repo/releases/tags/:tag
RELEASE_LATEST_URI = "/repos/%s/%s/releases/latest"
RELEASE_DATE_FORMAT = "02/01/2006 at 15:04"
)
Expand Down Expand Up @@ -111,19 +112,11 @@ func LatestRelease(user, repo, token string) (*Release, error) {
return &releases[latestRelIndex], nil
}

// ReleaseOfTag returns the Github release corresponding to a git tag, if it
// exists.
func ReleaseOfTag(user, repo, tag, token string) (*Release, error) {
releases, err := Releases(user, repo, token)
if err != nil {
return nil, err
}

for _, release := range releases {
if release.TagName == tag {
return &release, nil
}
}

return nil, fmt.Errorf("could not find the release corresponding to tag %s", tag)
var release Release
return &release, github.Client{Token: token, BaseURL: EnvApiEndpoint}.Get(fmt.Sprintf(RELEASE_BY_TAG_URI, user, repo, tag), &release)
}

/* find the release-id of the specified tag */
Expand Down

0 comments on commit 70ed556

Please sign in to comment.