Compare commits

..

No commits in common. "913e80c62b317e89065d8daa36d2b0b934f829e7" and "30fafd87cd4ccd434b06513708281e78de2ec73c" have entirely different histories.

3 changed files with 11 additions and 26 deletions

20
main.go
View File

@ -6,7 +6,7 @@ import (
"gitea.dikurium.ch/InnoPeak/drone-gitea-release/plugin" "gitea.dikurium.ch/InnoPeak/drone-gitea-release/plugin"
"github.com/kelseyhightower/envconfig" "github.com/kelseyhightower/envconfig"
log "github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
flag "github.com/spf13/pflag" flag "github.com/spf13/pflag"
) )
@ -15,7 +15,7 @@ var args plugin.Args
func init() { func init() {
if err := envconfig.Process("", &args); err != nil { if err := envconfig.Process("", &args); err != nil {
log.Fatalln(err) logrus.Fatalln(err)
} }
var ( var (
@ -50,19 +50,19 @@ func init() {
} }
func main() { func main() {
log.SetFormatter(new(formatter)) logrus.SetFormatter(new(formatter))
switch args.Level { switch args.Level {
case "debug": case "debug":
log.SetFormatter(textFormatter) logrus.SetFormatter(textFormatter)
log.SetLevel(log.DebugLevel) logrus.SetLevel(logrus.DebugLevel)
case "trace": case "trace":
log.SetFormatter(textFormatter) logrus.SetFormatter(textFormatter)
log.SetLevel(log.TraceLevel) logrus.SetLevel(logrus.TraceLevel)
} }
if err := plugin.Exec(context.Background(), args); err != nil { if err := plugin.Exec(context.Background(), args); err != nil {
log.Fatalln(err) logrus.Fatalln(err)
} }
} }
@ -70,11 +70,11 @@ func main() {
// or level information. // or level information.
type formatter struct{} type formatter struct{}
func (*formatter) Format(entry *log.Entry) ([]byte, error) { func (*formatter) Format(entry *logrus.Entry) ([]byte, error) {
return []byte(entry.Message), nil return []byte(entry.Message), nil
} }
// text formatter that writes logs with level information // text formatter that writes logs with level information
var textFormatter = &log.TextFormatter{ var textFormatter = &logrus.TextFormatter{
DisableTimestamp: true, DisableTimestamp: true,
} }

View File

@ -9,7 +9,6 @@ import (
"text/template" "text/template"
"code.gitea.io/sdk/gitea" "code.gitea.io/sdk/gitea"
log "github.com/sirupsen/logrus"
) )
var ( var (
@ -72,7 +71,7 @@ func Exec(ctx context.Context, args Args) error {
if err != nil { if err != nil {
if os.IsNotExist(err) && args.SkipIfNoNotesFile { if os.IsNotExist(err) && args.SkipIfNoNotesFile {
log.Info("No notes file found, skipping release") fmt.Println("No notes file found, skipping release")
return nil return nil
} }
return fmt.Errorf("error reading notes file %w", err) return fmt.Errorf("error reading notes file %w", err)
@ -97,8 +96,6 @@ func Exec(ctx context.Context, args Args) error {
return fmt.Errorf("error getting git tag %w", err) return fmt.Errorf("error getting git tag %w", err)
} }
} else if args.TagFile != "" { } else if args.TagFile != "" {
log.WithField("file", args.TagFile).Info("Reading tag from file")
var pattern = defaultTagRegex var pattern = defaultTagRegex
if args.TagRegex != "" { if args.TagRegex != "" {
pattern = regexp.MustCompile(args.TagRegex) pattern = regexp.MustCompile(args.TagRegex)
@ -121,8 +118,6 @@ func Exec(ctx context.Context, args Args) error {
tag = matches[i] tag = matches[i]
} }
} }
log.WithField("tag", tag).Info("Found tag")
} else { } else {
return fmt.Errorf("latest git tag or tag file must be given") return fmt.Errorf("latest git tag or tag file must be given")
} }
@ -147,11 +142,6 @@ func Exec(ctx context.Context, args Args) error {
title = titleBuffer.String() title = titleBuffer.String()
log.WithFields(log.Fields{
"template": titleTmpl.DefinedTemplates(),
"title": title,
}).Info("Generated title with template")
client, err := gitea.NewClient(args.GiteaUrl, gitea.SetBasicAuth(args.GiteaUsername, args.GiteaPassword)) client, err := gitea.NewClient(args.GiteaUrl, gitea.SetBasicAuth(args.GiteaUsername, args.GiteaPassword))
if err != nil { if err != nil {

View File

@ -9,7 +9,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"log"
"net/http" "net/http"
"os" "os"
"strings" "strings"
@ -35,8 +34,6 @@ func (bat BasicAuthTransport) RoundTrip(req *http.Request) (resp *http.Response,
func SetBasicAuth(username, password string) func(repo *git.Repository) error { func SetBasicAuth(username, password string) func(repo *git.Repository) error {
return func(repo *git.Repository) error { return func(repo *git.Repository) error {
log.Println("Configuring basic auth for https")
customClient := &http.Client{ customClient := &http.Client{
Transport: BasicAuthTransport{username, password, http.DefaultTransport}, Transport: BasicAuthTransport{username, password, http.DefaultTransport},
} }
@ -50,8 +47,6 @@ 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.Println("Fetching latest git tags")
err := repo.Fetch(&git.FetchOptions{Tags: git.AllTags}) err := repo.Fetch(&git.FetchOptions{Tags: git.AllTags})
if err == git.NoErrAlreadyUpToDate { if err == git.NoErrAlreadyUpToDate {