Skip to content

Commit 0d609b5

Browse files
authored
Merge branch 'master' into refactor-test-ini
2 parents b98d5c9 + 67e1039 commit 0d609b5

Some content is hidden

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

42 files changed

+306
-121
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

integrations/links_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestRedirectsNoLogin(t *testing.T) {
5151
"/user2/repo1/src/master": "/user2/repo1/src/branch/master",
5252
"/user2/repo1/src/master/file.txt": "/user2/repo1/src/branch/master/file.txt",
5353
"/user2/repo1/src/master/directory/file.txt": "/user2/repo1/src/branch/master/directory/file.txt",
54-
"/user/avatar/Ghost/-1": "/img/avatar_default.png",
54+
"/user/avatar/Ghost/-1": "/assets/img/avatar_default.png",
5555
"/api/v1/swagger": "/api/swagger",
5656
}
5757
for link, redirectLink := range redirects {

models/avatar.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func DefaultAvatarLink() string {
3232
return ""
3333
}
3434

35-
u.Path = path.Join(u.Path, "/img/avatar_default.png")
35+
u.Path = path.Join(u.Path, "/assets/img/avatar_default.png")
3636
return u.String()
3737
}
3838

models/avatar_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestHashEmail(t *testing.T) {
4141

4242
func TestSizedAvatarLink(t *testing.T) {
4343
disableGravatar()
44-
assert.Equal(t, "/suburl/img/avatar_default.png",
44+
assert.Equal(t, "/suburl/assets/img/avatar_default.png",
4545
SizedAvatarLink("[email protected]", 100))
4646

4747
enableGravatar(t)

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/oauth2.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ type OAuth2Provider struct {
2323
// key is used to map the OAuth2Provider with the goth provider type (also in LoginSource.OAuth2Config.Provider)
2424
// value is used to store display data
2525
var OAuth2Providers = map[string]OAuth2Provider{
26-
"bitbucket": {Name: "bitbucket", DisplayName: "Bitbucket", Image: "/img/auth/bitbucket.png"},
27-
"dropbox": {Name: "dropbox", DisplayName: "Dropbox", Image: "/img/auth/dropbox.png"},
28-
"facebook": {Name: "facebook", DisplayName: "Facebook", Image: "/img/auth/facebook.png"},
26+
"bitbucket": {Name: "bitbucket", DisplayName: "Bitbucket", Image: "/assets/img/auth/bitbucket.png"},
27+
"dropbox": {Name: "dropbox", DisplayName: "Dropbox", Image: "/assets/img/auth/dropbox.png"},
28+
"facebook": {Name: "facebook", DisplayName: "Facebook", Image: "/assets/img/auth/facebook.png"},
2929
"github": {
30-
Name: "github", DisplayName: "GitHub", Image: "/img/auth/github.png",
30+
Name: "github", DisplayName: "GitHub", Image: "/assets/img/auth/github.png",
3131
CustomURLMapping: &oauth2.CustomURLMapping{
3232
TokenURL: oauth2.GetDefaultTokenURL("github"),
3333
AuthURL: oauth2.GetDefaultAuthURL("github"),
@@ -36,36 +36,36 @@ var OAuth2Providers = map[string]OAuth2Provider{
3636
},
3737
},
3838
"gitlab": {
39-
Name: "gitlab", DisplayName: "GitLab", Image: "/img/auth/gitlab.png",
39+
Name: "gitlab", DisplayName: "GitLab", Image: "/assets/img/auth/gitlab.png",
4040
CustomURLMapping: &oauth2.CustomURLMapping{
4141
TokenURL: oauth2.GetDefaultTokenURL("gitlab"),
4242
AuthURL: oauth2.GetDefaultAuthURL("gitlab"),
4343
ProfileURL: oauth2.GetDefaultProfileURL("gitlab"),
4444
},
4545
},
46-
"gplus": {Name: "gplus", DisplayName: "Google", Image: "/img/auth/google.png"},
47-
"openidConnect": {Name: "openidConnect", DisplayName: "OpenID Connect", Image: "/img/auth/openid_connect.svg"},
48-
"twitter": {Name: "twitter", DisplayName: "Twitter", Image: "/img/auth/twitter.png"},
49-
"discord": {Name: "discord", DisplayName: "Discord", Image: "/img/auth/discord.png"},
46+
"gplus": {Name: "gplus", DisplayName: "Google", Image: "/assets/img/auth/google.png"},
47+
"openidConnect": {Name: "openidConnect", DisplayName: "OpenID Connect", Image: "/assets/img/auth/openid_connect.svg"},
48+
"twitter": {Name: "twitter", DisplayName: "Twitter", Image: "/assets/img/auth/twitter.png"},
49+
"discord": {Name: "discord", DisplayName: "Discord", Image: "/assets/img/auth/discord.png"},
5050
"gitea": {
51-
Name: "gitea", DisplayName: "Gitea", Image: "/img/auth/gitea.png",
51+
Name: "gitea", DisplayName: "Gitea", Image: "/assets/img/auth/gitea.png",
5252
CustomURLMapping: &oauth2.CustomURLMapping{
5353
TokenURL: oauth2.GetDefaultTokenURL("gitea"),
5454
AuthURL: oauth2.GetDefaultAuthURL("gitea"),
5555
ProfileURL: oauth2.GetDefaultProfileURL("gitea"),
5656
},
5757
},
5858
"nextcloud": {
59-
Name: "nextcloud", DisplayName: "Nextcloud", Image: "/img/auth/nextcloud.png",
59+
Name: "nextcloud", DisplayName: "Nextcloud", Image: "/assets/img/auth/nextcloud.png",
6060
CustomURLMapping: &oauth2.CustomURLMapping{
6161
TokenURL: oauth2.GetDefaultTokenURL("nextcloud"),
6262
AuthURL: oauth2.GetDefaultAuthURL("nextcloud"),
6363
ProfileURL: oauth2.GetDefaultProfileURL("nextcloud"),
6464
},
6565
},
66-
"yandex": {Name: "yandex", DisplayName: "Yandex", Image: "/img/auth/yandex.png"},
66+
"yandex": {Name: "yandex", DisplayName: "Yandex", Image: "/assets/img/auth/yandex.png"},
6767
"mastodon": {
68-
Name: "mastodon", DisplayName: "Mastodon", Image: "/img/auth/mastodon.png",
68+
Name: "mastodon", DisplayName: "Mastodon", Image: "/assets/img/auth/mastodon.png",
6969
CustomURLMapping: &oauth2.CustomURLMapping{
7070
AuthURL: oauth2.GetDefaultAuthURL("mastodon"),
7171
},

models/repo.go

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ func (repo *Repository) updateSize(e Engine) error {
747747
}
748748

749749
repo.Size = size + lfsSize
750-
_, err = e.ID(repo.ID).Cols("size").Update(repo)
750+
_, err = e.ID(repo.ID).Cols("size").NoAutoTime().Update(repo)
751751
return err
752752
}
753753

@@ -1455,23 +1455,26 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
14551455
if err := deleteBeans(sess,
14561456
&Access{RepoID: repo.ID},
14571457
&Action{RepoID: repo.ID},
1458-
&Watch{RepoID: repoID},
1459-
&Star{RepoID: repoID},
1460-
&Mirror{RepoID: repoID},
1461-
&Milestone{RepoID: repoID},
1462-
&Release{RepoID: repoID},
14631458
&Collaboration{RepoID: repoID},
1464-
&PullRequest{BaseRepoID: repoID},
1465-
&RepoUnit{RepoID: repoID},
1466-
&RepoRedirect{RedirectRepoID: repoID},
1467-
&Webhook{RepoID: repoID},
1459+
&Comment{RefRepoID: repoID},
1460+
&CommitStatus{RepoID: repoID},
1461+
&DeletedBranch{RepoID: repoID},
14681462
&HookTask{RepoID: repoID},
1463+
&LFSLock{RepoID: repoID},
1464+
&LanguageStat{RepoID: repoID},
1465+
&Milestone{RepoID: repoID},
1466+
&Mirror{RepoID: repoID},
14691467
&Notification{RepoID: repoID},
1470-
&CommitStatus{RepoID: repoID},
1468+
&ProtectedBranch{RepoID: repoID},
1469+
&PullRequest{BaseRepoID: repoID},
1470+
&Release{RepoID: repoID},
14711471
&RepoIndexerStatus{RepoID: repoID},
1472-
&LanguageStat{RepoID: repoID},
1473-
&Comment{RefRepoID: repoID},
1472+
&RepoRedirect{RedirectRepoID: repoID},
1473+
&RepoUnit{RepoID: repoID},
1474+
&Star{RepoID: repoID},
14741475
&Task{RepoID: repoID},
1476+
&Watch{RepoID: repoID},
1477+
&Webhook{RepoID: repoID},
14751478
); err != nil {
14761479
return fmt.Errorf("deleteBeans: %v", err)
14771480
}
@@ -1487,10 +1490,6 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
14871490
return err
14881491
}
14891492

1490-
if _, err := sess.Where("repo_id = ?", repoID).Delete(new(RepoUnit)); err != nil {
1491-
return err
1492-
}
1493-
14941493
if repo.IsFork {
14951494
if _, err := sess.Exec("UPDATE `repository` SET num_forks=num_forks-1 WHERE id=?", repo.ForkID); err != nil {
14961495
return fmt.Errorf("decrease fork count: %v", err)

models/user.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"code.gitea.io/gitea/modules/generate"
2626
"code.gitea.io/gitea/modules/git"
2727
"code.gitea.io/gitea/modules/log"
28-
"code.gitea.io/gitea/modules/public"
2928
"code.gitea.io/gitea/modules/setting"
3029
"code.gitea.io/gitea/modules/storage"
3130
"code.gitea.io/gitea/modules/structs"
@@ -302,7 +301,7 @@ func (u *User) CanImportLocal() bool {
302301
// DashboardLink returns the user dashboard page link.
303302
func (u *User) DashboardLink() string {
304303
if u.IsOrganization() {
305-
return setting.AppSubURL + "/org/" + u.Name + "/dashboard/"
304+
return u.OrganisationLink() + "/dashboard/"
306305
}
307306
return setting.AppSubURL + "/"
308307
}
@@ -317,6 +316,11 @@ func (u *User) HTMLURL() string {
317316
return setting.AppURL + u.Name
318317
}
319318

319+
// OrganisationLink returns the organization sub page link.
320+
func (u *User) OrganisationLink() string {
321+
return setting.AppSubURL + "/org/" + u.Name
322+
}
323+
320324
// GenerateEmailActivateCode generates an activate code based on user information and given e-mail.
321325
func (u *User) GenerateEmailActivateCode(email string) string {
322326
code := base.CreateTimeLimitCode(
@@ -772,7 +776,7 @@ func (u *User) IsGhost() bool {
772776
}
773777

774778
var (
775-
reservedUsernames = append([]string{
779+
reservedUsernames = []string{
776780
".",
777781
"..",
778782
".well-known",
@@ -807,7 +811,8 @@ var (
807811
"stars",
808812
"template",
809813
"user",
810-
}, public.KnownPublicEntries...)
814+
"favicon.ico",
815+
}
811816

812817
reservedUserPatterns = []string{"*.keys", "*.gpg"}
813818
)

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/convert/user.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,16 @@ func ToUserWithAccessMode(user *models.User, accessMode models.AccessMode) *api.
3838
// signed shall only be set if requester is logged in. authed shall only be set if user is site admin or user himself
3939
func toUser(user *models.User, signed, authed bool) *api.User {
4040
result := &api.User{
41-
ID: user.ID,
42-
UserName: user.Name,
43-
FullName: markup.Sanitize(user.FullName),
44-
Email: user.GetEmail(),
45-
AvatarURL: user.AvatarLink(),
46-
Created: user.CreatedUnix.AsTime(),
47-
Restricted: user.IsRestricted,
41+
ID: user.ID,
42+
UserName: user.Name,
43+
FullName: markup.Sanitize(user.FullName),
44+
Email: user.GetEmail(),
45+
AvatarURL: user.AvatarLink(),
46+
Created: user.CreatedUnix.AsTime(),
47+
Restricted: user.IsRestricted,
48+
Location: user.Location,
49+
Website: user.Website,
50+
Description: user.Description,
4851
}
4952
// hide primary email if API caller is anonymous or user keep email private
5053
if signed && (!user.KeepEmailPrivate || authed) {

0 commit comments

Comments
 (0)