Skip to content

Commit c290682

Browse files
authored
Upgrade golang to 1.25.1 and add descriptions for the swagger structs' fields (go-gitea#35418)
1 parent b8f1c9f commit c290682

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1929
-657
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ GOFUMPT_PACKAGE ?= mvdan.cc/[email protected]
3131
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/[email protected]
3232
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected]
3333
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/[email protected]
34-
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.32.3
34+
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@717e3cb29becaaf00e56953556c6d80f8a01b286
3535
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
3636
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1
3737
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module code.gitea.io/gitea
22

3-
go 1.24.6
3+
go 1.25.1
44

55
// rfc5280 said: "The serial number is an integer assigned by the CA to each certificate."
66
// But some CAs use negative serial number, just relax the check. related:

modules/globallock/locker_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,13 @@ func testLocker(t *testing.T, locker Locker) {
105105
require.NoError(t, err)
106106

107107
wg := &sync.WaitGroup{}
108-
wg.Add(1)
109-
go func() {
110-
defer wg.Done()
108+
wg.Go(func() {
111109
started := time.Now()
112110
release, err := locker.Lock(t.Context(), "test") // should be blocked for seconds
113111
defer release()
114112
assert.Greater(t, time.Since(started), time.Second)
115113
assert.NoError(t, err)
116-
}()
114+
})
117115

118116
time.Sleep(2 * time.Second)
119117
release()

modules/log/event_writer_conn_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,9 @@ func TestConnLogger(t *testing.T) {
6262
}
6363
expected := fmt.Sprintf("%s%s %s:%d:%s [%c] %s\n", prefix, dateString, event.Filename, event.Line, event.Caller, strings.ToUpper(event.Level.String())[0], event.MsgSimpleText)
6464
var wg sync.WaitGroup
65-
wg.Add(1)
66-
go func() {
67-
defer wg.Done()
65+
wg.Go(func() {
6866
listenReadAndClose(t, l, expected)
69-
}()
67+
})
7068
logger.SendLogEvent(&event)
7169
wg.Wait()
7270

modules/queue/workergroup.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,7 @@ func resetIdleTicker(t *time.Ticker, dur time.Duration) {
153153

154154
// doStartNewWorker starts a new worker for the queue, the worker reads from worker's channel and handles the items.
155155
func (q *WorkerPoolQueue[T]) doStartNewWorker(wp *workerGroup[T]) {
156-
wp.wg.Add(1)
157-
158-
go func() {
159-
defer wp.wg.Done()
160-
156+
wp.wg.Go(func() {
161157
log.Debug("Queue %q starts new worker", q.GetName())
162158
defer log.Debug("Queue %q stops idle worker", q.GetName())
163159

@@ -192,7 +188,7 @@ func (q *WorkerPoolQueue[T]) doStartNewWorker(wp *workerGroup[T]) {
192188
q.workerNumMu.Unlock()
193189
}
194190
}
195-
}()
191+
})
196192
}
197193

198194
// doFlush flushes the queue: it tries to read all items from the queue and handles them.

modules/structs/activity.go

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,32 @@ package structs
66
import "time"
77

88
type Activity struct {
9-
ID int64 `json:"id"`
9+
// The unique identifier of the activity
10+
ID int64 `json:"id"`
11+
// The ID of the user who receives/sees this activity
1012
UserID int64 `json:"user_id"` // Receiver user
1113
// the type of action
1214
//
1315
// enum: create_repo,rename_repo,star_repo,watch_repo,commit_repo,create_issue,create_pull_request,transfer_repo,push_tag,comment_issue,merge_pull_request,close_issue,reopen_issue,close_pull_request,reopen_pull_request,delete_tag,delete_branch,mirror_sync_push,mirror_sync_create,mirror_sync_delete,approve_pull_request,reject_pull_request,comment_pull,publish_release,pull_review_dismissed,pull_request_ready_for_review,auto_merge_pull_request
14-
OpType string `json:"op_type"`
15-
ActUserID int64 `json:"act_user_id"`
16-
ActUser *User `json:"act_user"`
17-
RepoID int64 `json:"repo_id"`
18-
Repo *Repository `json:"repo"`
19-
CommentID int64 `json:"comment_id"`
20-
Comment *Comment `json:"comment"`
21-
RefName string `json:"ref_name"`
22-
IsPrivate bool `json:"is_private"`
23-
Content string `json:"content"`
24-
Created time.Time `json:"created"`
16+
OpType string `json:"op_type"`
17+
// The ID of the user who performed the action
18+
ActUserID int64 `json:"act_user_id"`
19+
// The user who performed the action
20+
ActUser *User `json:"act_user"`
21+
// The ID of the repository associated with the activity
22+
RepoID int64 `json:"repo_id"`
23+
// The repository associated with the activity
24+
Repo *Repository `json:"repo"`
25+
// The ID of the comment associated with the activity (if applicable)
26+
CommentID int64 `json:"comment_id"`
27+
// The comment associated with the activity (if applicable)
28+
Comment *Comment `json:"comment"`
29+
// The name of the git reference (branch/tag) associated with the activity
30+
RefName string `json:"ref_name"`
31+
// Whether this activity is from a private repository
32+
IsPrivate bool `json:"is_private"`
33+
// Additional content or details about the activity
34+
Content string `json:"content"`
35+
// The date and time when the activity occurred
36+
Created time.Time `json:"created"`
2537
}

modules/structs/activitypub.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ package structs
55

66
// ActivityPub type
77
type ActivityPub struct {
8+
// Context defines the JSON-LD context for ActivityPub
89
Context string `json:"@context"`
910
}

modules/structs/admin_user.go

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,29 @@ import "time"
88

99
// CreateUserOption create user options
1010
type CreateUserOption struct {
11+
// The authentication source ID to associate with the user
1112
SourceID int64 `json:"source_id"`
1213
// identifier of the user, provided by the external authenticator (if configured)
1314
// default: empty
1415
LoginName string `json:"login_name"`
1516
// username of the user
1617
// required: true
1718
Username string `json:"username" binding:"Required;Username;MaxSize(40)"`
19+
// The full display name of the user
1820
FullName string `json:"full_name" binding:"MaxSize(100)"`
1921
// required: true
2022
// swagger:strfmt email
21-
Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
22-
Password string `json:"password" binding:"MaxSize(255)"`
23-
MustChangePassword *bool `json:"must_change_password"`
24-
SendNotify bool `json:"send_notify"`
25-
Restricted *bool `json:"restricted"`
26-
Visibility string `json:"visibility" binding:"In(,public,limited,private)"`
23+
Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
24+
// The plain text password for the user
25+
Password string `json:"password" binding:"MaxSize(255)"`
26+
// Whether the user must change password on first login
27+
MustChangePassword *bool `json:"must_change_password"`
28+
// Whether to send welcome notification email to the user
29+
SendNotify bool `json:"send_notify"`
30+
// Whether the user has restricted access privileges
31+
Restricted *bool `json:"restricted"`
32+
// User visibility level: public, limited, or private
33+
Visibility string `json:"visibility" binding:"In(,public,limited,private)"`
2734

2835
// For explicitly setting the user creation timestamp. Useful when users are
2936
// migrated from other systems. When omitted, the user's creation timestamp
@@ -34,26 +41,43 @@ type CreateUserOption struct {
3441
// EditUserOption edit user options
3542
type EditUserOption struct {
3643
// required: true
44+
// The authentication source ID to associate with the user
3745
SourceID int64 `json:"source_id"`
3846
// identifier of the user, provided by the external authenticator (if configured)
3947
// default: empty
4048
// required: true
4149
LoginName string `json:"login_name" binding:"Required"`
4250
// swagger:strfmt email
43-
Email *string `json:"email" binding:"MaxSize(254)"`
44-
FullName *string `json:"full_name" binding:"MaxSize(100)"`
45-
Password string `json:"password" binding:"MaxSize(255)"`
46-
MustChangePassword *bool `json:"must_change_password"`
47-
Website *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"`
48-
Location *string `json:"location" binding:"MaxSize(50)"`
49-
Description *string `json:"description" binding:"MaxSize(255)"`
50-
Active *bool `json:"active"`
51-
Admin *bool `json:"admin"`
52-
AllowGitHook *bool `json:"allow_git_hook"`
53-
AllowImportLocal *bool `json:"allow_import_local"`
54-
MaxRepoCreation *int `json:"max_repo_creation"`
55-
ProhibitLogin *bool `json:"prohibit_login"`
56-
AllowCreateOrganization *bool `json:"allow_create_organization"`
57-
Restricted *bool `json:"restricted"`
58-
Visibility string `json:"visibility" binding:"In(,public,limited,private)"`
51+
// The email address of the user
52+
Email *string `json:"email" binding:"MaxSize(254)"`
53+
// The full display name of the user
54+
FullName *string `json:"full_name" binding:"MaxSize(100)"`
55+
// The plain text password for the user
56+
Password string `json:"password" binding:"MaxSize(255)"`
57+
// Whether the user must change password on next login
58+
MustChangePassword *bool `json:"must_change_password"`
59+
// The user's personal website URL
60+
Website *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"`
61+
// The user's location or address
62+
Location *string `json:"location" binding:"MaxSize(50)"`
63+
// The user's personal description or bio
64+
Description *string `json:"description" binding:"MaxSize(255)"`
65+
// Whether the user account is active
66+
Active *bool `json:"active"`
67+
// Whether the user has administrator privileges
68+
Admin *bool `json:"admin"`
69+
// Whether the user can use Git hooks
70+
AllowGitHook *bool `json:"allow_git_hook"`
71+
// Whether the user can import local repositories
72+
AllowImportLocal *bool `json:"allow_import_local"`
73+
// Maximum number of repositories the user can create
74+
MaxRepoCreation *int `json:"max_repo_creation"`
75+
// Whether the user is prohibited from logging in
76+
ProhibitLogin *bool `json:"prohibit_login"`
77+
// Whether the user can create organizations
78+
AllowCreateOrganization *bool `json:"allow_create_organization"`
79+
// Whether the user has restricted access privileges
80+
Restricted *bool `json:"restricted"`
81+
// User visibility level: public, limited, or private
82+
Visibility string `json:"visibility" binding:"In(,public,limited,private)"`
5983
}

modules/structs/attachment.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,26 @@ import (
1010
// Attachment a generic attachment
1111
// swagger:model
1212
type Attachment struct {
13-
ID int64 `json:"id"`
14-
Name string `json:"name"`
15-
Size int64 `json:"size"`
16-
DownloadCount int64 `json:"download_count"`
13+
// ID is the unique identifier for the attachment
14+
ID int64 `json:"id"`
15+
// Name is the filename of the attachment
16+
Name string `json:"name"`
17+
// Size is the file size in bytes
18+
Size int64 `json:"size"`
19+
// DownloadCount is the number of times the attachment has been downloaded
20+
DownloadCount int64 `json:"download_count"`
1721
// swagger:strfmt date-time
18-
Created time.Time `json:"created_at"`
19-
UUID string `json:"uuid"`
20-
DownloadURL string `json:"browser_download_url"`
22+
// Created is the time when the attachment was uploaded
23+
Created time.Time `json:"created_at"`
24+
// UUID is the unique identifier for the attachment file
25+
UUID string `json:"uuid"`
26+
// DownloadURL is the URL to download the attachment
27+
DownloadURL string `json:"browser_download_url"`
2128
}
2229

2330
// EditAttachmentOptions options for editing attachments
2431
// swagger:model
2532
type EditAttachmentOptions struct {
33+
// Name is the new filename for the attachment
2634
Name string `json:"name"`
2735
}

modules/structs/cron.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ import "time"
77

88
// Cron represents a Cron task
99
type Cron struct {
10-
Name string `json:"name"`
11-
Schedule string `json:"schedule"`
12-
Next time.Time `json:"next"`
13-
Prev time.Time `json:"prev"`
14-
ExecTimes int64 `json:"exec_times"`
10+
// The name of the cron task
11+
Name string `json:"name"`
12+
// The cron schedule expression (e.g., "0 0 * * *")
13+
Schedule string `json:"schedule"`
14+
// The next scheduled execution time
15+
Next time.Time `json:"next"`
16+
// The previous execution time
17+
Prev time.Time `json:"prev"`
18+
// The total number of times this cron task has been executed
19+
ExecTimes int64 `json:"exec_times"`
1520
}

0 commit comments

Comments
 (0)