Skip to content

Commit 04a5bb6

Browse files
authored
Merge branch 'master' into only-close-the-gitrepo-at-the-end-of-wrap
2 parents 73b34f8 + f5eb33c commit 04a5bb6

File tree

21 files changed

+100
-42
lines changed

21 files changed

+100
-42
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ RUN addgroup \
5353
-u 1000 \
5454
-G git \
5555
git && \
56-
echo "git:$(dd if=/dev/urandom bs=24 count=1 status=none | base64)" | chpasswd
56+
echo "git:*" | chpasswd -e
5757

5858
ENV USER git
5959
ENV GITEA_CUSTOM /data/gitea

Dockerfile.rootless

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ RUN addgroup \
4646
-s /bin/bash \
4747
-u 1000 \
4848
-G git \
49-
git && \
50-
echo "git:$(dd if=/dev/urandom bs=24 count=1 status=none | base64)" | chpasswd
49+
git
5150

5251
RUN mkdir -p /var/lib/gitea /etc/gitea
5352
RUN chown git:git /var/lib/gitea /etc/gitea

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
5959
- `MIRROR_QUEUE_LENGTH`: **1000**: Patch test queue length, increase if pull request patch
6060
testing starts hanging.
6161
- `PREFERRED_LICENSES`: **Apache License 2.0,MIT License**: Preferred Licenses to place at
62-
the top of the list. Name must match file name in conf/license or custom/conf/license.
62+
the top of the list. Name must match file name in options/license or custom/options/license.
6363
- `DISABLE_HTTP_GIT`: **false**: Disable the ability to interact with repositories over the
6464
HTTP protocol.
6565
- `USE_COMPAT_SSH_URI`: **false**: Force ssh:// clone url instead of scp-style uri when

