Skip to content

Commit

Permalink
Add some debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
plorenz committed Jun 11, 2024
1 parent 489d7db commit 31feb16
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"bytes"
"compress/gzip"
"encoding/json"
"errors"
"fmt"
"github.com/hashicorp/go-version"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -155,9 +156,6 @@ func (cmd *BaseCommand) EvalCurrentAndNextVersion() {
}

for _, v := range versions {
if cmd.verbose {
cmd.Infof("Comparing against: %v\n", v)
}
if min.LessThanOrEqual(v) && v.LessThan(max) {
cmd.CurrentVersion = v
}
Expand All @@ -182,10 +180,22 @@ func (cmd *BaseCommand) EvalCurrentAndNextVersion() {
if cmd.useCurrentTag {
tag := ""
if strings.EqualFold("true", os.Getenv("GITHUB_ACTIONS")) {
if cmd.verbose {
fmt.Println("running in github actions, getting tag name from environment")
}
tag = os.Getenv("GITHUB_REF_NAME")
if tag == "" {
panic(errors.New("GITHUB_REF_NAME not set"))
}
if cmd.verbose {
fmt.Printf("running in github actions, found tag: %s\n", tag)
}
} else {
tags := cmd.runCommandWithOutput("get current git tag", "git", "describe", "--tags")
tag = tags[0]
if cmd.verbose {
fmt.Printf("got tag name from git: %s\n", tag)
}
}
v, err := version.NewVersion(tag)
if err != nil {
Expand Down Expand Up @@ -297,9 +307,6 @@ func (cmd *BaseCommand) getVersionList(params ...string) []*version.Version {
}
if v.Prerelease() == "" && v.Metadata() == "" {
versions = append(versions, v)
if cmd.verbose {
cmd.Infof("found version %v\n", v)
}
}
}
sort.Sort(versionList(versions))
Expand Down

0 comments on commit 31feb16

Please sign in to comment.