Skip to content

Commit 4af6417

Browse files
authored
Merge branch 'main' into lfs-ssh
2 parents 1e8502f + fdb1df9 commit 4af6417

File tree

93 files changed

+1078
-603
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

+1078
-603
lines changed

.github/labeler.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ modifies/go:
7070
- any-glob-to-any-file:
7171
- "**/*.go"
7272

73-
modifies/js:
73+
modifies/frontend:
7474
- changed-files:
7575
- any-glob-to-any-file:
7676
- "**/*.js"
77+
- "**/*.ts"
7778
- "**/*.vue"
7879

7980
docs-update-needed:

.github/workflows/pull-db-tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ jobs:
198198
test-mssql:
199199
if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true'
200200
needs: files-changed
201-
runs-on: ubuntu-latest
201+
# specifying the version of ubuntu in use as mssql fails on newer kernels
202+
# pending resolution from vendor
203+
runs-on: ubuntu-20.04
202204
services:
203205
mssql:
204206
image: mcr.microsoft.com/mssql/server:2017-latest

cmd/serv.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ func runServ(c *cli.Context) error {
194194
return nil
195195
}
196196

197+
defer func() {
198+
if err := recover(); err != nil {
199+
_ = fail(ctx, "Internal Server Error", "Panic: %v\n%s", err, log.Stack(2))
200+
}
201+
}()
202+
197203
keys := strings.Split(c.Args().First(), "-")
198204
if len(keys) != 2 || keys[0] != "key" {
199205
return fail(ctx, "Key ID format error", "Invalid key argument: %s", c.Args().First())
@@ -240,10 +246,7 @@ func runServ(c *cli.Context) error {
240246
}
241247

242248
verb := words[0]
243-
repoPath := words[1]
244-
if repoPath[0] == '/' {
245-
repoPath = repoPath[1:]
246-
}
249+
repoPath := strings.TrimPrefix(words[1], "/")
247250

248251
var lfsVerb string
249252

custom/conf/app.example.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,8 @@ INTERNAL_TOKEN =
528528
;; HMAC to encode urls with, it **is required** if camo is enabled.
529529
;HMAC_KEY =
530530
;; Set to true to use camo for https too lese only non https urls are proxyed
531-
;ALLWAYS = false
531+
;; ALLWAYS is deprecated and will be removed in the future
532+
;ALWAYS = false
532533

533534
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
534535
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ module code.gitea.io/gitea
22

33
go 1.23
44

5+
// rfc5280 said: "The serial number is an integer assigned by the CA to each certificate."
6+
// But some CAs use negative serial number, just relax the check. related:
7+
// Default TLS cert uses negative serial number #895 https://github.com/microsoft/mssql-docker/issues/895
8+
godebug x509negativeserial=1
9+
510
require (
611
code.gitea.io/actions-proto-go v0.4.0
712
code.gitea.io/gitea-vet v0.2.3

models/activities/action.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -452,13 +452,10 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, err
452452

453453
actions := make([]*Action, 0, opts.PageSize)
454454
var count int64
455+
opts.SetDefaultValues()
455456

456457
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")
460-
461-
opts.SetDefaultValues()
458+
sess := db.GetEngine(ctx).Where(cond)
462459
sess = db.SetSessionPagination(sess, &opts)
463460

464461
count, err = sess.Desc("`action`.created_unix").FindAndCount(&actions)
@@ -467,11 +464,7 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, err
467464
}
468465
} else {
469466
// 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()
467+
sess := db.GetEngine(ctx).Where(cond).Select("`action`.id")
475468
sess = db.SetSessionPagination(sess, &opts)
476469

477470
actionIDs := make([]int64, 0, opts.PageSize)
@@ -481,8 +474,7 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, err
481474

482475
count, err = db.GetEngine(ctx).Where(cond).
483476
Table("action").
484-
Cols("`action`.id").
485-
Join("INNER", "repository", "`repository`.id = `action`.repo_id").Count()
477+
Cols("`action`.id").Count()
486478
if err != nil {
487479
return nil, 0, fmt.Errorf("Count: %w", err)
488480
}

models/activities/action_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ func TestNotifyWatchers(t *testing.T) {
228228
}
229229

230230
func TestGetFeedsCorrupted(t *testing.T) {
231+
// Now we will not check for corrupted data in the feeds
232+
// users should run doctor to fix their data
231233
assert.NoError(t, unittest.PrepareTestDatabase())
232234
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
233235
unittest.AssertExistsAndLoadBean(t, &activities_model.Action{
@@ -241,8 +243,8 @@ func TestGetFeedsCorrupted(t *testing.T) {
241243
IncludePrivate: true,
242244
})
243245
assert.NoError(t, err)
244-
assert.Len(t, actions, 0)
245-
assert.Equal(t, int64(0), count)
246+
assert.Len(t, actions, 1)
247+
assert.Equal(t, int64(1), count)
246248
}
247249

248250
func TestConsistencyUpdateAction(t *testing.T) {

models/activities/repo_activity.go

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type ActivityStats struct {
3434
OpenedPRAuthorCount int64
3535
MergedPRs issues_model.PullRequestList
3636
MergedPRAuthorCount int64
37+
ActiveIssues issues_model.IssueList
3738
OpenedIssues issues_model.IssueList
3839
OpenedIssueAuthorCount int64
3940
ClosedIssues issues_model.IssueList
@@ -172,7 +173,7 @@ func (stats *ActivityStats) MergedPRPerc() int {
172173

173174
// ActiveIssueCount returns total active issue count
174175
func (stats *ActivityStats) ActiveIssueCount() int {
175-
return stats.OpenedIssueCount() + stats.ClosedIssueCount()
176+
return len(stats.ActiveIssues)
176177
}
177178

178179
// OpenedIssueCount returns open issue count
@@ -285,13 +286,21 @@ func (stats *ActivityStats) FillIssues(ctx context.Context, repoID int64, fromTi
285286
stats.ClosedIssueAuthorCount = count
286287

287288
// New issues
288-
sess = issuesForActivityStatement(ctx, repoID, fromTime, false, false)
289+
sess = newlyCreatedIssues(ctx, repoID, fromTime)
289290
sess.OrderBy("issue.created_unix ASC")
290291
stats.OpenedIssues = make(issues_model.IssueList, 0)
291292
if err = sess.Find(&stats.OpenedIssues); err != nil {
292293
return err
293294
}
294295

296+
// Active issues
297+
sess = activeIssues(ctx, repoID, fromTime)
298+
sess.OrderBy("issue.created_unix ASC")
299+
stats.ActiveIssues = make(issues_model.IssueList, 0)
300+
if err = sess.Find(&stats.ActiveIssues); err != nil {
301+
return err
302+
}
303+
295304
// Opened issue authors
296305
sess = issuesForActivityStatement(ctx, repoID, fromTime, false, false)
297306
if _, err = sess.Select("count(distinct issue.poster_id) as `count`").Table("issue").Get(&count); err != nil {
@@ -317,6 +326,23 @@ func (stats *ActivityStats) FillUnresolvedIssues(ctx context.Context, repoID int
317326
return sess.Find(&stats.UnresolvedIssues)
318327
}
319328

329+
func newlyCreatedIssues(ctx context.Context, repoID int64, fromTime time.Time) *xorm.Session {
330+
sess := db.GetEngine(ctx).Where("issue.repo_id = ?", repoID).
331+
And("issue.is_pull = ?", false). // Retain the is_pull check to exclude pull requests
332+
And("issue.created_unix >= ?", fromTime.Unix()) // Include all issues created after fromTime
333+
334+
return sess
335+
}
336+
337+
func activeIssues(ctx context.Context, repoID int64, fromTime time.Time) *xorm.Session {
338+
sess := db.GetEngine(ctx).Where("issue.repo_id = ?", repoID).
339+
And("issue.is_pull = ?", false).
340+
And("issue.created_unix >= ?", fromTime.Unix()).
341+
Or("issue.closed_unix >= ?", fromTime.Unix())
342+
343+
return sess
344+
}
345+
320346
func issuesForActivityStatement(ctx context.Context, repoID int64, fromTime time.Time, closed, unresolved bool) *xorm.Session {
321347
sess := db.GetEngine(ctx).Where("issue.repo_id = ?", repoID).
322348
And("issue.is_closed = ?", closed)

models/issues/pull.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ func (pr *PullRequest) LoadAttributes(ctx context.Context) (err error) {
268268
return nil
269269
}
270270

271+
func (pr *PullRequest) IsAgitFlow() bool {
272+
return pr.Flow == PullRequestFlowAGit
273+
}
274+
271275
// LoadHeadRepo loads the head repository, pr.HeadRepo will remain nil if it does not exist
272276
// and thus ErrRepoNotExist will never be returned
273277
func (pr *PullRequest) LoadHeadRepo(ctx context.Context) (err error) {

models/issues/review.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ func (r *Review) TooltipContent() string {
247247
}
248248
return "repo.issues.review.official"
249249
case ReviewTypeComment:
250-
return "repo.issues.review.comment"
250+
return "repo.issues.review.commented"
251251
case ReviewTypeReject:
252252
return "repo.issues.review.rejected"
253253
case ReviewTypeRequest:

0 commit comments

Comments
 (0)