Skip to content

Commit

Permalink
chore: moves release logic to github pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszmajsak committed Dec 5, 2019
1 parent 0cc6281 commit 551590b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
6 changes: 4 additions & 2 deletions pkg/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"strings"
"time"

"github.com/bartoszmajsak/github-changelog-generator/pkg/github"

"github.com/bartoszmajsak/github-changelog-generator/pkg/cmd/version"
"github.com/bartoszmajsak/github-changelog-generator/pkg/config"
"github.com/bartoszmajsak/github-changelog-generator/pkg/format"
Expand All @@ -22,8 +24,8 @@ func NewCmd() *cobra.Command {
PersistentPreRunE: func(cmd *cobra.Command, args []string) error { //nolint[:unparam]
if v.Released() {
go func() {
latestRelease, _ := version.LatestRelease()
if !version.IsLatestRelease(latestRelease) {
latestRelease, _ := github.LatestRelease()
if !github.IsLatestRelease(latestRelease) {
releaseInfo <- fmt.Sprintf("WARN: you are using %s which is not the latest release (newest is %s).\n"+
"Follow release notes for update info https://github.com/Maistra/istio-workspace/releases/latest", v.Version, latestRelease)
} else {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/version/releases.go → pkg/github/releases.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package version
package github

import (
"net/http"
Expand Down
14 changes: 7 additions & 7 deletions pkg/cmd/version/releases_test.go → pkg/github/releases_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package version_test
package github_test

import (
"gopkg.in/h2non/gock.v1"

"github.com/bartoszmajsak/github-changelog-generator/pkg/cmd/version"
"github.com/bartoszmajsak/github-changelog-generator/pkg/github"
v "github.com/bartoszmajsak/github-changelog-generator/version"

. "github.com/onsi/ginkgo"
Expand All @@ -25,7 +25,7 @@ var _ = Describe("Fetching latest release", func() {

It("should get latest release", func() {
// when
release, err := version.LatestRelease()
release, err := github.LatestRelease()

// then
Expect(err).ToNot(HaveOccurred())
Expand All @@ -34,11 +34,11 @@ var _ = Describe("Fetching latest release", func() {

It("should determine that v0.0.0 is not latest release", func() {
// given
latestRelease, err := version.LatestRelease()
latestRelease, err := github.LatestRelease()
Expect(err).ToNot(HaveOccurred())

// when
latest := version.IsLatestRelease(latestRelease)
latest := github.IsLatestRelease(latestRelease)

// then
Expect(latest).To(BeFalse())
Expand All @@ -47,11 +47,11 @@ var _ = Describe("Fetching latest release", func() {
It("should determine that v0.0.2 is latest release", func() {
// given
v.Version = "v0.0.2"
latestRelease, err := version.LatestRelease()
latestRelease, err := github.LatestRelease()
Expect(err).ToNot(HaveOccurred())

// when
latest := version.IsLatestRelease(latestRelease)
latest := github.IsLatestRelease(latestRelease)

// then
Expect(latest).To(BeTrue())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package version_test
package github_test

import (
"testing"
Expand Down

0 comments on commit 551590b

Please sign in to comment.