Browse Source

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
pull/36094/merge
TheFox0x7 1 day ago committed by GitHub
parent
commit
3bb0770160
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      cmd/admin_auth_ldap_test.go
  2. 14
      services/migrations/onedev.go

4
cmd/admin_auth_ldap_test.go

@ -233,7 +233,7 @@ func TestAddLdapBindDn(t *testing.T) { @@ -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) { @@ -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
},
}

14
services/migrations/onedev.go

@ -77,19 +77,19 @@ type OneDevDownloader struct { @@ -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),

Loading…
Cancel
Save