docs/content/doc/advanced/external-renderers.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ IS_INPUT_FILE = true
7070
[markup.restructuredtext]
7171
ENABLED = true
7272
FILE_EXTENSIONS = .rst
73-
RENDER_COMMAND = rst2html.py
73+
RENDER_COMMAND = "timeout 30s pandoc +RTS -M512M -RTS -f rst"
7474
IS_INPUT_FILE = false
7575
```
7676

models/consistency.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,15 @@ func CountOrphanedObjects(subject, refobject, joinCond string) (int64, error) {
296296

297297
// DeleteOrphanedObjects delete subjects with have no existing refobject anymore
298298
func DeleteOrphanedObjects(subject, refobject, joinCond string) error {
299-
_, err := x.In("id", builder.Select("`"+subject+"`.id").
299+
subQuery := builder.Select("`"+subject+"`.id").
300300
From("`"+subject+"`").
301301
Join("LEFT", "`"+refobject+"`", joinCond).
302-
Where(builder.IsNull{"`" + refobject + "`.id"})).
303-
Delete("`" + subject + "`")
302+
Where(builder.IsNull{"`" + refobject + "`.id"})
303+
sql, args, err := builder.Delete(builder.In("id", subQuery)).From("`" + subject + "`").ToSQL()
304+
if err != nil {
305+
return err
306+
}
307+
_, err = x.Exec(append([]interface{}{sql}, args...)...)
304308
return err
305309
}
306310

models/consistency_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
"testing"
9+
10+
"github.com/stretchr/testify/assert"
11+
)
12+
13+
func TestDeleteOrphanedObjects(t *testing.T) {
14+
assert.NoError(t, PrepareTestDatabase())
15+
16+
countBefore, err := x.Count(&PullRequest{})
17+
assert.NoError(t, err)
18+
19+
_, err = x.Insert(&PullRequest{IssueID: 1000}, &PullRequest{IssueID: 1001}, &PullRequest{IssueID: 1003})
20+
assert.NoError(t, err)
21+
22+
orphaned, err := CountOrphanedObjects("pull_request", "issue", "pull_request.issue_id=issue.id")
23+
assert.NoError(t, err)
24+
assert.EqualValues(t, 3, orphaned)
25+
26+
err = DeleteOrphanedObjects("pull_request", "issue", "pull_request.issue_id=issue.id")
27+
assert.NoError(t, err)
28+
29+
countAfter, err := x.Count(&PullRequest{})
30+
assert.NoError(t, err)
31+
assert.EqualValues(t, countBefore, countAfter)
32+
}

models/repo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,7 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
14721472
&LanguageStat{RepoID: repoID},
14731473
&Comment{RefRepoID: repoID},
14741474
&Task{RepoID: repoID},
1475+
&ProtectedBranch{RepoID: repoID},
14751476
); err != nil {
14761477
return fmt.Errorf("deleteBeans: %v", err)
14771478
}

models/user.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ func (u *User) CanImportLocal() bool {
301301
// DashboardLink returns the user dashboard page link.
302302
func (u *User) DashboardLink() string {
303303
if u.IsOrganization() {
304-
return setting.AppSubURL + "/org/" + u.Name + "/dashboard/"
304+
return u.OrganisationLink() + "/dashboard/"
305305
}
306306
return setting.AppSubURL + "/"
307307
}
@@ -316,6 +316,11 @@ func (u *User) HTMLURL() string {
316316
return setting.AppURL + u.Name
317317
}
318318

319+
// OrganisationLink returns the organization sub page link.
320+
func (u *User) OrganisationLink() string {
321+
return setting.AppSubURL + "/org/" + u.Name
322+
}
323+
319324
// GenerateEmailActivateCode generates an activate code based on user information and given e-mail.
320325
func (u *User) GenerateEmailActivateCode(email string) string {
321326
code := base.CreateTimeLimitCode(

modules/context/org.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"strings"
1010

1111
"code.gitea.io/gitea/models"
12-
"code.gitea.io/gitea/modules/setting"
1312
)
1413

1514
// Organization contains organization context
@@ -70,7 +69,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
7069

7170
// Force redirection when username is actually a user.
7271
if !org.IsOrganization() {
73-
ctx.Redirect(setting.AppSubURL + "/" + org.Name)
72+
ctx.Redirect(org.HomeLink())
7473
return
7574
}
7675

@@ -118,7 +117,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
118117
ctx.Data["IsOrganizationMember"] = ctx.Org.IsMember
119118
ctx.Data["CanCreateOrgRepo"] = ctx.Org.CanCreateOrgRepo
120119

121-
ctx.Org.OrgLink = setting.AppSubURL + "/org/" + org.Name
120+
ctx.Org.OrgLink = org.OrganisationLink()
122121
ctx.Data["OrgLink"] = ctx.Org.OrgLink
123122

124123
// Team.

modules/doctor/dbconsistency.go

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func checkDBConsistency(logger log.Logger, autofix bool) error {
2929
if count > 0 {
3030
if autofix {
3131
if err = models.DeleteOrphanedLabels(); err != nil {
32-
logger.Critical("Error: %v whilst deleting orphaned labels")
32+
logger.Critical("Error: %v whilst deleting orphaned labels", err)
3333
return err
3434
}
3535
logger.Info("%d labels without existing repository/organisation deleted", count)
@@ -47,7 +47,7 @@ func checkDBConsistency(logger log.Logger, autofix bool) error {
4747
if count > 0 {
4848
if autofix {
4949
if err = models.DeleteOrphanedIssueLabels(); err != nil {
50-
logger.Critical("Error: %v whilst deleting orphaned issue_labels")
50+
logger.Critical("Error: %v whilst deleting orphaned issue_labels", err)
5151
return err
5252
}
5353
logger.Info("%d issue_labels without existing label deleted", count)
@@ -65,7 +65,7 @@ func checkDBConsistency(logger log.Logger, autofix bool) error {
6565
if count > 0 {
6666
if autofix {
6767
if err = models.DeleteOrphanedIssues(); err != nil {
68-
logger.Critical("Error: %v whilst deleting orphaned issues")
68+
logger.Critical("Error: %v whilst deleting orphaned issues", err)
6969
return err
7070
}
7171
logger.Info("%d issues without existing repository deleted", count)
@@ -83,7 +83,7 @@ func checkDBConsistency(logger log.Logger, autofix bool) error {
8383
if count > 0 {
8484
if autofix {
8585
if err = models.DeleteOrphanedObjects("pull_request", "issue", "pull_request.issue_id=issue.id"); err != nil {
86-
logger.Critical("Error: %v whilst deleting orphaned objects")
86+
logger.Critical("Error: %v whilst deleting orphaned objects", err)
8787
return err
8888
}
8989
logger.Info("%d pull requests without existing issue deleted", count)
@@ -101,7 +101,7 @@ func checkDBConsistency(logger log.Logger, autofix bool) error {
101101
if count > 0 {
102102
if autofix {
103103
if err = models.DeleteOrphanedObjects("tracked_time", "issue", "tracked_time.issue_id=issue.id"); err != nil {
104-
logger.Critical("Error: %v whilst deleting orphaned objects")
104+
logger.Critical("Error: %v whilst deleting orphaned objects", err)
105105
return err
106106
}
107107
logger.Info("%d tracked times without existing issue deleted", count)
@@ -120,7 +120,7 @@ func checkDBConsistency(logger log.Logger, autofix bool) error {
120120
if autofix {
121121
updatedCount, err := models.FixNullArchivedRepository()
122122
if err != nil {
123-
logger.Critical("Error: %v whilst fixing null archived repositories")
123+
logger.Critical("Error: %v whilst fixing null archived repositories", err)
124124
return err
125125
}
126126
logger.Info("%d repositories with null is_archived updated", updatedCount)
@@ -139,7 +139,7 @@ func checkDBConsistency(logger log.Logger, autofix bool) error {
139139
if autofix {
140140
updatedCount, err := models.FixCommentTypeLabelWithEmptyLabel()
141141
if err != nil {
142-
logger.Critical("Error: %v whilst removing label comments with empty labels")
142+
logger.Critical("Error: %v whilst removing label comments with empty labels", err)
143143
return err
144144
}
145145
logger.Info("%d label comments with empty labels removed", updatedCount)
@@ -197,7 +197,7 @@ func checkDBConsistency(logger log.Logger, autofix bool) error {
197197
if autofix {
198198
err := models.FixBadSequences()
199199
if err != nil {
200-
logger.Critical("Error: %v whilst attempting to fix sequences")
200+
logger.Critical("Error: %v whilst attempting to fix sequences", err)
201201
return err
202202
}
203203
logger.Info("%d sequences updated", count)
@@ -207,6 +207,24 @@ func checkDBConsistency(logger log.Logger, autofix bool) error {
207207
}
208208
}
209209

210+
// find protected branches without existing repository
211+
count, err = models.CountOrphanedObjects("protected_branch", "repository", "protected_branch.repo_id=repository.id")
212+
if err != nil {
213+
logger.Critical("Error: %v whilst counting orphaned objects")
214+
return err
215+
}
216+
if count > 0 {
217+
if autofix {
218+
if err = models.DeleteOrphanedObjects("protected_branch", "repository", "protected_branch.repo_id=repository.id"); err != nil {
219+
logger.Critical("Error: %v whilst deleting orphaned objects", err)
220+
return err
221+
}
222+
logger.Info("%d protected branches without existing repository deleted", count)
223+
} else {
224+
logger.Warn("%d protected branches without existing repository", count)
225+
}
226+
}
227+
210228
return nil
211229
}
212230

routers/org/org.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,5 @@ func CreatePost(ctx *context.Context) {
7575
}
7676
log.Trace("Organization created: %s", org.Name)
7777

78-
ctx.Redirect(setting.AppSubURL + "/org/" + form.OrgName + "/dashboard")
78+
ctx.Redirect(org.DashboardLink())
7979
}

routers/repo/issue_label.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"code.gitea.io/gitea/modules/base"
1212
"code.gitea.io/gitea/modules/context"
1313
"code.gitea.io/gitea/modules/log"
14-
"code.gitea.io/gitea/modules/setting"
1514
"code.gitea.io/gitea/modules/web"
1615
"code.gitea.io/gitea/services/forms"
1716
issue_service "code.gitea.io/gitea/services/issue"
@@ -88,7 +87,7 @@ func RetrieveLabels(ctx *context.Context) {
8887
ctx.ServerError("org.IsOwnedBy", err)
8988
return
9089
}
91-
ctx.Org.OrgLink = setting.AppSubURL + "/org/" + org.LowerName
90+
ctx.Org.OrgLink = org.OrganisationLink()
9291
ctx.Data["IsOrganizationOwner"] = ctx.Org.IsOwner
9392
ctx.Data["OrganizationLink"] = ctx.Org.OrgLink
9493
}

routers/repo/migrate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func MigratePost(ctx *context.Context) {
234234

235235
err = task.MigrateRepository(ctx.User, ctxUser, opts)
236236
if err == nil {
237-
ctx.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + opts.RepoName)
237+
ctx.Redirect(ctxUser.HomeLink() + "/" + opts.RepoName)
238238
return
239239
}
240240

routers/repo/pull.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func ForkPost(ctx *context.Context) {
201201
}
202202
repo, has := models.HasForkedRepo(ctxUser.ID, traverseParentRepo.ID)
203203
if has {
204-
ctx.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + repo.Name)
204+
ctx.Redirect(ctxUser.HomeLink() + "/" + repo.Name)
205205
return
206206
}
207207
if !traverseParentRepo.IsFork {
@@ -243,7 +243,7 @@ func ForkPost(ctx *context.Context) {
243243
}
244244

245245
log.Trace("Repository forked[%d]: %s/%s", forkRepo.ID, ctxUser.Name, repo.Name)
246-
ctx.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + repo.Name)
246+
ctx.Redirect(ctxUser.HomeLink() + "/" + repo.Name)
247247
}
248248

249249
func checkPullInfo(ctx *context.Context) *models.Issue {

routers/repo/repo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func CreatePost(ctx *context.Context) {
240240
repo, err = repo_service.GenerateRepository(ctx.User, ctxUser, templateRepo, opts)
241241
if err == nil {
242242
log.Trace("Repository generated [%d]: %s/%s", repo.ID, ctxUser.Name, repo.Name)
243-
ctx.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + repo.Name)
243+
ctx.Redirect(ctxUser.HomeLink() + "/" + repo.Name)
244244
return
245245
}
246246
} else {
@@ -259,7 +259,7 @@ func CreatePost(ctx *context.Context) {
259259
})
260260
if err == nil {
261261
log.Trace("Repository created [%d]: %s/%s", repo.ID, ctxUser.Name, repo.Name)
262-
ctx.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + repo.Name)
262+
ctx.Redirect(ctxUser.HomeLink() + "/" + repo.Name)
263263
return
264264
}
265265
}

routers/repo/setting.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ func SettingsPost(ctx *context.Context) {
500500

501501
log.Trace("Repository transfer process was started: %s/%s -> %s", ctx.Repo.Owner.Name, repo.Name, newOwner)
502502
ctx.Flash.Success(ctx.Tr("repo.settings.transfer_started", newOwner.DisplayName()))
503-
ctx.Redirect(setting.AppSubURL + "/" + ctx.Repo.Owner.Name + "/" + repo.Name + "/settings")
503+
ctx.Redirect(ctx.Repo.Owner.HomeLink() + "/" + repo.Name + "/settings")
504504

505505
case "cancel_transfer":
506506
if !ctx.Repo.IsOwner() {
@@ -512,7 +512,7 @@ func SettingsPost(ctx *context.Context) {
512512
if err != nil {
513513
if models.IsErrNoPendingTransfer(err) {
514514
ctx.Flash.Error("repo.settings.transfer_abort_invalid")
515-
ctx.Redirect(setting.AppSubURL + "/" + ctx.User.Name + "/" + repo.Name + "/settings")
515+
ctx.Redirect(ctx.User.HomeLink() + "/" + repo.Name + "/settings")
516516
} else {
517517
ctx.ServerError("GetPendingRepositoryTransfer", err)
518518
}
@@ -532,7 +532,7 @@ func SettingsPost(ctx *context.Context) {
532532

533533
log.Trace("Repository transfer process was cancelled: %s/%s ", ctx.Repo.Owner.Name, repo.Name)
534534
ctx.Flash.Success(ctx.Tr("repo.settings.transfer_abort_success", repoTransfer.Recipient.Name))
535-
ctx.Redirect(setting.AppSubURL + "/" + ctx.Repo.Owner.Name + "/" + repo.Name + "/settings")
535+
ctx.Redirect(ctx.Repo.Owner.HomeLink() + "/" + repo.Name + "/settings")
536536

537537
case "delete":
538538
if !ctx.Repo.IsOwner() {

routers/routes/install.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ func InstallRoutes() *web.Route {
103103
&public.Options{
104104
Directory: path.Join(setting.StaticRootPath, "public"),
105105
SkipLogging: setting.DisableRouterLog,
106+
Prefix: "/assets",
106107
},
107108
))
108109

templates/admin/org/list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<td>{{.NumMembers}}</td>
4646
<td>{{.NumRepos}}</td>
4747
<td><span title="{{.CreatedUnix.FormatLong}}">{{.CreatedUnix.FormatShort}}</span></td>
48-
<td><a href="{{AppSubUrl}}/org/{{.Name}}/settings">{{svg "octicon-pencil"}}</a></td>
48+
<td><a href="{{.OrganisationLink}}/settings">{{svg "octicon-pencil"}}</a></td>
4949
</tr>
5050
{{end}}
5151
</tbody>

templates/repo/settings/lfs.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<h4 class="ui top attached header">
88
{{.i18n.Tr "repo.settings.lfs_filelist"}} ({{.i18n.Tr "admin.total" .Total}})
99
<div class="ui right">
10-
<a class="ui tiny show-panel button" href="{{.Link}}/locks"><span class="octicon-tiny">{{svg "octicon-lock"}}</span>{{.i18n.Tr "repo.settings.lfs_locks"}}</a>
11-
<a class="ui primary tiny show-panel button" href="{{.Link}}/pointers"><span class="octicon-tiny">{{svg "octicon-search"}}</span>&nbsp;{{.i18n.Tr "repo.settings.lfs_findpointerfiles"}}</a>
10+
<a class="ui tiny show-panel button" href="{{.Link}}/locks">{{.i18n.Tr "repo.settings.lfs_locks"}}</a>
11+
<a class="ui primary tiny show-panel button" href="{{.Link}}/pointers">&nbsp;{{.i18n.Tr "repo.settings.lfs_findpointerfiles"}}</a>
1212
</div>
1313
</h4>
1414
<table id="lfs-files-table" class="ui attached segment single line table">

0 commit comments

Comments
 (0)