Skip to content

Commit 1fa6c06

Browse files
committed
Merge remote-tracking branch 'upstream/main'
* upstream/main: [skip ci] Updated licenses and gitignores Add `WithPullRequest` for `actionsNotifier` (go-gitea#25144) [skip ci] Updated translations via Crowdin [skip ci] Updated translations via Crowdin Update github.com/google/go-github to v53 (go-gitea#25157) Fix bug for code search if code is disabled (go-gitea#25173) Minor arc-green color tweaks (go-gitea#25175) Fix duplicate Reviewed-by trailers (go-gitea#24796) Fix go-gitea#25133 (go-gitea#25162) Fix mobile navbar and misc cleanups (go-gitea#25134) Button and color enhancements (go-gitea#24989) Fix setup-go actions (go-gitea#25167) # Conflicts: # templates/base/head_navbar.tmpl
2 parents 482bdb7 + d67e411 commit 1fa6c06

Some content is hidden

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

73 files changed

+971
-720
lines changed

.github/workflows/cron-licenses.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ jobs:
1010
if: github.repository == 'go-gitea/gitea'
1111
steps:
1212
- uses: actions/checkout@v3
13-
- uses: actions/setup-go@v3
13+
- uses: actions/setup-go@v4
1414
with:
15-
go-version: ">=1.20.1"
15+
go-version: ">=1.20"
16+
check-latest: true
1617
- run: make generate-license generate-gitignore
1718
timeout-minutes: 40
1819
- name: push translations to repo

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ jobs:
4141
- uses: actions/checkout@v3
4242
- uses: actions/setup-go@v4
4343
with:
44-
go-version: ">=1.20.0"
44+
go-version: ">=1.20"
45+
check-latest: true
4546
- name: Add hosts to /etc/hosts
4647
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 pgsql ldap minio" | sudo tee -a /etc/hosts'
4748
- run: make deps-backend
@@ -65,7 +66,8 @@ jobs:
6566
- uses: actions/checkout@v3
6667
- uses: actions/setup-go@v4
6768
with:
68-
go-version: ">=1.20.0"
69+
go-version: ">=1.20"
70+
check-latest: true
6971
- run: make deps-backend
7072
- run: make backend
7173
env:
@@ -123,7 +125,8 @@ jobs:
123125
- uses: actions/checkout@v3
124126
- uses: actions/setup-go@v4
125127
with:
126-
go-version: ">=1.20.0"
128+
go-version: ">=1.20"
129+
check-latest: true
127130
- name: Add hosts to /etc/hosts
128131
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mysql elasticsearch smtpimap" | sudo tee -a /etc/hosts'
129132
- run: make deps-backend
@@ -172,7 +175,8 @@ jobs:
172175
- uses: actions/checkout@v3
173176
- uses: actions/setup-go@v4
174177
with:
175-
go-version: ">=1.20.0"
178+
go-version: ">=1.20"
179+
check-latest: true
176180
- name: Add hosts to /etc/hosts
177181
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mysql elasticsearch smtpimap" | sudo tee -a /etc/hosts'
178182
- run: make deps-backend
@@ -203,7 +207,8 @@ jobs:
203207
- uses: actions/checkout@v3
204208
- uses: actions/setup-go@v4
205209
with:
206-
go-version: ">=1.20.0"
210+
go-version: ">=1.20"
211+
check-latest: true
207212
- name: Add hosts to /etc/hosts
208213
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mysql8" | sudo tee -a /etc/hosts'
209214
- run: make deps-backend
@@ -233,7 +238,8 @@ jobs:
233238
- uses: actions/checkout@v3
234239
- uses: actions/setup-go@v4
235240
with:
236-
go-version: ">=1.20.0"
241+
go-version: ">=1.20"
242+
check-latest: true
237243
- name: Add hosts to /etc/hosts
238244
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mssql" | sudo tee -a /etc/hosts'
239245
- run: make deps-backend

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.

contrib/backport/backport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"strings"
1818
"syscall"
1919

20-
"github.com/google/go-github/v52/github"
20+
"github.com/google/go-github/v53/github"
2121
"github.com/urfave/cli"
2222
"gopkg.in/yaml.v3"
2323
)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ require (
5555
github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14
5656
github.com/gogs/go-gogs-client v0.0.0-20210131175652-1d7215cd8d85
5757
github.com/golang-jwt/jwt/v4 v4.5.0
58-
github.com/google/go-github/v52 v52.0.0
58+
github.com/google/go-github/v53 v53.0.0
5959
github.com/google/pprof v0.0.0-20230502171905-255e3b9b56de
6060
github.com/google/uuid v1.3.0
6161
github.com/gorilla/feeds v1.1.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,8 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
565565
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
566566
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
567567
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
568-
github.com/google/go-github/v52 v52.0.0 h1:uyGWOY+jMQ8GVGSX8dkSwCzlehU3WfdxQ7GweO/JP7M=
569-
github.com/google/go-github/v52 v52.0.0/go.mod h1:WJV6VEEUPuMo5pXqqa2ZCZEdbQqua4zAk2MZTIo+m+4=
568+
github.com/google/go-github/v53 v53.0.0 h1:T1RyHbSnpHYnoF0ZYKiIPSgPtuJ8G6vgc0MKodXsQDQ=
569+
github.com/google/go-github/v53 v53.0.0/go.mod h1:XhFRObz+m/l+UCm9b7KSIC3lT3NWSXGt7mOsAWEloao=
570570
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
571571
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
572572
github.com/google/go-tpm v0.1.2-0.20190725015402-ae6dd98980d4/go.mod h1:H9HbmUG2YgV/PHITkO7p6wxEEj/v5nlsVWIwumwH2NI=

models/fixtures/review.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,30 @@
105105
official: true
106106
updated_unix: 1603196749
107107
created_unix: 1603196749
108+
109+
-
110+
id: 13
111+
type: 1
112+
reviewer_id: 5
113+
issue_id: 11
114+
content: "old review from user5"
115+
updated_unix: 946684820
116+
created_unix: 946684820
117+
118+
-
119+
id: 14
120+
type: 1
121+
reviewer_id: 5
122+
issue_id: 11
123+
content: "duplicate review from user5 (latest)"
124+
updated_unix: 946684830
125+
created_unix: 946684830
126+
127+
-
128+
id: 15
129+
type: 1
130+
reviewer_id: 6
131+
issue_id: 11
132+
content: "singular review from user6 and final review for this pr"
133+
updated_unix: 946684831
134+
created_unix: 946684831

models/issues/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ func (pr *PullRequest) getReviewedByLines(writer io.Writer) error {
404404
defer committer.Close()
405405

406406
// Note: This doesn't page as we only expect a very limited number of reviews
407-
reviews, err := FindReviews(ctx, FindReviewOptions{
407+
reviews, err := FindLatestReviews(ctx, FindReviewOptions{
408408
Type: ReviewTypeApprove,
409409
IssueID: pr.IssueID,
410410
OfficialOnly: setting.Repository.PullRequest.DefaultMergeMessageOfficialApproversOnly,

models/issues/pull_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
issues_model "code.gitea.io/gitea/models/issues"
1111
"code.gitea.io/gitea/models/unittest"
1212
user_model "code.gitea.io/gitea/models/user"
13+
"code.gitea.io/gitea/modules/setting"
1314

1415
"github.com/stretchr/testify/assert"
1516
)
@@ -325,3 +326,14 @@ func TestParseCodeOwnersLine(t *testing.T) {
325326
assert.Equal(t, g.Tokens, tokens, "Codeowners tokenizer failed")
326327
}
327328
}
329+
330+
func TestGetApprovers(t *testing.T) {
331+
assert.NoError(t, unittest.PrepareTestDatabase())
332+
pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 5})
333+
// Official reviews are already deduplicated. Allow unofficial reviews
334+
// to assert that there are no duplicated approvers.
335+
setting.Repository.PullRequest.DefaultMergeMessageOfficialApproversOnly = false
336+
approvers := pr.GetApprovers()
337+
expected := "Reviewed-by: User Five <[email protected]>\nReviewed-by: User Six <[email protected]>\n"
338+
assert.EqualValues(t, expected, approvers)
339+
}

models/issues/review.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,27 @@ func FindReviews(ctx context.Context, opts FindReviewOptions) ([]*Review, error)
275275
Find(&reviews)
276276
}
277277

278+
// FindLatestReviews returns only latest reviews per user, passing FindReviewOptions
279+
func FindLatestReviews(ctx context.Context, opts FindReviewOptions) ([]*Review, error) {
280+
reviews := make([]*Review, 0, 10)
281+
cond := opts.toCond()
282+
sess := db.GetEngine(ctx).Where(cond)
283+
if opts.Page > 0 {
284+
sess = db.SetSessionPagination(sess, &opts)
285+
}
286+
287+
sess.In("id", builder.
288+
Select("max ( id ) ").
289+
From("review").
290+
Where(cond).
291+
GroupBy("reviewer_id"))
292+
293+
return reviews, sess.
294+
Asc("created_unix").
295+
Asc("id").
296+
Find(&reviews)
297+
}
298+
278299
// CountReviews returns count of reviews passing FindReviewOptions
279300
func CountReviews(opts FindReviewOptions) (int64, error) {
280301
return db.GetEngine(db.DefaultContext).Where(opts.toCond()).Count(&Review{})

0 commit comments

Comments
 (0)