filter by drafts in the check step

The user now opts-in to getting final or draft releases. Default
behaviour is final releases.

NOTE: There is also strict filtering on only allowing semver supported tags.

Signed-off-by: David Jahn <david.a.jahn@gmail.com>
This commit is contained in:
JT Archie
2015-10-22 12:27:52 -04:00
committed by David Jahn
parent e3a3a53dba
commit 7331e0a7ad
13 changed files with 329 additions and 54 deletions

View File

@@ -8,6 +8,7 @@ import (
"net/http"
"os"
"path/filepath"
"strconv"
"github.com/zachgersh/go-github/github"
)
@@ -32,7 +33,12 @@ func (c *InCommand) Run(destDir string, request InRequest) (InResponse, error) {
var foundRelease *github.RepositoryRelease
foundRelease, err = c.github.GetReleaseByTag(request.Version.Tag)
if request.Version.Tag != "" {
foundRelease, err = c.github.GetReleaseByTag(request.Version.Tag)
} else {
id, _ := strconv.Atoi(request.Version.ID)
foundRelease, err = c.github.GetRelease(id)
}
if err != nil {
return InResponse{}, err
}
@@ -41,7 +47,7 @@ func (c *InCommand) Run(destDir string, request InRequest) (InResponse, error) {
return InResponse{}, errors.New("no releases")
}
if *foundRelease.TagName != "" {
if foundRelease.TagName != nil && *foundRelease.TagName != "" {
tagPath := filepath.Join(destDir, "tag")
err = ioutil.WriteFile(tagPath, []byte(*foundRelease.TagName), 0644)
if err != nil {
@@ -116,9 +122,7 @@ func (c *InCommand) Run(destDir string, request InRequest) (InResponse, error) {
}
return InResponse{
Version: Version{
Tag: *foundRelease.TagName,
},
Version: versionFromDraft(foundRelease),
Metadata: metadataFromRelease(foundRelease),
}, nil
}