forked from github-release/github-release
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtags.go
More file actions
36 lines (28 loc) · 628 Bytes
/
tags.go
File metadata and controls
36 lines (28 loc) · 628 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"fmt"
)
const (
TAGS_URI = "/repos/%s/%s/tags%s"
)
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 */
func Tags(user, repo, token string) ([]Tag, error) {
var tags []Tag
if token != "" {
token = "?access_token=" + token
}
err := GithubGet(fmt.Sprintf(TAGS_URI, user, repo, token), &tags)
if err != nil {
return nil, err
}
return tags, nil
}