Skip to content

Commit 9ea796b

Browse files
jergerMarkusAmshovelunny
authored andcommitted
[gitea] week 2025-21 cherry pick (gitea/main -> forgejo) (#8040)
## Checklist - [x] go to the last cherry-pick PR (forgejo/forgejo#7965) to figure out how far it went: [gitea@9d4ebc1f2c](go-gitea/gitea@9d4ebc1) - [x] cherry-pick and open PR (forgejo/forgejo#8040) - [ ] have the PR pass the CI - end-to-end (specially important if there are actions related changes) - [ ] add `run-end-to-end` label - [ ] check the result - [ ] write release notes - [ ] assign reviewers - [ ] 48h later, last call - merge 1 hour after the last call ## Legend - ❓ - No decision about the commit has been made. - 🍒 - The commit has been cherry picked. - ⏩ - The commit has been skipped. - 💡 - The commit has been skipped, but should be ported to Forgejo. - ✍️ - The commit has been skipped, and a port to Forgejo already exists. ## Commits - 🍒 [`gitea`](go-gitea/gitea@50d9565) -> [`forgejo`](https://codeberg.org/forgejo/forgejo/commit/c3e6eab73235ac189ca3a36ce2b8ea8d8ad82c81) Add sort option recentclose for issues and pulls ([gitea#34525](go-gitea/gitea#34525)) ## TODO - 💡 [`gitea`](go-gitea/gitea@d5bbaee) Retain issue sort type when a keyword search is introduced ([gitea#34559](go-gitea/gitea#34559)) UI: Small bat might be nice. Test needed? Do we've frontend tests covering the search? ------ - 💡 [`gitea`](go-gitea/gitea@82ea238) Always use an empty line to separate the commit message and trailer ([gitea#34512](go-gitea/gitea#34512)) Needs merge ------ - 💡 [`gitea`](go-gitea/gitea@74858dc) Fix line-button issue after file selection in file tree ([gitea#34574](go-gitea/gitea#34574)) Frontend: Makes it sense to pick/port ui logic in *.ts files? ------ - 💡 [`gitea`](go-gitea/gitea@7149c9c) Fix doctor deleting orphaned issues attachments ([gitea#34142](go-gitea/gitea#34142)) Doctor: seems useful. ------ - 💡 [`gitea`](go-gitea/gitea@0cec4b8) Fix actions skipped commit status indicator ([gitea#34507](go-gitea/gitea#34507)) Actions: Might benefit from additional tests. ------ - 💡 [`gitea`](go-gitea/gitea@4cb0c64) Add "View workflow file" to Actions list page ([gitea#34538](go-gitea/gitea#34538)) Actions: Needs tests ------ - 💡 [`gitea`](go-gitea/gitea@b0936f4) Do not mutate incoming options to RenderUserSearch and SearchUsers ([gitea#34544](go-gitea/gitea#34544)) Nice refactoring but needs manual merge. ------ - 💡 [`gitea`](go-gitea/gitea@498088c) Add webhook assigning test and fix possible bug ([gitea#34420](go-gitea/gitea#34420)) Integrationtest has conflicts needs merge. ------ - 💡 [`gitea`](go-gitea/gitea@24a5105) Fix possible nil description of pull request when migrating from CodeCommit ([gitea#34541](go-gitea/gitea#34541)) Is this relevant to forgejo? Did not find the place to apply this small change. ------ - 💡 [`gitea`](go-gitea/gitea@688da55) Split GetLatestCommitStatus as two functions ([gitea#34535](go-gitea/gitea#34535)) Merge required. ------ - 💡 [`gitea`](go-gitea/gitea@ab96912) Don't display error log when .git-blame-ignore-revs doesn't exist ([gitea#34457](go-gitea/gitea#34457)) Unsure wheter this affects forgejo. Tests missing. ------ - 💡 [`gitea`](go-gitea/gitea@11ee7ff) fix: return 201 Created for CreateVariable API responses ([gitea#34517](go-gitea/gitea#34517)) Actions: This is marked as breaking the api. Pls think about whether this breaking change iss needed & how this impact api-version-increase. The corresponding clinet change can be found here: https://gitea.com/gitea/go-sdk/pulls/713/files ------ - 💡 [`gitea`](go-gitea/gitea@9b295e9) Actions list ([gitea#34530](go-gitea/gitea#34530)) Actions: Regression from go-gitea/gitea#34337 Part of https://codeberg.org/forgejo/forgejo/pulls/7909 ------ ## Skipped - ⏩ [`gitea`](go-gitea/gitea@bb6377d) [skip ci] Updated translations via Crowdin ------ - ⏩ [`gitea`](go-gitea/gitea@07d802a) [skip ci] Updated translations via Crowdin ------ - ⏩ [`gitea`](go-gitea/gitea@c6e2093) Clean up "file-view" related styles ([gitea#34558](go-gitea/gitea#34558)) - gitea ui specific specific ------ - ⏩ [`gitea`](go-gitea/gitea@9f10885) Refactor commit reader ([gitea#34542](go-gitea/gitea#34542)) - gitea refactor specific ------ <details> <summary><h2>Stats</h2></summary> <br> Between [`gitea@9d4ebc1f2c`](go-gitea/gitea@9d4ebc1) and [`gitea@d5bbaee64e`](go-gitea/gitea@d5bbaee), **18** commits have been reviewed. We picked **1**, skipped **4**, and decided to port **13**. </details> Co-authored-by: Markus Amshove <[email protected]> Co-authored-by: Lunny Xiao <[email protected]> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8040 Reviewed-by: Earl Warren <[email protected]> Co-authored-by: Michael Jerger <[email protected]> Co-committed-by: Michael Jerger <[email protected]>
1 parent 877fa8c commit 9ea796b

File tree

5 files changed

+47
-2
lines changed

5 files changed

+47
-2
lines changed

models/issues/issue_search.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ func applySorts(sess *xorm.Session, sortType string, priorityRepoID int64) {
6666
sess.Asc("issue.created_unix").Asc("issue.id")
6767
case "recentupdate":
6868
sess.Desc("issue.updated_unix").Desc("issue.created_unix").Desc("issue.id")
69+
case "recentclose":
70+
sess.Desc("issue.closed_unix").Desc("issue.created_unix").Desc("issue.id")
6971
case "leastupdate":
7072
sess.Asc("issue.updated_unix").Asc("issue.created_unix").Asc("issue.id")
7173
case "mostcomment":

models/issues/pull_list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ func PullRequests(ctx context.Context, baseRepoID int64, opts *PullRequestsOptio
152152
applySorts(findSession, opts.SortType, 0)
153153
findSession = db.SetSessionPagination(findSession, opts)
154154
prs := make([]*PullRequest, 0, opts.PageSize)
155-
return prs, maxResults, findSession.Find(&prs)
155+
found := findSession.Find(&prs)
156+
return prs, maxResults, found
156157
}
157158

158159
// PullRequestList defines a list of pull requests

models/issues/pull_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,47 @@ func TestPullRequestsNewest(t *testing.T) {
7979
}
8080
}
8181

82+
func TestPullRequests_Closed_RecentSortType(t *testing.T) {
83+
// Issue ID | Closed At. | Updated At
84+
// 2 | 1707270001 | 1707270001
85+
// 3 | 1707271000 | 1707279999
86+
// 11 | 1707279999 | 1707275555
87+
tests := []struct {
88+
sortType string
89+
expectedIssueIDOrder []int64
90+
}{
91+
{"recentupdate", []int64{3, 11, 2}},
92+
{"recentclose", []int64{11, 3, 2}},
93+
}
94+
95+
require.NoError(t, unittest.PrepareTestDatabase())
96+
_, err := db.Exec(db.DefaultContext, "UPDATE issue SET closed_unix = 1707270001, updated_unix = 1707270001, is_closed = true WHERE id = 2")
97+
require.NoError(t, err)
98+
_, err = db.Exec(db.DefaultContext, "UPDATE issue SET closed_unix = 1707271000, updated_unix = 1707279999, is_closed = true WHERE id = 3")
99+
require.NoError(t, err)
100+
_, err = db.Exec(db.DefaultContext, "UPDATE issue SET closed_unix = 1707279999, updated_unix = 1707275555, is_closed = true WHERE id = 11")
101+
require.NoError(t, err)
102+
103+
for _, test := range tests {
104+
t.Run(test.sortType, func(t *testing.T) {
105+
prs, _, err := issues_model.PullRequests(db.DefaultContext, 1, &issues_model.PullRequestsOptions{
106+
ListOptions: db.ListOptions{
107+
Page: 1,
108+
},
109+
State: "closed",
110+
SortType: test.sortType,
111+
})
112+
require.NoError(t, err)
113+
114+
if assert.Len(t, prs, len(test.expectedIssueIDOrder)) {
115+
for i := range test.expectedIssueIDOrder {
116+
assert.Equal(t, test.expectedIssueIDOrder[i], prs[i].IssueID)
117+
}
118+
}
119+
})
120+
}
121+
}
122+
82123
func TestLoadRequestedReviewers(t *testing.T) {
83124
require.NoError(t, unittest.PrepareTestDatabase())
84125

routers/api/v1/repo/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func ListPullRequests(ctx *context.APIContext) {
7171
// in: query
7272
// description: Type of sort
7373
// type: string
74-
// enum: [oldest, recentupdate, leastupdate, mostcomment, leastcomment, priority]
74+
// enum: [oldest, recentupdate, recentclose, leastupdate, mostcomment, leastcomment, priority]
7575
// - name: milestone
7676
// in: query
7777
// description: ID of the milestone

templates/swagger/v1_json.tmpl

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

0 commit comments

Comments
 (0)