Skip to content

Commit eb20142

Browse files
committed
Merge branch 'main' into add-issue-planned-time
# Conflicts: # models/migrations/migrations.go # models/migrations/v1_23/v310.go
2 parents b24c958 + 576e31a commit eb20142

File tree

262 files changed

+5959
-3856
lines changed

Some content is hidden

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

262 files changed

+5959
-3856
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,4 @@ Tim-Niclas Oelschläger <[email protected]> (@zokkis)
6363
Yu Liu <[email protected]> (@HEREYUA)
6464
Kemal Zebari <[email protected]> (@kemzeb)
6565
Rowan Bohde <[email protected]> (@bohde)
66+
hiifong <[email protected]> (@hiifong)

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,12 @@ lint-backend-fix: lint-go-fix lint-go-vet lint-editorconfig
377377
.PHONY: lint-js
378378
lint-js: node_modules
379379
npx eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES)
380-
# npx tsc
380+
# npx vue-tsc
381381

382382
.PHONY: lint-js-fix
383383
lint-js-fix: node_modules
384384
npx eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES) --fix
385-
# npx tsc
385+
# npx vue-tsc
386386

387387
.PHONY: lint-css
388388
lint-css: node_modules
@@ -451,6 +451,10 @@ lint-templates: .venv node_modules
451451
lint-yaml: .venv
452452
@poetry run yamllint .
453453

454+
.PHONY: tsc
455+
tsc:
456+
npx vue-tsc
457+
454458
.PHONY: watch
455459
watch:
456460
@bash tools/watch.sh

assets/go-licenses.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

custom/conf/app.example.ini

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,10 @@ LEVEL = Info
784784
;; Please note that setting this to false will not disable OAuth Basic or Basic authentication using a token
785785
;ENABLE_BASIC_AUTHENTICATION = true
786786
;;
787+
;; Show the password sign-in form (for password-based login), otherwise, only show OAuth2 login methods.
788+
;; If you set it to false, maybe it also needs to set ENABLE_BASIC_AUTHENTICATION to false to completely disable password-based authentication.
789+
;ENABLE_PASSWORD_SIGNIN_FORM = true
790+
;;
787791
;; More detail: https://github.com/gogits/gogs/issues/165
788792
;ENABLE_REVERSE_PROXY_AUTHENTICATION = false
789793
; Enable this to allow reverse proxy authentication for API requests, the reverse proxy is responsible for ensuring that no CSRF is possible.
@@ -1944,6 +1948,13 @@ LEVEL = Info
19441948
;; Minio secretAccessKey to connect only available when STORAGE_TYPE is `minio`
19451949
;MINIO_SECRET_ACCESS_KEY =
19461950
;;
1951+
;; Preferred IAM Endpoint to override Minio's default IAM Endpoint resolution only available when STORAGE_TYPE is `minio`.
1952+
;; If not provided and STORAGE_TYPE is `minio`, will search for and derive endpoint from known environment variables
1953+
;; (AWS_CONTAINER_AUTHORIZATION_TOKEN, AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE, AWS_CONTAINER_CREDENTIALS_RELATIVE_URI,
1954+
;; AWS_CONTAINER_CREDENTIALS_FULL_URI, AWS_WEB_IDENTITY_TOKEN_FILE, AWS_ROLE_ARN, AWS_ROLE_SESSION_NAME, AWS_REGION),
1955+
;; or the DefaultIAMRoleEndpoint if not provided otherwise.
1956+
;MINIO_IAM_ENDPOINT =
1957+
;;
19471958
;; Minio bucket to store the attachments only available when STORAGE_TYPE is `minio`
19481959
;MINIO_BUCKET = gitea
19491960
;;
@@ -2688,6 +2699,13 @@ LEVEL = Info
26882699
;; Minio secretAccessKey to connect only available when STORAGE_TYPE is `minio`
26892700
;MINIO_SECRET_ACCESS_KEY =
26902701
;;
2702+
;; Preferred IAM Endpoint to override Minio's default IAM Endpoint resolution only available when STORAGE_TYPE is `minio`.
2703+
;; If not provided and STORAGE_TYPE is `minio`, will search for and derive endpoint from known environment variables
2704+
;; (AWS_CONTAINER_AUTHORIZATION_TOKEN, AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE, AWS_CONTAINER_CREDENTIALS_RELATIVE_URI,
2705+
;; AWS_CONTAINER_CREDENTIALS_FULL_URI, AWS_WEB_IDENTITY_TOKEN_FILE, AWS_ROLE_ARN, AWS_ROLE_SESSION_NAME, AWS_REGION),
2706+
;; or the DefaultIAMRoleEndpoint if not provided otherwise.
2707+
;MINIO_IAM_ENDPOINT =
2708+
;;
26912709
;; Minio bucket to store the attachments only available when STORAGE_TYPE is `minio`
26922710
;MINIO_BUCKET = gitea
26932711
;;

