forked from owenthereal/gh
/
release.go
41 lines (35 loc) · 889 Bytes
/
release.go
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
37
38
39
40
41
package commands
import (
"fmt"
"github.com/jingweno/gh/github"
"github.com/jingweno/gh/utils"
"os"
"strings"
)
var cmdRelease = &Command{
Run: release,
Usage: "release",
Short: "Manipulate releases on GitHub",
Long: `Manipulates releases on GitHub for the project that the "origin" remote
points to.
`,
}
func release(cmd *Command, args *Args) {
localRepo := github.LocalRepo()
project, err := localRepo.CurrentProject()
utils.Check(err)
gh := github.NewClient(project.Host)
if args.Noop {
fmt.Printf("Would request list of releases for %s\n", project)
} else {
releases, err := gh.Releases(project)
utils.Check(err)
var outputs []string
for _, release := range releases {
out := fmt.Sprintf("%s (%s)\n%s", release.Name, release.TagName, release.Body)
outputs = append(outputs, out)
}
fmt.Println(strings.Join(outputs, "\n\n"))
}
os.Exit(0)
}