2019-07-14 16:51:10 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2020-09-14 18:31:56 +00:00
|
|
|
"github.com/github-release/github-release/github"
|
2019-07-14 16:51:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
TAGS_URI = "/repos/%s/%s/tags"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Tag struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
Commit Commit `json:"commit"`
|
|
|
|
ZipBallUrl string `json:"zipball_url"`
|
|
|
|
TarBallUrl string `json:"tarball_url"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *Tag) String() string {
|
|
|
|
return t.Name + " (commit: " + t.Commit.Url + ")"
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the tags associated with a repo.
|
2020-09-14 18:31:56 +00:00
|
|
|
func Tags(user, repo, authUser, token string) ([]Tag, error) {
|
2019-07-14 16:51:10 +00:00
|
|
|
var tags []Tag
|
2020-09-14 18:31:56 +00:00
|
|
|
client := github.NewClient(authUser, token, nil)
|
|
|
|
client.SetBaseURL(EnvApiEndpoint)
|
|
|
|
return tags, client.Get(fmt.Sprintf(TAGS_URI, user, repo), &tags)
|
2019-07-14 16:51:10 +00:00
|
|
|
}
|