Skip to content

Commit 6d97919

Browse files
committed
Merge remote-tracking branch 'upstream/release/v1.17' into codeberg-1.17
2 parents 6d42e52 + 2c93bd7 commit 6d97919

File tree

23 files changed

+142
-27
lines changed

23 files changed

+142
-27
lines changed

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,43 @@ 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.17.0-rc2](https://github.com/go-gitea/gitea/releases/tag/v1.17.0-rc2) - 2022-07-13
8+
9+
* SECURITY
10+
* Use git.HOME_PATH for Git HOME directory (#20114) (#20293)
11+
* Add write check for creating Commit Statuses (#20332) (#20333)
12+
* ENHANCEMENTS
13+
* Make notification bell more prominent on mobile (#20108, #20236, #20251) (#20269)
14+
* Adjust max-widths for the repository file table (#20243) (#20247)
15+
* Display full name (#20171) (#20246)
16+
* BUGFIXES
17+
* Allow RSA 2047 bit keys (#20272) (#20396)
18+
* Add missing return for when topic isn't found (#20351) (#20395)
19+
* Fix commit status icon when in subdirectory (#20285) (#20385)
20+
* Initialize cron last (#20373) (#20384)
21+
* Set target on create release with existing tag (#20381) (#20382)
22+
* Update xorm.io/xorm to fix a interpreting db column sizes issue on 32bit systems (#20371) (#20372)
23+
* Make sure `repo_dir` is an empty directory or doesn't exist before 'dump-repo' (#20205) (#20370)
24+
* Prevent context deadline error propagation in GetCommitsInfo (#20346) (#20361)
25+
* Correctly handle draft releases without a tag (#20314) (#20335)
26+
* Prevent "empty" scrollbars on Firefox (#20294) (#20308)
27+
* Refactor SSH init code, fix directory creation for TrustedUserCAKeys file (#20299) (#20306)
28+
* Bump goldmark to v1.4.13 (#20300) (#20301)
29+
* Do not create empty ".ssh" directory when loading config (#20289) (#20298)
30+
* Fix NPE when using non-numeric (#20277) (#20278)
31+
* Store read access in access for team repositories (#20275) (#20276)
32+
* EscapeFilter the group dn membership (#20200) (#20254)
33+
* Only show Followers that current user can access (#20220) (#20252)
34+
* Update Bluemonday to v1.0.19 (#20199) (#20209)
35+
* Refix indices on actions table (#20158) (#20198)
36+
* Check if project has the same repository id with issue when assign project to issue (#20133) (#20188)
37+
* Fix remove file on initial comment (#20127) (#20128)
38+
* Catch the error before the response is processed by goth (#20000) (#20102)
39+
* Dashboard feed respect setting.UI.FeedPagingNum again (#20094) (#20099)
40+
* Alter hook_task TEXT fields to LONGTEXT (#20038) (#20041)
41+
* Respond with a 401 on git push when password isn't changed yet (#20026) (#20027)
42+
* Return 404 when tag is broken (#20017) (#20024)
43+
744
## [1.17.0-rc1](https://github.com/go-gitea/gitea/releases/tag/v1.17.0-rc1) - 2022-06-18
845

946
* BREAKING

cmd/dump_repo.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ package cmd
77
import (
88
"context"
99
"errors"
10+
"fmt"
11+
"os"
1012
"strings"
1113

1214
"code.gitea.io/gitea/modules/convert"
@@ -15,6 +17,7 @@ import (
1517
base "code.gitea.io/gitea/modules/migration"
1618
"code.gitea.io/gitea/modules/setting"
1719
"code.gitea.io/gitea/modules/structs"
20+
"code.gitea.io/gitea/modules/util"
1821
"code.gitea.io/gitea/services/migrations"
1922

2023
"github.com/urfave/cli"
@@ -159,9 +162,23 @@ func runDumpRepository(ctx *cli.Context) error {
159162
}
160163
}
161164

165+
// the repo_dir will be removed if error occurs in DumpRepository
166+
// make sure the directory doesn't exist or is empty, prevent from deleting user files
167+
repoDir := ctx.String("repo_dir")
168+
if exists, err := util.IsExist(repoDir); err != nil {
169+
return fmt.Errorf("unable to stat repo_dir %q: %v", repoDir, err)
170+
} else if exists {
171+
if isDir, _ := util.IsDir(repoDir); !isDir {
172+
return fmt.Errorf("repo_dir %q already exists but it's not a directory", repoDir)
173+
}
174+
if dir, _ := os.ReadDir(repoDir); len(dir) > 0 {
175+
return fmt.Errorf("repo_dir %q is not empty", repoDir)
176+
}
177+
}
178+
162179
if err := migrations.DumpRepository(
163180
context.Background(),
164-
ctx.String("repo_dir"),
181+
repoDir,
165182
ctx.String("owner_name"),
166183
opts,
167184
); err != nil {

custom/conf/app.example.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ ROUTER = console
12451245
;; Define allowed algorithms and their minimum key length (use -1 to disable a type)
12461246
;ED25519 = 256
12471247
;ECDSA = 256
1248-
;RSA = 2048
1248+
;RSA = 2047 ; we allow 2047 here because an otherwise valid 2048 bit RSA key can be reported as having 2047 bit length
12491249
;DSA = -1 ; set to 1024 to switch on
12501250

12511251
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ Define allowed algorithms and their minimum key length (use -1 to disable a type
620620

621621
- `ED25519`: **256**
622622
- `ECDSA`: **256**
623-
- `RSA`: **2048**
623+
- `RSA`: **2047**: We set 2047 here because an otherwise valid 2048 RSA key can be reported as 2047 length.
624624
- `DSA`: **-1**: DSA is now disabled by default. Set to **1024** to re-enable but ensure you may need to reconfigure your SSHD provider
625625

626626
## Webhook (`webhook`)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ require (
102102
mvdan.cc/xurls/v2 v2.4.0
103103
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251
104104
xorm.io/builder v0.3.11
105-
xorm.io/xorm v1.3.1
105+
xorm.io/xorm v1.3.2-0.20220714055524-c3bce556200f
106106
)
107107

108108
require (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,5 +2413,5 @@ strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251/go.mod h1:
24132413
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
24142414
xorm.io/builder v0.3.11 h1:naLkJitGyYW7ZZdncsh/JW+HF4HshmvTHTyUyPwJS00=
24152415
xorm.io/builder v0.3.11/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
2416-
xorm.io/xorm v1.3.1 h1:z5egKrDoOLqZFhMjcGF4FBHiTmE5/feQoHclfhNidfM=
2417-
xorm.io/xorm v1.3.1/go.mod h1:9NbjqdnjX6eyjRRhh01GHm64r6N9shTb/8Ak3YRt8Nw=
2416+
xorm.io/xorm v1.3.2-0.20220714055524-c3bce556200f h1:3NvNsM4lnttTsHpk8ODHqrwN1MCEjsO3bD/rpd8A47k=
2417+
xorm.io/xorm v1.3.2-0.20220714055524-c3bce556200f/go.mod h1:9NbjqdnjX6eyjRRhh01GHm64r6N9shTb/8Ak3YRt8Nw=

integrations/pull_status_test.go

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ func doAPICreateCommitStatus(ctx APITestContext, commitID string, status api.Com
105105
}
106106
}
107107

108-
func TestPullCreate_EmptyChangesWithCommits(t *testing.T) {
108+
func TestPullCreate_EmptyChangesWithDifferentCommits(t *testing.T) {
109+
// Merge must continue if commits SHA are different, even if content is same
110+
// Reason: gitflow and merging master back into develop, where is high possiblity, there are no changes
111+
// but just commit saying "Merge branch". And this meta commit can be also tagged,
112+
// so we need to have this meta commit also in develop branch.
109113
onGiteaRun(t, func(t *testing.T, u *url.URL) {
110114
session := loginUser(t, "user1")
111115
testRepoFork(t, session, "user2", "repo1", "user1", "repo1")
@@ -126,6 +130,28 @@ func TestPullCreate_EmptyChangesWithCommits(t *testing.T) {
126130
doc := NewHTMLParser(t, resp.Body)
127131

128132
text := strings.TrimSpace(doc.doc.Find(".merge-section").Text())
129-
assert.Contains(t, text, "This branch is equal with the target branch.")
133+
assert.Contains(t, text, "This pull request can be merged automatically.")
134+
})
135+
}
136+
137+
func TestPullCreate_EmptyChangesWithSameCommits(t *testing.T) {
138+
onGiteaRun(t, func(t *testing.T, u *url.URL) {
139+
session := loginUser(t, "user1")
140+
testRepoFork(t, session, "user2", "repo1", "user1", "repo1")
141+
testCreateBranch(t, session, "user1", "repo1", "branch/master", "status1", http.StatusSeeOther)
142+
url := path.Join("user1", "repo1", "compare", "master...status1")
143+
req := NewRequestWithValues(t, "POST", url,
144+
map[string]string{
145+
"_csrf": GetCSRF(t, session, url),
146+
"title": "pull request from status1",
147+
},
148+
)
149+
session.MakeRequest(t, req, http.StatusSeeOther)
150+
req = NewRequest(t, "GET", "/user1/repo1/pulls/1")
151+
resp := session.MakeRequest(t, req, http.StatusOK)
152+
doc := NewHTMLParser(t, resp.Body)
153+
154+
text := strings.TrimSpace(doc.doc.Find(".merge-section").Text())
155+
assert.Contains(t, text, "This branch is already included in the target branch. There is nothing to merge.")
130156
})
131157
}

models/issues/label.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"code.gitea.io/gitea/models/db"
1818
user_model "code.gitea.io/gitea/models/user"
1919
"code.gitea.io/gitea/modules/timeutil"
20+
"code.gitea.io/gitea/modules/util"
2021

2122
"xorm.io/builder"
2223
)
@@ -107,6 +108,7 @@ func (label *Label) CalOpenOrgIssues(repoID, labelID int64) {
107108
counts, _ := CountIssuesByRepo(&IssuesOptions{
108109
RepoID: repoID,
109110
LabelIDs: []int64{labelID},
111+
IsClosed: util.OptionalBoolFalse,
110112
})
111113

112114
for _, count := range counts {

models/issues/pull.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ const (
122122
PullRequestStatusManuallyMerged
123123
PullRequestStatusError
124124
PullRequestStatusEmpty
125+
PullRequestStatusAncestor
125126
)
126127

127128
// PullRequestFlow the flow of pull request
@@ -423,6 +424,11 @@ func (pr *PullRequest) IsEmpty() bool {
423424
return pr.Status == PullRequestStatusEmpty
424425
}
425426

427+
// IsAncestor returns true if the Head Commit of this PR is an ancestor of the Base Commit
428+
func (pr *PullRequest) IsAncestor() bool {
429+
return pr.Status == PullRequestStatusAncestor
430+
}
431+
426432
// SetMerged sets a pull request to merged and closes the corresponding issue
427433
func (pr *PullRequest) SetMerged(ctx context.Context) (bool, error) {
428434
if pr.HasMerged {

modules/git/git.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020

2121
"code.gitea.io/gitea/modules/log"
2222
"code.gitea.io/gitea/modules/setting"
23+
2324
"github.com/hashicorp/go-version"
2425
)
2526

modules/git/log_name_status.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"bufio"
99
"bytes"
1010
"context"
11+
"errors"
1112
"io"
1213
"path"
1314
"sort"
@@ -62,9 +63,10 @@ func LogNameStatusRepo(ctx context.Context, repository, head, treepath string, p
6263
})
6364
if err != nil {
6465
_ = stdoutWriter.CloseWithError(ConcatenateError(err, (&stderr).String()))
65-
} else {
66-
_ = stdoutWriter.Close()
66+
return
6767
}
68+
69+
_ = stdoutWriter.Close()
6870
}()
6971

7072
// For simplicities sake we'll us a buffered reader to read from the cat-file --batch
@@ -354,7 +356,7 @@ heaploop:
354356
}
355357
current, err := g.Next(treepath, path2idx, changed, maxpathlen)
356358
if err != nil {
357-
if err == context.DeadlineExceeded {
359+
if errors.Is(err, context.DeadlineExceeded) {
358360
break heaploop
359361
}
360362
g.Close()

modules/setting/setting.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ var (
170170
ServerMACs: []string{"[email protected]", "hmac-sha2-256", "hmac-sha1"},
171171
KeygenPath: "ssh-keygen",
172172
MinimumKeySizeCheck: true,
173-
MinimumKeySizes: map[string]int{"ed25519": 256, "ed25519-sk": 256, "ecdsa": 256, "ecdsa-sk": 256, "rsa": 2048},
173+
MinimumKeySizes: map[string]int{"ed25519": 256, "ed25519-sk": 256, "ecdsa": 256, "ecdsa-sk": 256, "rsa": 2047},
174174
ServerHostKeys: []string{"ssh/gitea.rsa", "ssh/gogs.rsa"},
175175
AuthorizedKeysCommandTemplate: "{{.AppPath}} --config={{.CustomConf}} serv key-{{.Key.ID}}",
176176
PerWriteTimeout: PerWriteTimeout,

options/locale/locale_en-US.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,8 @@ pulls.remove_prefix = Remove <strong>%s</strong> prefix
15331533
pulls.data_broken = This pull request is broken due to missing fork information.
15341534
pulls.files_conflicted = This pull request has changes conflicting with the target branch.
15351535
pulls.is_checking = "Merge conflict checking is in progress. Try again in few moments."
1536-
pulls.is_empty = "This branch is equal with the target branch."
1536+
pulls.is_ancestor = "This branch is already included in the target branch. There is nothing to merge."
1537+
pulls.is_empty = "The changes on this branch are already on the target branch. This will be an empty commit."
15371538
pulls.required_status_check_failed = Some required checks were not successful.
15381539
pulls.required_status_check_missing = Some required checks are missing.
15391540
pulls.required_status_check_administrator = As an administrator, you may still merge this pull request.

routers/api/v1/repo/release.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ func CreateRelease(ctx *context.APIContext) {
224224
rel.IsTag = false
225225
rel.Repo = ctx.Repo.Repository
226226
rel.Publisher = ctx.Doer
227+
rel.Target = form.Target
227228

228229
if err = release_service.UpdateRelease(ctx.Doer, ctx.Repo.GitRepo, rel, nil, nil, nil); err != nil {
229230
ctx.Error(http.StatusInternalServerError, "UpdateRelease", err)

routers/api/v1/repo/topic.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ func DeleteTopic(ctx *context.APIContext) {
240240

241241
if topic == nil {
242242
ctx.NotFound()
243+
return
243244
}
244245

245246
ctx.Status(http.StatusNoContent)

routers/init.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ func GlobalInitInstalled(ctx context.Context) {
141141
mustInit(repo_service.Init)
142142

143143
// Booting long running goroutines.
144-
cron.NewContext(ctx)
145144
issue_indexer.InitIssueIndexer(false)
146145
code_indexer.Init()
147146
mustInit(stats_indexer.Init)
@@ -160,6 +159,9 @@ func GlobalInitInstalled(ctx context.Context) {
160159

161160
auth.Init()
162161
svg.Init()
162+
163+
// Finally start up the cron
164+
cron.NewContext(ctx)
163165
}
164166

165167
// NormalRoutes represents non install routes

routers/web/repo/view.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -854,15 +854,15 @@ func renderDirectoryFiles(ctx *context.Context, timeout time.Duration) git.Entri
854854
}
855855
ctx.Data["LatestCommitVerification"] = verification
856856
ctx.Data["LatestCommitUser"] = user_model.ValidateCommitWithEmail(latestCommit)
857-
}
858857

859-
statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, ctx.Repo.Commit.ID.String(), db.ListOptions{})
860-
if err != nil {
861-
log.Error("GetLatestCommitStatus: %v", err)
862-
}
858+
statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, latestCommit.ID.String(), db.ListOptions{})
859+
if err != nil {
860+
log.Error("GetLatestCommitStatus: %v", err)
861+
}
863862

864-
ctx.Data["LatestCommitStatus"] = git_model.CalcCommitStatus(statuses)
865-
ctx.Data["LatestCommitStatuses"] = statuses
863+
ctx.Data["LatestCommitStatus"] = git_model.CalcCommitStatus(statuses)
864+
ctx.Data["LatestCommitStatuses"] = statuses
865+
}
866866

867867
branchLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL()
868868
treeLink := branchLink

routers/web/user/setting/account.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func Account(ctx *context.Context) {
3434
ctx.Data["Title"] = ctx.Tr("settings")
3535
ctx.Data["PageIsSettingsAccount"] = true
3636
ctx.Data["Email"] = ctx.Doer.Email
37+
ctx.Data["EnableNotifyMail"] = setting.Service.EnableNotifyMail
3738

3839
loadAccountData(ctx)
3940

services/pull/check.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func CheckPullMergable(stdCtx context.Context, doer *user_model.User, perm *acce
8989
return ErrIsWorkInProgress
9090
}
9191

92-
if !pr.CanAutoMerge() {
92+
if !pr.CanAutoMerge() && !pr.IsEmpty() {
9393
return ErrNotMergableState
9494
}
9595

services/pull/patch.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ func TestPatch(pr *issues_model.PullRequest) error {
8787
}
8888
}
8989
pr.MergeBase = strings.TrimSpace(pr.MergeBase)
90+
if pr.HeadCommitID, err = gitRepo.GetRefCommitID(git.BranchPrefix + "tracking"); err != nil {
91+
return fmt.Errorf("GetBranchCommitID: can't find commit ID for head: %w", err)
92+
}
93+
94+
if pr.HeadCommitID == pr.MergeBase {
95+
pr.Status = issues_model.PullRequestStatusAncestor
96+
return nil
97+
}
9098

9199
// 2. Check for conflicts
92100
if conflicts, err := checkConflicts(ctx, pr, gitRepo, tmpBasePath); err != nil || conflicts || pr.Status == issues_model.PullRequestStatusEmpty {

templates/repo/issue/view_content/pull.tmpl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,12 @@
195195
<i class="icon icon-octicon">{{svg "octicon-sync"}}</i>
196196
{{$.i18n.Tr "repo.pulls.is_checking"}}
197197
</div>
198-
{{else if .Issue.PullRequest.IsEmpty}}
198+
{{else if .Issue.PullRequest.IsAncestor}}
199199
<div class="item">
200200
<i class="icon icon-octicon">{{svg "octicon-alert" 16}}</i>
201-
{{$.i18n.Tr "repo.pulls.is_empty"}}
201+
{{$.i18n.Tr "repo.pulls.is_ancestor"}}
202202
</div>
203-
{{else if .Issue.PullRequest.CanAutoMerge}}
203+
{{else if or .Issue.PullRequest.CanAutoMerge .Issue.PullRequest.IsEmpty}}
204204
{{if .IsBlockedByApprovals}}
205205
<div class="item">
206206
<i class="icon icon-octicon">{{svg "octicon-x"}}</i>
@@ -282,7 +282,6 @@
282282
</div>
283283
{{end}}
284284
{{end}}
285-
286285
{{if and (gt .Issue.PullRequest.CommitsBehind 0) (not .Issue.IsClosed) (not .Issue.PullRequest.IsChecking) (not .IsPullFilesConflicted) (not .IsPullRequestBroken) (not $canAutoMerge)}}
287286
<div class="ui divider"></div>
288287
<div class="item item-section">
@@ -321,6 +320,14 @@
321320
</div>
322321
</div>
323322
{{end}}
323+
{{if .Issue.PullRequest.IsEmpty}}
324+
<div class="ui divider"></div>
325+
326+
<div class="item">
327+
<i class="icon icon-octicon">{{svg "octicon-alert" 16}}</i>
328+
{{$.i18n.Tr "repo.pulls.is_empty"}}
329+
</div>
330+
{{end}}
324331

325332
{{if .AllowMerge}} {{/* user is allowed to merge */}}
326333
{{$prUnit := .Repository.MustGetUnit $.UnitTypePullRequests}}
@@ -348,6 +355,7 @@
348355

349356
'canMergeNow': {{$canMergeNow}},
350357
'allOverridableChecksOk': {{not $notAllOverridableChecksOk}},
358+
'emptyCommit': {{.Issue.PullRequest.IsEmpty}},
351359
'pullHeadCommitID': {{.PullHeadCommitID}},
352360
'isPullBranchDeletable': {{.IsPullBranchDeletable}},
353361
'defaultDeleteBranchAfterMerge': {{$prUnit.PullRequestsConfig.DefaultDeleteBranchAfterMerge}},

0 commit comments

Comments
 (0)