tweak fields of Release struct and add docs for them

This commit is contained in:
rhysd 2017-12-28 17:39:13 +09:00
parent 9c8dc3199b
commit 0c3940241c
4 changed files with 14 additions and 10 deletions

View File

@ -23,7 +23,7 @@ func selfUpdate() error {
fmt.Println("Current binary is the latest version", version)
} else {
fmt.Println("Update successfully done to version", latest.Version)
fmt.Println("Release note:\n", latest.Description)
fmt.Println("Release note:\n", latest.ReleaseNotes)
}
return nil
}

View File

@ -113,9 +113,9 @@ func (d *ReleaseDetector) DetectLatest(slug string) (release *Release, found boo
}
release = &Release{
AssetURL: url,
DocumentURL: rel.GetHTMLURL(),
Description: rel.GetBody(),
AssetURL: url,
URL: rel.GetHTMLURL(),
ReleaseNotes: rel.GetBody(),
}
release.Version, err = semver.Make(tag)

View File

@ -32,10 +32,10 @@ func TestDetectReleaseWithVersionPrefix(t *testing.T) {
if !strings.HasSuffix(r.AssetURL, ".zip") && !strings.HasSuffix(r.AssetURL, ".tar.gz") {
t.Error("Incorrect URL for asset:", r.AssetURL)
}
if r.DocumentURL == "" {
if r.URL == "" {
t.Error("Document URL should not be empty")
}
if r.Description == "" {
if r.ReleaseNotes == "" {
t.Error("Description should not be empty for this repo")
}
}

View File

@ -6,8 +6,12 @@ import (
// Release represents a release asset for current OS and arch.
type Release struct {
Version semver.Version
AssetURL string
DocumentURL string
Description string
// Version is the version of the release
Version semver.Version
// AssetURL is a URL to the uploaded file for the release
AssetURL string
// URL is a URL to release page for browsing
URL string
// ReleaseNotes is a release notes of the release
ReleaseNotes string
}