Move versions/filelocker into dedicated subpackages, and consistent headers in http requests (#888)

- move filelocker logic into dedicated subpackage
- consistent useragent in requests

Reviewed-on: https://gitea.com/gitea/tea/pulls/888
Co-authored-by: techknowlogick <techknowlogick@gitea.com>
Co-committed-by: techknowlogick <techknowlogick@gitea.com>
This commit is contained in:
techknowlogick
2026-02-05 18:05:43 +00:00
committed by techknowlogick
parent 982adb4d02
commit 49a9032d8a
15 changed files with 277 additions and 127 deletions

View File

@@ -18,6 +18,7 @@ import (
"code.gitea.io/sdk/gitea"
"code.gitea.io/tea/modules/debug"
"code.gitea.io/tea/modules/httputil"
"code.gitea.io/tea/modules/theme"
"code.gitea.io/tea/modules/utils"
"github.com/charmbracelet/huh"
@@ -290,9 +291,9 @@ func doOAuthRefresh(l *Login) (*oauth2.Token, error) {
ctx := context.Background()
httpClient := &http.Client{
Transport: &http.Transport{
Transport: httputil.WrapTransport(&http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: l.Insecure},
},
}),
}
ctx = context.WithValue(ctx, oauth2.HTTPClient, httpClient)
@@ -336,7 +337,7 @@ func (l *Login) Client(options ...gitea.ClientOption) *gitea.Client {
options = append([]gitea.ClientOption{gitea.SetGiteaVersion("")}, options...)
}
options = append(options, gitea.SetToken(l.Token), gitea.SetHTTPClient(httpClient))
options = append(options, gitea.SetToken(l.Token), gitea.SetHTTPClient(httpClient), gitea.SetUserAgent(httputil.UserAgent()))
if debug.IsDebug() {
options = append(options, gitea.SetDebugMode())
}