Compare commits

..

No commits in common. "76e800c9d479b46f0e02a659a175e9265589ec4b" and "8ff9355fcf705af021e3a5376ccf099187afa952" have entirely different histories.

3 changed files with 10 additions and 23 deletions

View File

@ -24,7 +24,6 @@ func init() {
tagRegex *string = flag.String("tag-regex", "", "Regex pattern to look for tag in tag-file") tagRegex *string = flag.String("tag-regex", "", "Regex pattern to look for tag in tag-file")
notes *string = flag.String("notes", "", "Notes to use in release") notes *string = flag.String("notes", "", "Notes to use in release")
notesFile *string = flag.String("notes-file", "", "File to use for release notes") notesFile *string = flag.String("notes-file", "", "File to use for release notes")
logLevel *string = flag.String("log-level", "", "Level for logging")
) )
flag.Parse() flag.Parse()
@ -48,10 +47,6 @@ func init() {
if notesFile != nil && *notesFile != "" { if notesFile != nil && *notesFile != "" {
args.NotesFile = *notesFile args.NotesFile = *notesFile
} }
if logLevel != nil && *logLevel != "" {
args.Level = *logLevel
}
} }
func main() { func main() {

View File

@ -96,8 +96,6 @@ func Exec(ctx context.Context, args Args) error {
if err != nil { if err != nil {
return fmt.Errorf("error getting git tag %w", err) return fmt.Errorf("error getting git tag %w", err)
} }
log.WithField("tag", tag).Info("Fetched latest git tag")
} else if args.TagFile != "" { } else if args.TagFile != "" {
log.WithField("file", args.TagFile).Info("Reading tag from file") log.WithField("file", args.TagFile).Info("Reading tag from file")

View File

@ -9,6 +9,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"log"
"net/http" "net/http"
"os" "os"
"strings" "strings"
@ -16,7 +17,6 @@ import (
"github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing/transport/client" "github.com/go-git/go-git/v5/plumbing/transport/client"
githttp "github.com/go-git/go-git/v5/plumbing/transport/http" githttp "github.com/go-git/go-git/v5/plumbing/transport/http"
log "github.com/sirupsen/logrus"
) )
type GetLatestGitTagOption func(repo *git.Repository) error type GetLatestGitTagOption func(repo *git.Repository) error
@ -50,7 +50,7 @@ func SetBasicAuth(username, password string) func(repo *git.Repository) error {
func FetchTags() func(repo *git.Repository) error { func FetchTags() func(repo *git.Repository) error {
return func(repo *git.Repository) error { return func(repo *git.Repository) error {
log.Info("Fetching latest git tags") log.Println("Fetching latest git tags")
err := repo.Fetch(&git.FetchOptions{Tags: git.AllTags}) err := repo.Fetch(&git.FetchOptions{Tags: git.AllTags})
@ -82,25 +82,19 @@ func getLatestGitTag(options ...GetLatestGitTagOption) (tag string, err error) {
return "", fmt.Errorf("error getting git tag refs %w", err) return "", fmt.Errorf("error getting git tag refs %w", err)
} }
for { ref, err := tagRefs.Next()
r, err := tagRefs.Next()
if err == io.EOF { if err == io.EOF {
break return tag, fmt.Errorf("couldn't find any git tags %w", err)
}
if err != nil {
return "", fmt.Errorf("error iterating tags %w", err)
}
parts := strings.Split(string(r.Name()), "/")
tag = strings.Join(parts[2:], "/")
} }
if tag == "" { if err != nil {
return tag, fmt.Errorf("couldn't find any git tags") return tag, fmt.Errorf("error iterating tags %w", err)
} }
parts := strings.Split(string(ref.Name()), "/")
tag = strings.Join(parts[2:], "/")
return return
} }