Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.8.0
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.4.0
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.15
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.7.0
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.32.3
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@717e3cb29becaaf00e56953556c6d80f8a01b286
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module code.gitea.io/gitea

go 1.24.6
go 1.25.1

// rfc5280 said: "The serial number is an integer assigned by the CA to each certificate."
// But some CAs use negative serial number, just relax the check. related:
Expand Down
6 changes: 2 additions & 4 deletions modules/globallock/locker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,13 @@ func testLocker(t *testing.T, locker Locker) {
require.NoError(t, err)

wg := &sync.WaitGroup{}
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
started := time.Now()
release, err := locker.Lock(t.Context(), "test") // should be blocked for seconds
defer release()
assert.Greater(t, time.Since(started), time.Second)
assert.NoError(t, err)
}()
})

time.Sleep(2 * time.Second)
release()
Expand Down
6 changes: 2 additions & 4 deletions modules/log/event_writer_conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,9 @@ func TestConnLogger(t *testing.T) {
}
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)
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
listenReadAndClose(t, l, expected)
}()
})
logger.SendLogEvent(&event)
wg.Wait()

Expand Down
8 changes: 2 additions & 6 deletions modules/queue/workergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,7 @@ func resetIdleTicker(t *time.Ticker, dur time.Duration) {

// doStartNewWorker starts a new worker for the queue, the worker reads from worker's channel and handles the items.
func (q *WorkerPoolQueue[T]) doStartNewWorker(wp *workerGroup[T]) {
wp.wg.Add(1)

go func() {
defer wp.wg.Done()

wp.wg.Go(func() {
log.Debug("Queue %q starts new worker", q.GetName())
defer log.Debug("Queue %q stops idle worker", q.GetName())

Expand Down Expand Up @@ -192,7 +188,7 @@ func (q *WorkerPoolQueue[T]) doStartNewWorker(wp *workerGroup[T]) {
q.workerNumMu.Unlock()
}
}
}()
})
}

// doFlush flushes the queue: it tries to read all items from the queue and handles them.
Expand Down
36 changes: 24 additions & 12 deletions modules/structs/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,32 @@ package structs
import "time"

type Activity struct {
ID int64 `json:"id"`
// The unique identifier of the activity
ID int64 `json:"id"`
// The ID of the user who receives/sees this activity
UserID int64 `json:"user_id"` // Receiver user
// the type of action
//
// 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
OpType string `json:"op_type"`
ActUserID int64 `json:"act_user_id"`
ActUser *User `json:"act_user"`
RepoID int64 `json:"repo_id"`
Repo *Repository `json:"repo"`
CommentID int64 `json:"comment_id"`
Comment *Comment `json:"comment"`
RefName string `json:"ref_name"`
IsPrivate bool `json:"is_private"`
Content string `json:"content"`
Created time.Time `json:"created"`
OpType string `json:"op_type"`
// The ID of the user who performed the action
ActUserID int64 `json:"act_user_id"`
// The user who performed the action
ActUser *User `json:"act_user"`
// The ID of the repository associated with the activity
RepoID int64 `json:"repo_id"`
// The repository associated with the activity
Repo *Repository `json:"repo"`
// The ID of the comment associated with the activity (if applicable)
CommentID int64 `json:"comment_id"`
// The comment associated with the activity (if applicable)
Comment *Comment `json:"comment"`
// The name of the git reference (branch/tag) associated with the activity
RefName string `json:"ref_name"`
// Whether this activity is from a private repository
IsPrivate bool `json:"is_private"`
// Additional content or details about the activity
Content string `json:"content"`
// The date and time when the activity occurred
Created time.Time `json:"created"`
}
1 change: 1 addition & 0 deletions modules/structs/activitypub.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ package structs

// ActivityPub type
type ActivityPub struct {
// Context defines the JSON-LD context for ActivityPub
Context string `json:"@context"`
}
68 changes: 46 additions & 22 deletions modules/structs/admin_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,29 @@ import "time"

