From 2a3947d7c6e23aef1d576d8598289eae144ba0b0 Mon Sep 17 00:00:00 2001 From: Simon Prochazka Date: Thu, 27 Feb 2020 15:21:31 +0100 Subject: [PATCH] chore: resolve breaking changes from upgrade git to v2 --- cmd/get_commits.go | 2 +- cmd/get_commits_test.go | 10 +++++----- cmd/log.go | 16 +++++++++++----- cmd/publish.go | 24 +++++++++++++----------- go.mod | 2 +- go.sum | 4 ++-- 6 files changed, 33 insertions(+), 25 deletions(-) diff --git a/cmd/get_commits.go b/cmd/get_commits.go index 783b376..cfe7c30 100644 --- a/cmd/get_commits.go +++ b/cmd/get_commits.go @@ -1,7 +1,7 @@ package cmd import ( - history "github.com/outillage/git/pkg" + history "github.com/outillage/git/v2" "gopkg.in/src-d/go-git.v4/plumbing" ) diff --git a/cmd/get_commits_test.go b/cmd/get_commits_test.go index bdc1483..8d41f0d 100644 --- a/cmd/get_commits_test.go +++ b/cmd/get_commits_test.go @@ -3,12 +3,12 @@ package cmd import ( "testing" - history "github.com/outillage/git/pkg" + history "github.com/outillage/git/v2" "github.com/stretchr/testify/assert" ) func TestGetCommitsDetachedTags(t *testing.T) { - repo, err := history.OpenGit("../testdata/detached_tag", false) + repo, err := history.OpenGit("../testdata/detached_tag", nil) assert.NoError(t, err) @@ -30,7 +30,7 @@ func TestGetCommitsDetachedTags(t *testing.T) { } func TestGetCommitsSingleBranch(t *testing.T) { - repo, err := history.OpenGit("../testdata/single_branch_tags", false) + repo, err := history.OpenGit("../testdata/single_branch_tags", nil) assert.NoError(t, err) @@ -52,7 +52,7 @@ func TestGetCommitsSingleBranch(t *testing.T) { } func TestGetCommitsReleaseCommit(t *testing.T) { - repo, err := history.OpenGit("../testdata/release_commit", false) + repo, err := history.OpenGit("../testdata/release_commit", nil) assert.NoError(t, err) @@ -76,7 +76,7 @@ func TestGetCommitsReleaseCommit(t *testing.T) { } func TestGetCommitsReleaseNonCompliantCommit(t *testing.T) { - repo, err := history.OpenGit("../testdata/release_noncompliant_commit", false) + repo, err := history.OpenGit("../testdata/release_noncompliant_commit", nil) assert.NoError(t, err) diff --git a/cmd/log.go b/cmd/log.go index 94c3428..480ded2 100644 --- a/cmd/log.go +++ b/cmd/log.go @@ -1,9 +1,11 @@ package cmd import ( + "io/ioutil" "log" + "os" - history "github.com/outillage/git/pkg" + history "github.com/outillage/git/v2" "github.com/outillage/quoad" "github.com/outillage/release-notary/internal/text" "github.com/spf13/cobra" @@ -18,12 +20,16 @@ var logCmd = &cobra.Command{ Short: "Prints commits between two tags", Long: "In default prints the commits between 2 tags. Can be overriden to specify exact commits.", RunE: func(cmd *cobra.Command, args []string) error { - debug := false - if cmd.Flag("verbose").Value.String() == "true" { - debug = true + debugLogger := log.Logger{} + debugLogger.SetPrefix("[DEBUG] ") + debugLogger.SetOutput(os.Stdout) + + if !Verbose { + debugLogger.SetOutput(ioutil.Discard) + debugLogger.SetPrefix("") } - repo, err := history.OpenGit(".", debug) + repo, err := history.OpenGit(".", &debugLogger) if err != nil { return err diff --git a/cmd/publish.go b/cmd/publish.go index 00652e8..916b65e 100644 --- a/cmd/publish.go +++ b/cmd/publish.go @@ -3,9 +3,12 @@ package cmd import ( "errors" "fmt" + "io/ioutil" + "log" + "os" "strings" - history "github.com/outillage/git/pkg" + history "github.com/outillage/git/v2" "github.com/outillage/quoad" "github.com/outillage/release-notary/internal/releaser" "github.com/outillage/release-notary/internal/slack" @@ -26,17 +29,16 @@ var publishCmd = &cobra.Command{ Short: "Publishes release notes", Long: "", RunE: func(cmd *cobra.Command, args []string) error { - debug := false - if cmd.Flag("verbose").Value.String() == "true" { - debug = true - } + debugLogger := log.Logger{} + debugLogger.SetPrefix("[DEBUG] ") + debugLogger.SetOutput(os.Stdout) - dryRun := false - if cmd.Flag("dry-run").Value.String() == "true" { - dryRun = true + if !Verbose { + debugLogger.SetOutput(ioutil.Discard) + debugLogger.SetPrefix("") } - repo, err := history.OpenGit(".", debug) + repo, err := history.OpenGit(".", &debugLogger) if err != nil { return err @@ -72,13 +74,13 @@ var publishCmd = &cobra.Command{ Complex: complexOutput, } - content := releaseNotes.Generate(sections, dryRun) + content := releaseNotes.Generate(sections, DryRun) if err != nil { return err } - if dryRun { + if DryRun { fmt.Println("my job here is done...") return nil } diff --git a/go.mod b/go.mod index 73104f6..1c3caf4 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.13 require ( github.com/json-iterator/go v1.1.9 - github.com/outillage/git/v2/v2 v2.0.1 + github.com/outillage/git/v2 v2.0.1 github.com/outillage/quoad v0.2.0 github.com/spf13/cobra v0.0.6 github.com/spf13/viper v1.6.2 diff --git a/go.sum b/go.sum index 8dfe793..3285ff4 100644 --- a/go.sum +++ b/go.sum @@ -97,8 +97,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLD github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/outillage/git v1.2.6 h1:mWCPxhxkuSLKd4dvnV3GXsDU2Oon10BgD6qOM+ljkZA= -github.com/outillage/git v1.2.6/go.mod h1:5gcZpe6CD8GesH9UAeYYAEPn3987FeSSeZwkxFNeePA= +github.com/outillage/git/v2 v2.0.1 h1:spc5mZmSvB05Yjz119tpiDCFMQKlglEHDcSqzBA2Log= +github.com/outillage/git/v2 v2.0.1/go.mod h1:c6L0qnmoC0TYDt9Cer+HziO77yzvrfNlPAEXBAH+HRM= github.com/outillage/quoad v0.2.0 h1:jAFYegH3ASd3YEQCVuviHMiWDFxQAOfl7ox4BSBPriY= github.com/outillage/quoad v0.2.0/go.mod h1:VdBGieQx7EtZDWn10L2fyW6ZT3uDstIhlTbPwDNL25o= github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=