Skip to content

Commit d44ef83

Browse files
authored
Merge branch 'main' into replace-16104-allow-different-smtp-port
2 parents e0e045a + f1a810e commit d44ef83

File tree

226 files changed

+6236
-2413
lines changed

Some content is hidden

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

226 files changed

+6236
-2413
lines changed

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,37 @@ This changelog goes through all the changes that have been made in each release
44
without substantial changes to our git log; to see the highlights of what has
55
been added to each release, please refer to the [blog](https://blog.gitea.io).
66

7+
## [1.15.0-rc3](https://github.com/go-gitea/gitea/releases/tag/v1.15.0-rc3) - 2021-08-06
8+
9+
* BREAKING
10+
* Upgrade to the latest version of golang-jwt and increase minimum go to 1.15 (#16590) (#16606)
11+
* SECURITY
12+
* Upgrade to the latest version of golang-jwt and increase minimum go to 1.15 (#16590) (#16606)
13+
* Correctly create of git-daemon-export-ok files (#16508) (#16514)
14+
* Don't show private user's repo in explore view (#16550) (#16554)
15+
* Update node tar dependency to 6.1.6 (#16622) (#16623)
16+
* API
17+
* Swagger AccessToken fixes (#16574) (#16597)
18+
* Set AllowedHeaders on API CORS handler (#16524) (#16618)
19+
* BUGFIXES
20+
* Restore Accessibility for Dropdown (#16576) (#16617)
21+
* Pass down SignedUserName down to AccessLogger context (#16605) (#16616)
22+
* Fix table alignment in markdown (#16596) (#16602)
23+
* Fix 500 on first wiki page (#16586) (#16598)
24+
* Lock goth/gothic and Re-attempt OAuth2 registration on login if registration failed at startup (#16564) (#16570)
25+
* Upgrade levelqueue to v0.4.0 (#16560) (#16561)
26+
* Handle too long PR titles correctly (#16517) (#16549)
27+
* Fix data race in bleve indexer (#16474) (#16509)
28+
* Restore CORS on git smart http protocol (#16496) (#16506)
29+
* Fix race in log (#16490) (#16505)
30+
* Fix prepareWikiFileName to respect existing unescaped files (#16487) (#16498)
31+
* Make cancel from CatFileBatch and CatFileBatchCheck wait for the command to end (#16479) (#16480)
32+
* Update notification table with only latest data (#16445) (#16469)
33+
* Revert to use alpine 3.13 (#16451) (#16452)
34+
* Fix crash following ldap authentication update (#16447) (#16448)
35+
* Fix direct creation of external users on admin page (partial #16612) (#16613)
36+
* Prevent 500 on draft releases without tag (#16634) (#16636)
37+
738
## [1.15.0-rc2](https://github.com/go-gitea/gitea/releases/tag/v1.15.0-rc2) - 2021-07-22
839

940
* BUGFIXES

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ require (
5252
github.com/gogs/go-gogs-client v0.0.0-20210131175652-1d7215cd8d85
5353
github.com/golang-jwt/jwt v3.2.2+incompatible
5454
github.com/golang/snappy v0.0.4 // indirect
55-
github.com/google/go-github/v32 v32.1.0
55+
github.com/google/go-github/v37 v37.0.0
5656
github.com/google/go-querystring v1.1.0 // indirect
5757
github.com/google/uuid v1.2.0
5858
github.com/gorilla/context v1.1.1
@@ -124,7 +124,7 @@ require (
124124
go.uber.org/atomic v1.8.0 // indirect
125125
go.uber.org/multierr v1.7.0 // indirect
126126
go.uber.org/zap v1.18.1 // indirect
127-
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e
127+
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
128128
golang.org/x/net v0.0.0-20210716203947-853a461950ff
129129
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914
130130
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c

go.sum

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,8 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
529529
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
530530
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
531531
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
532-
github.com/google/go-github/v32 v32.1.0 h1:GWkQOdXqviCPx7Q7Fj+KyPoGm4SwHRh8rheoPhd27II=
533-
github.com/google/go-github/v32 v32.1.0/go.mod h1:rIEpZD9CTDQwDK9GDrtMTycQNA4JU3qBsCizh3q2WCI=
532+
github.com/google/go-github/v37 v37.0.0 h1:rCspN8/6kB1BAJWZfuafvHhyfIo5fkAulaP/3bOQ/tM=
533+
github.com/google/go-github/v37 v37.0.0/go.mod h1:LM7in3NmXDrX58GbEHy7FtNLbI2JijX93RnMKvWG3m4=
534534
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
535535
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
536536
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
@@ -1145,8 +1145,9 @@ golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWP
11451145
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
11461146
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
11471147
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
1148-
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI=
11491148
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
1149+
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
1150+
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
11501151
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
11511152
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
11521153
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2021 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package integrations
6+
7+
import (
8+
"net/http"
9+
"net/url"
10+
"testing"
11+
12+
"code.gitea.io/gitea/models"
13+
api "code.gitea.io/gitea/modules/structs"
14+
"github.com/stretchr/testify/assert"
15+
)
16+
17+
func TestAPIReposGitNotes(t *testing.T) {
18+
onGiteaRun(t, func(*testing.T, *url.URL) {
19+
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
20+
// Login as User2.
21+
session := loginUser(t, user.Name)
22+
token := getTokenForLoggedInUser(t, session)
23+
24+
// check invalid requests
25+
req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/notes/12345?token=%s", user.Name, token)
26+
session.MakeRequest(t, req, http.StatusNotFound)
27+
28+
req = NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/notes/..?token=%s", user.Name, token)
29+
session.MakeRequest(t, req, http.StatusUnprocessableEntity)
30+
31+
// check valid request
32+
req = NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/notes/65f1bf27bc3bf70f64657658635e66094edbcb4d?token=%s", user.Name, token)
33+
resp := session.MakeRequest(t, req, http.StatusOK)
34+
35+
var apiData api.Note
36+
DecodeJSON(t, resp, &apiData)
37+
assert.Equal(t, "This is a test note\n", apiData.Message)
38+
})
39+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3fa2f829675543ecfc16b2891aebe8bf0608a8f4

models/commit.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2021 Gitea. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package models
6+
7+
import (
8+
"code.gitea.io/gitea/modules/git"
9+
)
10+
11+
// ConvertFromGitCommit converts git commits into SignCommitWithStatuses
12+
func ConvertFromGitCommit(commits []*git.Commit, repo *Repository) []*SignCommitWithStatuses {
13+
return ParseCommitsWithStatus(
14+
ParseCommitsWithSignature(
15+
ValidateCommitsWithEmails(commits),
16+
repo,
17+
),
18+
repo,
19+
)
20+
}

models/commit_status.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package models
66

77
import (
8-
"container/list"
98
"crypto/sha1"
109
"fmt"
1110
"strings"
@@ -257,16 +256,12 @@ type SignCommitWithStatuses struct {
257256
}
258257

259258
// ParseCommitsWithStatus checks commits latest statuses and calculates its worst status state
260-
func ParseCommitsWithStatus(oldCommits *list.List, repo *Repository) *list.List {
261-
var (
262-
newCommits = list.New()
263-
e = oldCommits.Front()
264-
)
265-
266-
for e != nil {
267-
c := e.Value.(SignCommit)
268-
commit := SignCommitWithStatuses{
269-
SignCommit: &c,
259+
func ParseCommitsWithStatus(oldCommits []*SignCommit, repo *Repository) []*SignCommitWithStatuses {
260+
newCommits := make([]*SignCommitWithStatuses, 0, len(oldCommits))
261+
262+
for _, c := range oldCommits {
263+
commit := &SignCommitWithStatuses{
264+
SignCommit: c,
270265
}
271266
statuses, err := GetLatestCommitStatus(repo.ID, commit.ID.String(), ListOptions{})
272267
if err != nil {
@@ -276,8 +271,7 @@ func ParseCommitsWithStatus(oldCommits *list.List, repo *Repository) *list.List
276271
commit.Status = CalcCommitStatus(statuses)
277272
}
278273

279-
newCommits.PushBack(commit)
280-
e = e.Next()
274+
newCommits = append(newCommits, commit)
281275
}
282276
return newCommits
283277
}

models/gpg_key_commit_verification.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package models
66

77
import (
8-
"container/list"
98
"fmt"
109
"hash"
1110
"strings"
@@ -68,24 +67,19 @@ const (
6867
)
6968

7069
// ParseCommitsWithSignature checks if signaute of commits are corresponding to users gpg keys.
71-
func ParseCommitsWithSignature(oldCommits *list.List, repository *Repository) *list.List {
72-
var (
73-
newCommits = list.New()
74-
e = oldCommits.Front()
75-
)
70+
func ParseCommitsWithSignature(oldCommits []*UserCommit, repository *Repository) []*SignCommit {
71+
newCommits := make([]*SignCommit, 0, len(oldCommits))
7672
keyMap := map[string]bool{}
7773

78-
for e != nil {
79-
c := e.Value.(UserCommit)
80-
signCommit := SignCommit{
81-
UserCommit: &c,
74+
for _, c := range oldCommits {
75+
signCommit := &SignCommit{
76+
UserCommit: c,
8277
Verification: ParseCommitWithSignature(c.Commit),
8378
}
8479

8580
_ = CalculateTrustStatus(signCommit.Verification, repository, &keyMap)
8681

87-
newCommits.PushBack(signCommit)
88-
e = e.Next()
82+
newCommits = append(newCommits, signCommit)
8983
}
9084
return newCommits
9185
}

models/issue_comment.go

Lines changed: 29 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
package models
88

99
import (
10-
"container/list"
1110
"fmt"
1211
"regexp"
1312
"strconv"
@@ -191,11 +190,11 @@ type Comment struct {
191190
RefIssue *Issue `xorm:"-"`
192191
RefComment *Comment `xorm:"-"`
193192

194-
Commits *list.List `xorm:"-"`
195-
OldCommit string `xorm:"-"`
196-
NewCommit string `xorm:"-"`
197-
CommitsNum int64 `xorm:"-"`
198-
IsForcePush bool `xorm:"-"`
193+
Commits []*SignCommitWithStatuses `xorm:"-"`
194+
OldCommit string `xorm:"-"`
195+
NewCommit string `xorm:"-"`
196+
CommitsNum int64 `xorm:"-"`
197+
IsForcePush bool `xorm:"-"`
199198
}
200199

201200
// PushActionContent is content of push pull comment
@@ -675,13 +674,8 @@ func (c *Comment) LoadPushCommits() (err error) {
675674
}
676675
defer gitRepo.Close()
677676

678-
c.Commits = gitRepo.GetCommitsFromIDs(data.CommitIDs)
679-
c.CommitsNum = int64(c.Commits.Len())
680-
if c.CommitsNum > 0 {
681-
c.Commits = ValidateCommitsWithEmails(c.Commits)
682-
c.Commits = ParseCommitsWithSignature(c.Commits, c.Issue.Repo)
683-
c.Commits = ParseCommitsWithStatus(c.Commits, c.Issue.Repo)
684-
}
677+
c.Commits = ConvertFromGitCommit(gitRepo.GetCommitsFromIDs(data.CommitIDs), c.Issue.Repo)
678+
c.CommitsNum = int64(len(c.Commits))
685679
}
686680

687681
return err
@@ -1293,21 +1287,17 @@ func getCommitIDsFromRepo(repo *Repository, oldCommitID, newCommitID, baseBranch
12931287
return nil, false, err
12941288
}
12951289

1296-
var (
1297-
commits *list.List
1298-
commitChecks map[string]commitBranchCheckItem
1299-
)
1300-
commits, err = newCommit.CommitsBeforeUntil(oldCommitID)
1290+
commits, err := newCommit.CommitsBeforeUntil(oldCommitID)
13011291
if err != nil {
13021292
return nil, false, err
13031293
}
13041294

1305-
commitIDs = make([]string, 0, commits.Len())
1306-
commitChecks = make(map[string]commitBranchCheckItem)
1295+
commitIDs = make([]string, 0, len(commits))
1296+
commitChecks := make(map[string]*commitBranchCheckItem)
13071297

1308-
for e := commits.Front(); e != nil; e = e.Next() {
1309-
commitChecks[e.Value.(*git.Commit).ID.String()] = commitBranchCheckItem{
1310-
Commit: e.Value.(*git.Commit),
1298+
for _, commit := range commits {
1299+
commitChecks[commit.ID.String()] = &commitBranchCheckItem{
1300+
Commit: commit,
13111301
Checked: false,
13121302
}
13131303
}
@@ -1316,8 +1306,8 @@ func getCommitIDsFromRepo(repo *Repository, oldCommitID, newCommitID, baseBranch
13161306
return
13171307
}
13181308

1319-
for e := commits.Back(); e != nil; e = e.Prev() {
1320-
commitID := e.Value.(*git.Commit).ID.String()
1309+
for i := len(commits) - 1; i >= 0; i-- {
1310+
commitID := commits[i].ID.String()
13211311
if item, ok := commitChecks[commitID]; ok && item.Checked {
13221312
commitIDs = append(commitIDs, commitID)
13231313
}
@@ -1331,64 +1321,49 @@ type commitBranchCheckItem struct {
13311321
Checked bool
13321322
}
13331323

1334-
func commitBranchCheck(gitRepo *git.Repository, startCommit *git.Commit, endCommitID, baseBranch string, commitList map[string]commitBranchCheckItem) (err error) {
1335-
var (
1336-
item commitBranchCheckItem
1337-
ok bool
1338-
listItem *list.Element
1339-
tmp string
1340-
)
1341-
1324+
func commitBranchCheck(gitRepo *git.Repository, startCommit *git.Commit, endCommitID, baseBranch string, commitList map[string]*commitBranchCheckItem) error {
13421325
if startCommit.ID.String() == endCommitID {
1343-
return
1326+
return nil
13441327
}
13451328

1346-
checkStack := list.New()
1347-
checkStack.PushBack(startCommit.ID.String())
1348-
listItem = checkStack.Back()
1329+
checkStack := make([]string, 0, 10)
1330+
checkStack = append(checkStack, startCommit.ID.String())
13491331

1350-
for listItem != nil {
1351-
tmp = listItem.Value.(string)
1352-
checkStack.Remove(listItem)
1332+
for len(checkStack) > 0 {
1333+
commitID := checkStack[0]
1334+
checkStack = checkStack[1:]
13531335

1354-
if item, ok = commitList[tmp]; !ok {
1355-
listItem = checkStack.Back()
1336+
item, ok := commitList[commitID]
1337+
if !ok {
13561338
continue
13571339
}
13581340

13591341
if item.Commit.ID.String() == endCommitID {
1360-
listItem = checkStack.Back()
13611342
continue
13621343
}
13631344

1364-
if err = item.Commit.LoadBranchName(); err != nil {
1365-
return
1345+
if err := item.Commit.LoadBranchName(); err != nil {
1346+
return err
13661347
}
13671348

13681349
if item.Commit.Branch == baseBranch {
1369-
listItem = checkStack.Back()
13701350
continue
13711351
}
13721352

13731353
if item.Checked {
1374-
listItem = checkStack.Back()
13751354
continue
13761355
}
13771356

13781357
item.Checked = true
1379-
commitList[tmp] = item
13801358

13811359
parentNum := item.Commit.ParentCount()
13821360
for i := 0; i < parentNum; i++ {
1383-
var parentCommit *git.Commit
1384-
parentCommit, err = item.Commit.Parent(i)
1361+
parentCommit, err := item.Commit.Parent(i)
13851362
if err != nil {
1386-
return
1363+
return err
13871364
}
1388-
checkStack.PushBack(parentCommit.ID.String())
1365+
checkStack = append(checkStack, parentCommit.ID.String())
13891366
}
1390-
1391-
listItem = checkStack.Back()
13921367
}
13931368
return nil
13941369
}

0 commit comments

Comments
 (0)