// CreateUserOption create user options
type CreateUserOption struct {
// The authentication source ID to associate with the user
SourceID int64 `json:"source_id"`
// identifier of the user, provided by the external authenticator (if configured)
// default: empty
LoginName string `json:"login_name"`
// username of the user
// required: true
Username string `json:"username" binding:"Required;Username;MaxSize(40)"`
// The full display name of the user
FullName string `json:"full_name" binding:"MaxSize(100)"`
// required: true
// swagger:strfmt email
Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
Password string `json:"password" binding:"MaxSize(255)"`
MustChangePassword *bool `json:"must_change_password"`
SendNotify bool `json:"send_notify"`
Restricted *bool `json:"restricted"`
Visibility string `json:"visibility" binding:"In(,public,limited,private)"`
Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
// The plain text password for the user
Password string `json:"password" binding:"MaxSize(255)"`
// Whether the user must change password on first login
MustChangePassword *bool `json:"must_change_password"`
// Whether to send welcome notification email to the user
SendNotify bool `json:"send_notify"`
// Whether the user has restricted access privileges
Restricted *bool `json:"restricted"`
// User visibility level: public, limited, or private
Visibility string `json:"visibility" binding:"In(,public,limited,private)"`

// For explicitly setting the user creation timestamp. Useful when users are
// migrated from other systems. When omitted, the user's creation timestamp
Expand All @@ -34,26 +41,43 @@ type CreateUserOption struct {
// EditUserOption edit user options
type EditUserOption struct {
// required: true
// The authentication source ID to associate with the user
SourceID int64 `json:"source_id"`
// identifier of the user, provided by the external authenticator (if configured)
// default: empty
// required: true
LoginName string `json:"login_name" binding:"Required"`
// swagger:strfmt email
Email *string `json:"email" binding:"MaxSize(254)"`
FullName *string `json:"full_name" binding:"MaxSize(100)"`
Password string `json:"password" binding:"MaxSize(255)"`
MustChangePassword *bool `json:"must_change_password"`
Website *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"`
Location *string `json:"location" binding:"MaxSize(50)"`
Description *string `json:"description" binding:"MaxSize(255)"`
Active *bool `json:"active"`
Admin *bool `json:"admin"`
AllowGitHook *bool `json:"allow_git_hook"`
AllowImportLocal *bool `json:"allow_import_local"`
MaxRepoCreation *int `json:"max_repo_creation"`
ProhibitLogin *bool `json:"prohibit_login"`
AllowCreateOrganization *bool `json:"allow_create_organization"`
Restricted *bool `json:"restricted"`
Visibility string `json:"visibility" binding:"In(,public,limited,private)"`
// The email address of the user
Email *string `json:"email" binding:"MaxSize(254)"`
// The full display name of the user
FullName *string `json:"full_name" binding:"MaxSize(100)"`
// The plain text password for the user
Password string `json:"password" binding:"MaxSize(255)"`
// Whether the user must change password on next login
MustChangePassword *bool `json:"must_change_password"`
// The user's personal website URL
Website *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"`
// The user's location or address
Location *string `json:"location" binding:"MaxSize(50)"`
// The user's personal description or bio
Description *string `json:"description" binding:"MaxSize(255)"`
// Whether the user account is active
Active *bool `json:"active"`
// Whether the user has administrator privileges
Admin *bool `json:"admin"`
// Whether the user can use Git hooks
AllowGitHook *bool `json:"allow_git_hook"`
// Whether the user can import local repositories
AllowImportLocal *bool `json:"allow_import_local"`
// Maximum number of repositories the user can create
MaxRepoCreation *int `json:"max_repo_creation"`
// Whether the user is prohibited from logging in
ProhibitLogin *bool `json:"prohibit_login"`
// Whether the user can create organizations
AllowCreateOrganization *bool `json:"allow_create_organization"`
// Whether the user has restricted access privileges
Restricted *bool `json:"restricted"`
// User visibility level: public, limited, or private
Visibility string `json:"visibility" binding:"In(,public,limited,private)"`
}
22 changes: 15 additions & 7 deletions modules/structs/attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,26 @@ import (
// Attachment a generic attachment
// swagger:model
type Attachment struct {
ID int64 `json:"id"`
Name string `json:"name"`
Size int64 `json:"size"`
DownloadCount int64 `json:"download_count"`
// ID is the unique identifier for the attachment
ID int64 `json:"id"`
// Name is the filename of the attachment
Name string `json:"name"`
// Size is the file size in bytes
Size int64 `json:"size"`
// DownloadCount is the number of times the attachment has been downloaded
DownloadCount int64 `json:"download_count"`
// swagger:strfmt date-time
Created time.Time `json:"created_at"`
UUID string `json:"uuid"`
DownloadURL string `json:"browser_download_url"`
// Created is the time when the attachment was uploaded
Created time.Time `json:"created_at"`
// UUID is the unique identifier for the attachment file
UUID string `json:"uuid"`
// DownloadURL is the URL to download the attachment
DownloadURL string `json:"browser_download_url"`
}

// EditAttachmentOptions options for editing attachments
// swagger:model
type EditAttachmentOptions struct {
// Name is the new filename for the attachment
Name string `json:"name"`
}
15 changes: 10 additions & 5 deletions modules/structs/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ import "time"

// Cron represents a Cron task
type Cron struct {
Name string `json:"name"`
Schedule string `json:"schedule"`
Next time.Time `json:"next"`
Prev time.Time `json:"prev"`
ExecTimes int64 `json:"exec_times"`
// The name of the cron task
Name string `json:"name"`
// The cron schedule expression (e.g., "0 0 * * *")
Schedule string `json:"schedule"`
// The next scheduled execution time
Next time.Time `json:"next"`
// The previous execution time
Prev time.Time `json:"prev"`
// The total number of times this cron task has been executed
ExecTimes int64 `json:"exec_times"`
}
19 changes: 13 additions & 6 deletions modules/structs/git_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@ package structs

// GitBlobResponse represents a git blob
type GitBlobResponse struct {
Content *string `json:"content"`
// The content of the git blob (may be base64 encoded)
Content *string `json:"content"`
// The encoding used for the content (e.g., "base64")
Encoding *string `json:"encoding"`
URL string `json:"url"`
SHA string `json:"sha"`
Size int64 `json:"size"`
// The URL to access this git blob
URL string `json:"url"`
// The SHA hash of the git blob
SHA string `json:"sha"`
// The size of the git blob in bytes
Size int64 `json:"size"`

LfsOid *string `json:"lfs_oid,omitempty"`
LfsSize *int64 `json:"lfs_size,omitempty"`
// The LFS object ID if this blob is stored in LFS
LfsOid *string `json:"lfs_oid,omitempty"`
// The size of the LFS object if this blob is stored in LFS
LfsSize *int64 `json:"lfs_size,omitempty"`
}
10 changes: 7 additions & 3 deletions modules/structs/git_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ package structs

// GitHook represents a Git repository hook
type GitHook struct {
Name string `json:"name"`
IsActive bool `json:"is_active"`
Content string `json:"content,omitempty"`
// Name is the name of the Git hook
Name string `json:"name"`
// IsActive indicates if the hook is active
IsActive bool `json:"is_active"`
// Content contains the script content of the hook
Content string `json:"content,omitempty"`
}

// GitHookList represents a list of Git hooks
type GitHookList []*GitHook

// EditGitHookOption options when modifying one Git hook
type EditGitHookOption struct {
// Content is the new script content for the hook
Content string `json:"content"`
}
Loading