From 3bb077016004a008e237000e5ca30b27a633ac76 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Tue, 16 Dec 2025 03:16:58 +0100 Subject: [PATCH] fix nilnil in onedev downloader (#36154) onedev migration never used the migration transport, it now uses it the same way gogs one does --- cuts 3 nilnils for https://github.com/go-gitea/gitea/issues/36152 --- cmd/admin_auth_ldap_test.go | 4 ++-- services/migrations/onedev.go | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/admin_auth_ldap_test.go b/cmd/admin_auth_ldap_test.go index 2da7ebc573..0e3e465e81 100644 --- a/cmd/admin_auth_ldap_test.go +++ b/cmd/admin_auth_ldap_test.go @@ -233,7 +233,7 @@ func TestAddLdapBindDn(t *testing.T) { }, getAuthSourceByID: func(ctx context.Context, id int64) (*auth.Source, error) { assert.FailNow(t, "getAuthSourceByID called", "case %d: should not call getAuthSourceByID", n) - return nil, nil + return nil, nil //nolint:nilnil // mock function covering improper behavior }, } @@ -463,7 +463,7 @@ func TestAddLdapSimpleAuth(t *testing.T) { }, getAuthSourceByID: func(ctx context.Context, id int64) (*auth.Source, error) { assert.FailNow(t, "getAuthSourceById called", "case %d: should not call getAuthSourceByID", n) - return nil, nil + return nil, nil //nolint:nilnil // mock function covering improper behavior }, } diff --git a/services/migrations/onedev.go b/services/migrations/onedev.go index 9917bdae3c..a30e36c8b8 100644 --- a/services/migrations/onedev.go +++ b/services/migrations/onedev.go @@ -77,19 +77,19 @@ type OneDevDownloader struct { } // NewOneDevDownloader creates a new downloader -func NewOneDevDownloader(_ context.Context, baseURL *url.URL, username, password, repoPath string) *OneDevDownloader { +func NewOneDevDownloader(ctx context.Context, baseURL *url.URL, username, password, repoPath string) *OneDevDownloader { + httpTransport := NewMigrationHTTPTransport() downloader := &OneDevDownloader{ baseURL: baseURL, repoPath: repoPath, client: &http.Client{ - Transport: &http.Transport{ - Proxy: func(req *http.Request) (*url.URL, error) { - if len(username) > 0 && len(password) > 0 { + Transport: roundTripperFunc( + func(req *http.Request) (*http.Response, error) { + if username != "" && password != "" { req.SetBasicAuth(username, password) } - return nil, nil - }, - }, + return httpTransport.RoundTrip(req.WithContext(ctx)) + }), }, userMap: make(map[int64]*onedevUser), milestoneMap: make(map[int64]string),