mirror of
https://github.com/cooperspencer/gickup.git
synced 2026-10-19 16:16:46 +00:00
fix(sourcehut): keep logging context local to each operation (#435)
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
)
|
||||
|
||||
func TestGetRepoVisibility(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
configured string
|
||||
@@ -23,6 +25,8 @@ func TestGetRepoVisibility(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if got := getRepoVisibility(test.configured, test.sourcePrivate); got != test.want {
|
||||
t.Fatalf("getRepoVisibility(%q, %t) = %q, want %q", test.configured, test.sourcePrivate, got, test.want)
|
||||
}
|
||||
|
||||
@@ -13,11 +13,8 @@ import (
|
||||
"github.com/cooperspencer/gickup/logger"
|
||||
"github.com/cooperspencer/gickup/types"
|
||||
graphqlclient "github.com/hasura/go-graphql-client"
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
var sub zerolog.Logger
|
||||
|
||||
const defaultSourcehutURL = "https://git.sr.ht"
|
||||
|
||||
func normalizeBearerToken(token string) string {
|
||||
@@ -250,7 +247,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
for _, repo := range conf.Source.Sourcehut {
|
||||
repo.URL = normalizeURL(repo.URL)
|
||||
|
||||
sub = logger.CreateSubLogger("stage", "sourcehut", "url", repo.URL)
|
||||
sub := logger.CreateSubLogger("stage", "sourcehut", "url", repo.URL)
|
||||
err := repo.Filter.ParseDuration()
|
||||
if err != nil {
|
||||
sub.Warn().
|
||||
@@ -374,8 +371,6 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
func GetOrCreate(destination types.GenRepo, repo types.Repo) (string, error) {
|
||||
destination.URL = normalizeURL(destination.URL)
|
||||
|
||||
sub = logger.CreateSubLogger("stage", "sourcehut", "url", destination.URL)
|
||||
|
||||
token := destination.GetToken()
|
||||
endpoint := graphQLEndpoint(destination.URL)
|
||||
configuredUser := strings.TrimPrefix(destination.User, "~")
|
||||
|
||||
Reference in New Issue
Block a user