Skip to content

Commit 6830964

Browse files
committed
Merge branch 'main' into lunny/lock_package_upload
2 parents 9241bef + 2da2000 commit 6830964

File tree

93 files changed

+1035
-1198
lines changed

Some content is hidden

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

93 files changed

+1035
-1198
lines changed

.github/ISSUE_TEMPLATE/bug-report.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ body:
1111
value: |
1212
1. Please speak English, this is the language all maintainers can speak and write.
1313
2. Please ask questions or configuration/deploy problems on our Discord
14-
server (https://discord.gg/gitea) or forum (https://discourse.gitea.io).
14+
server (https://discord.gg/gitea) or forum (https://forum.gitea.com).
1515
3. Make sure you are using the latest release and
1616
take a moment to check that your issue hasn't been reported before.
1717
4. Make sure it's not mentioned in the FAQ (https://docs.gitea.com/help/faq)

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ contact_links:
77
url: https://discord.gg/Gitea
88
about: Please ask questions and discuss configuration or deployment problems here.
99
- name: Discourse Forum
10-
url: https://discourse.gitea.io
10+
url: https://forum.gitea.com
1111
about: Questions and configuration or deployment problems can also be discussed on our forum.
1212
- name: Frequently Asked Questions
1313
url: https://docs.gitea.com/help/faq

.github/ISSUE_TEMPLATE/feature-request.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ body:
77
value: |
88
1. Please speak English, this is the language all maintainers can speak and write.
99
2. Please ask questions or configuration/deploy problems on our Discord
10-
server (https://discord.gg/gitea) or forum (https://discourse.gitea.io).
10+
server (https://discord.gg/gitea) or forum (https://forum.gitea.com).
1111
3. Please take a moment to check that your feature hasn't already been suggested.
1212
- type: textarea
1313
id: description

.github/ISSUE_TEMPLATE/ui.bug-report.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ body:
1111
value: |
1212
1. Please speak English, this is the language all maintainers can speak and write.
1313
2. Please ask questions or configuration/deploy problems on our Discord
14-
server (https://discord.gg/gitea) or forum (https://discourse.gitea.io).
14+
server (https://discord.gg/gitea) or forum (https://forum.gitea.com).
1515
3. Please take a moment to check that your issue doesn't already exist.
1616
4. Make sure it's not mentioned in the FAQ (https://docs.gitea.com/help/faq)
1717
5. Please give all relevant information below for bug reports, because

assets/go-licenses.json

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

cmd/hook.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,22 @@ Gitea or set your environment appropriately.`, "")
290290
return nil
291291
}
292292

293+
// runHookUpdate avoid to do heavy operations on update hook because it will be
294+
// invoked for every ref update which does not like pre-receive and post-receive
293295
func runHookUpdate(c *cli.Context) error {
296+
if isInternal, _ := strconv.ParseBool(os.Getenv(repo_module.EnvIsInternal)); isInternal {
297+
return nil
298+
}
299+
294300
// Update is empty and is kept only for backwards compatibility
301+
if len(os.Args) < 3 {
302+
return nil
303+
}
304+
refName := git.RefName(os.Args[len(os.Args)-3])
305+
if refName.IsPull() {
306+
// ignore update to refs/pull/xxx/head, so we don't need to output any information
307+
os.Exit(1)
308+
}
295309
return nil
296310
}
297311

custom/conf/app.example.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2713,3 +2713,9 @@ LEVEL = Info
27132713
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27142714
;; storage type
27152715
;STORAGE_TYPE = local
2716+
2717+
;[global_lock]
2718+
;; Lock service type, could be memory or redis
2719+
;SERVICE_TYPE = memory
2720+
;; Ignored for the "memory" type. For "redis" use something like `redis://127.0.0.1:6379/0`
2721+
;SERVICE_CONN_STR =

models/activities/action.go

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -450,17 +450,46 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, err
450450
return nil, 0, err
451451
}
452452

453-
sess := db.GetEngine(ctx).Where(cond).
454-
Select("`action`.*"). // this line will avoid select other joined table's columns
455-
Join("INNER", "repository", "`repository`.id = `action`.repo_id")
453+
actions := make([]*Action, 0, opts.PageSize)
454+
var count int64
456455

457-
opts.SetDefaultValues()
458-
sess = db.SetSessionPagination(sess, &opts)
456+
if opts.Page < 10 { // TODO: why it's 10 but other values? It's an experience value.
457+
sess := db.GetEngine(ctx).Where(cond).
458+
Select("`action`.*"). // this line will avoid select other joined table's columns
459+
Join("INNER", "repository", "`repository`.id = `action`.repo_id")
459460

460-
actions := make([]*Action, 0, opts.PageSize)
461-
count, err := sess.Desc("`action`.created_unix").FindAndCount(&actions)
462-
if err != nil {
463-
return nil, 0, fmt.Errorf("FindAndCount: %w", err)
461+
opts.SetDefaultValues()
462+
sess = db.SetSessionPagination(sess, &opts)
463+
464+
count, err = sess.Desc("`action`.created_unix").FindAndCount(&actions)
465+
if err != nil {
466+
return nil, 0, fmt.Errorf("FindAndCount: %w", err)
467+
}
468+
} else {
469+
// First, only query which IDs are necessary, and only then query all actions to speed up the overall query
470+
sess := db.GetEngine(ctx).Where(cond).
471+
Select("`action`.id").
472+
Join("INNER", "repository", "`repository`.id = `action`.repo_id")
473+
474+
opts.SetDefaultValues()
475+
sess = db.SetSessionPagination(sess, &opts)
476+
477+
actionIDs := make([]int64, 0, opts.PageSize)
478+
if err := sess.Table("action").Desc("`action`.created_unix").Find(&actionIDs); err != nil {
479+
return nil, 0, fmt.Errorf("Find(actionsIDs): %w", err)
480+
}
481+
482+
count, err = db.GetEngine(ctx).Where(cond).
483+
Table("action").
484+
Cols("`action`.id").
485+
Join("INNER", "repository", "`repository`.id = `action`.repo_id").Count()
486+
if err != nil {
487+
return nil, 0, fmt.Errorf("Count: %w", err)
488+
}
489+
490+
if err := db.GetEngine(ctx).In("`action`.id", actionIDs).Desc("`action`.created_unix").Find(&actions); err != nil {
491+
return nil, 0, fmt.Errorf("Find: %w", err)
492+
}
464493
}
465494

466495
if err := ActionList(actions).LoadAttributes(ctx); err != nil {

models/auth/access_token_scope.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,22 @@ func (s AccessTokenScope) HasScope(scopes ...AccessTokenScope) (bool, error) {
309309
return true, nil
310310
}
311311

312+
// HasAnyScope returns true if any of the scopes is contained in the string
313+
func (s AccessTokenScope) HasAnyScope(scopes ...AccessTokenScope) (bool, error) {
314+
bitmap, err := s.parse()
315+
if err != nil {
316+
return false, err
317+
}
318+
319+
for _, s := range scopes {
320+
if has, err := bitmap.hasScope(s); has || err != nil {
321+
return has, err
322+
}
323+
}
324+
325+
return false, nil
326+
}
327+
312328
// hasScope returns true if the string has the given scope
313329
func (bitmap accessTokenScopeBitmap) hasScope(scope AccessTokenScope) (bool, error) {
314330
expectedBits, ok := allAccessTokenScopeBits[scope]

models/issues/review.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,13 @@ func (r *Review) LoadAttributes(ctx context.Context) (err error) {
214214
return err
215215
}
216216

217+
// HTMLTypeColorName returns the color used in the ui indicating the review
217218
func (r *Review) HTMLTypeColorName() string {
218219
switch r.Type {
219220
case ReviewTypeApprove:
221+
if !r.Official {
222+
return "grey"
223+
}
220224
if r.Stale {
221225
return "yellow"
222226
}
@@ -231,6 +235,27 @@ func (r *Review) HTMLTypeColorName() string {
231235
return "grey"
232236
}
233237

238+
// TooltipContent returns the locale string describing the review type
239+
func (r *Review) TooltipContent() string {
240+
switch r.Type {
241+
case ReviewTypeApprove:
242+
if r.Stale {
243+
return "repo.issues.review.stale"
244+
}
245+
if !r.Official {
246+
return "repo.issues.review.unofficial"
247+
}
248+
return "repo.issues.review.official"
249+
case ReviewTypeComment:
250+
return "repo.issues.review.comment"
251+
case ReviewTypeReject:
252+
return "repo.issues.review.rejected"
253+
case ReviewTypeRequest:
254+
return "repo.issues.review.requested"
255+
}
256+
return ""
257+
}
258+
234259
// GetReviewByID returns the review by the given ID
235260
func GetReviewByID(ctx context.Context, id int64) (*Review, error) {
236261
review := new(Review)

0 commit comments

Comments
 (0)