fix(sourcehut): keep logging context local to each operation (#435)

This commit is contained in:
Danny Sauer
2026-09-09 18:34:36 +02:00
committed by GitHub
parent 97c0b60a0c
commit 109cc1eda4
2 changed files with 5 additions and 6 deletions
+4
View File
@@ -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)
}
+1 -6
View File
@@ -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, "~")