models/activities/action.go

Lines changed: 7 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func (a *Action) LoadActUser(ctx context.Context) {
200200
}
201201
}
202202

203-
func (a *Action) loadRepo(ctx context.Context) {
203+
func (a *Action) LoadRepo(ctx context.Context) {
204204
if a.Repo != nil {
205205
return
206206
}
@@ -250,7 +250,7 @@ func (a *Action) GetActDisplayNameTitle(ctx context.Context) string {
250250

251251
// GetRepoUserName returns the name of the action repository owner.
252252
func (a *Action) GetRepoUserName(ctx context.Context) string {
253-
a.loadRepo(ctx)
253+
a.LoadRepo(ctx)
254254
if a.Repo == nil {
255255
return "(non-existing-repo)"
256256
}
@@ -265,7 +265,7 @@ func (a *Action) ShortRepoUserName(ctx context.Context) string {
265265

266266
// GetRepoName returns the name of the action repository.
267267
func (a *Action) GetRepoName(ctx context.Context) string {
268-
a.loadRepo(ctx)
268+
a.LoadRepo(ctx)
269269
if a.Repo == nil {
270270
return "(non-existing-repo)"
271271
}
@@ -448,65 +448,13 @@ type GetFeedsOptions struct {
448448
Date string // the day we want activity for: YYYY-MM-DD
449449
}
450450

451-
// GetFeeds returns actions according to the provided options
452-
func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, error) {
453-
if opts.RequestedUser == nil && opts.RequestedTeam == nil && opts.RequestedRepo == nil {
454-
return nil, 0, fmt.Errorf("need at least one of these filters: RequestedUser, RequestedTeam, RequestedRepo")
455-
}
456-
457-
cond, err := activityQueryCondition(ctx, opts)
458-
if err != nil {
459-
return nil, 0, err
460-
}
461-
462-
actions := make([]*Action, 0, opts.PageSize)
463-
var count int64
464-
opts.SetDefaultValues()
465-
466-
if opts.Page < 10 { // TODO: why it's 10 but other values? It's an experience value.
467-
sess := db.GetEngine(ctx).Where(cond)
468-
sess = db.SetSessionPagination(sess, &opts)
469-
470-
count, err = sess.Desc("`action`.created_unix").FindAndCount(&actions)
471-
if err != nil {
472-
return nil, 0, fmt.Errorf("FindAndCount: %w", err)
473-
}
474-
} else {
475-
// First, only query which IDs are necessary, and only then query all actions to speed up the overall query
476-
sess := db.GetEngine(ctx).Where(cond).Select("`action`.id")
477-
sess = db.SetSessionPagination(sess, &opts)
478-
479-
actionIDs := make([]int64, 0, opts.PageSize)
480-
if err := sess.Table("action").Desc("`action`.created_unix").Find(&actionIDs); err != nil {
481-
return nil, 0, fmt.Errorf("Find(actionsIDs): %w", err)
482-
}
483-
484-
count, err = db.GetEngine(ctx).Where(cond).
485-
Table("action").
486-
Cols("`action`.id").Count()
487-
if err != nil {
488-
return nil, 0, fmt.Errorf("Count: %w", err)
489-
}
490-
491-
if err := db.GetEngine(ctx).In("`action`.id", actionIDs).Desc("`action`.created_unix").Find(&actions); err != nil {
492-
return nil, 0, fmt.Errorf("Find: %w", err)
493-
}
494-
}
495-
496-
if err := ActionList(actions).LoadAttributes(ctx); err != nil {
497-
return nil, 0, fmt.Errorf("LoadAttributes: %w", err)
498-
}
499-
500-
return actions, count, nil
501-
}
502-
503451
// ActivityReadable return whether doer can read activities of user
504452
func ActivityReadable(user, doer *user_model.User) bool {
505453
return !user.KeepActivityPrivate ||
506454
doer != nil && (doer.IsAdmin || user.ID == doer.ID)
507455
}
508456

509-
func activityQueryCondition(ctx context.Context, opts GetFeedsOptions) (builder.Cond, error) {
457+
func ActivityQueryCondition(ctx context.Context, opts GetFeedsOptions) (builder.Cond, error) {
510458
cond := builder.NewCond()
511459

512460
if opts.RequestedTeam != nil && opts.RequestedUser == nil {
@@ -644,7 +592,7 @@ func NotifyWatchers(ctx context.Context, actions ...*Action) error {
644592
}
645593

646594
if repoChanged {
647-
act.loadRepo(ctx)
595+
act.LoadRepo(ctx)
648596
repo = act.Repo
649597

650598
// check repo owner exist.
@@ -770,15 +718,15 @@ func DeleteIssueActions(ctx context.Context, repoID, issueID, issueIndex int64)
770718
// CountActionCreatedUnixString count actions where created_unix is an empty string
771719
func CountActionCreatedUnixString(ctx context.Context) (int64, error) {
772720
if setting.Database.Type.IsSQLite3() {
773-
return db.GetEngine(ctx).Where(`created_unix = ""`).Count(new(Action))
721+
return db.GetEngine(ctx).Where(`created_unix = ''`).Count(new(Action))
774722
}
775723
return 0, nil
776724
}
777725

778726
// FixActionCreatedUnixString set created_unix to zero if it is an empty string
779727
func FixActionCreatedUnixString(ctx context.Context) (int64, error) {
780728
if setting.Database.Type.IsSQLite3() {
781-
res, err := db.GetEngine(ctx).Exec(`UPDATE action SET created_unix = 0 WHERE created_unix = ""`)
729+
res, err := db.GetEngine(ctx).Exec(`UPDATE action SET created_unix = 0 WHERE created_unix = ''`)
782730
if err != nil {
783731
return 0, err
784732
}

models/activities/action_list.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,55 @@ func (actions ActionList) LoadIssues(ctx context.Context) error {
201201
}
202202
return nil
203203
}
204+
205+
// GetFeeds returns actions according to the provided options
206+
func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, error) {
207+
if opts.RequestedUser == nil && opts.RequestedTeam == nil && opts.RequestedRepo == nil {
208+
return nil, 0, fmt.Errorf("need at least one of these filters: RequestedUser, RequestedTeam, RequestedRepo")
209+
}
210+
211+
cond, err := ActivityQueryCondition(ctx, opts)
212+
if err != nil {
213+
return nil, 0, err
214+
}
215+
216+
actions := make([]*Action, 0, opts.PageSize)
217+
var count int64
218+
opts.SetDefaultValues()
219+
220+
if opts.Page < 10 { // TODO: why it's 10 but other values? It's an experience value.
221+
sess := db.GetEngine(ctx).Where(cond)
222+
sess = db.SetSessionPagination(sess, &opts)
223+
224+
count, err = sess.Desc("`action`.created_unix").FindAndCount(&actions)
225+
if err != nil {
226+
return nil, 0, fmt.Errorf("FindAndCount: %w", err)
227+
}
228+
} else {
229+
// First, only query which IDs are necessary, and only then query all actions to speed up the overall query
230+
sess := db.GetEngine(ctx).Where(cond).Select("`action`.id")
231+
sess = db.SetSessionPagination(sess, &opts)
232+
233+
actionIDs := make([]int64, 0, opts.PageSize)
234+
if err := sess.Table("action").Desc("`action`.created_unix").Find(&actionIDs); err != nil {
235+
return nil, 0, fmt.Errorf("Find(actionsIDs): %w", err)
236+
}
237+
238+
count, err = db.GetEngine(ctx).Where(cond).
239+
Table("action").
240+
Cols("`action`.id").Count()
241+
if err != nil {
242+
return nil, 0, fmt.Errorf("Count: %w", err)
243+
}
244+
245+
if err := db.GetEngine(ctx).In("`action`.id", actionIDs).Desc("`action`.created_unix").Find(&actions); err != nil {
246+
return nil, 0, fmt.Errorf("Find: %w", err)
247+
}
248+
}
249+
250+
if err := ActionList(actions).LoadAttributes(ctx); err != nil {
251+
return nil, 0, fmt.Errorf("LoadAttributes: %w", err)
252+
}
253+
254+
return actions, count, nil
255+
}

0 commit comments

Comments
 (0)