diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini
index d3e1920a10..7431630b13 100644
--- a/custom/conf/app.example.ini
+++ b/custom/conf/app.example.ini
@@ -806,6 +806,11 @@ LEVEL = Info
;; Every new user will have restricted permissions depending on this setting
;DEFAULT_USER_IS_RESTRICTED = false
;;
+;; Users will be able to use dots when choosing their username. Disabling this is
+;; helpful if your usersare having issues with e.g. RSS feeds or advanced third-party
+;; extensions that use strange regex patterns.
+; ALLOW_DOTS_IN_USERNAMES = true
+;;
;; Either "public", "limited" or "private", default is "public"
;; Limited is for users visible only to signed users
;; Private is for users visible only to members of their organizations
@@ -1762,9 +1767,6 @@ LEVEL = Info
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
-;AVATAR_UPLOAD_PATH = data/avatars
-;REPOSITORY_AVATAR_UPLOAD_PATH = data/repo-avatars
-;;
;; How Gitea deals with missing repository avatars
;; none = no avatar will be displayed; random = random avatar will be displayed; image = default image will be used
;REPOSITORY_AVATAR_FALLBACK = none
diff --git a/models/auth/token_scope.go b/models/auth/token_scope.go
index fe57276700..003ca5c9ab 100644
--- a/models/auth/token_scope.go
+++ b/models/auth/token_scope.go
@@ -250,7 +250,7 @@ func (s AccessTokenScope) parse() (accessTokenScopeBitmap, error) {
remainingScopes = remainingScopes[i+1:]
}
singleScope := AccessTokenScope(v)
- if singleScope == "" {
+ if singleScope == "" || singleScope == "sudo" {
continue
}
if singleScope == AccessTokenScopeAll {
diff --git a/models/auth/token_scope_test.go b/models/auth/token_scope_test.go
index a6097e45d7..d11c5e6a3d 100644
--- a/models/auth/token_scope_test.go
+++ b/models/auth/token_scope_test.go
@@ -20,7 +20,7 @@ func TestAccessTokenScope_Normalize(t *testing.T) {
tests := []scopeTestNormalize{
{"", "", nil},
{"write:misc,write:notification,read:package,write:notification,public-only", "public-only,write:misc,write:notification,read:package", nil},
- {"all", "all", nil},
+ {"all,sudo", "all", nil},
{"write:activitypub,write:admin,write:misc,write:notification,write:organization,write:package,write:issue,write:repository,write:user", "all", nil},
{"write:activitypub,write:admin,write:misc,write:notification,write:organization,write:package,write:issue,write:repository,write:user,public-only", "public-only,all", nil},
}
diff --git a/models/db/engine.go b/models/db/engine.go
index b5a41f93e3..0fcd4849bf 100755
--- a/models/db/engine.go
+++ b/models/db/engine.go
@@ -11,10 +11,13 @@ import (
"io"
"reflect"
"strings"
+ "time"
+ "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"xorm.io/xorm"
+ "xorm.io/xorm/contexts"
"xorm.io/xorm/names"
"xorm.io/xorm/schemas"
@@ -147,6 +150,13 @@ func InitEngine(ctx context.Context) error {
xormEngine.SetConnMaxLifetime(setting.Database.ConnMaxLifetime)
xormEngine.SetDefaultContext(ctx)
+ if setting.Database.SlowQueryTreshold > 0 {
+ xormEngine.AddHook(&SlowQueryHook{
+ Treshold: setting.Database.SlowQueryTreshold,
+ Logger: log.GetLogger("xorm"),
+ })
+ }
+
SetDefaultEngine(ctx, xormEngine)
return nil
}
@@ -300,3 +310,21 @@ func SetLogSQL(ctx context.Context, on bool) {
sess.Engine().ShowSQL(on)
}
}
+
+type SlowQueryHook struct {
+ Treshold time.Duration
+ Logger log.Logger
+}
+
+var _ contexts.Hook = &SlowQueryHook{}
+
+func (SlowQueryHook) BeforeProcess(c *contexts.ContextHook) (context.Context, error) {
+ return c.Ctx, nil
+}
+
+func (h *SlowQueryHook) AfterProcess(c *contexts.ContextHook) error {
+ if c.ExecuteTime >= h.Treshold {
+ h.Logger.Log(8, log.WARN, "[Slow SQL Query] %s %v - %v", c.SQL, c.Args, c.ExecuteTime)
+ }
+ return nil
+}
diff --git a/models/db/engine_test.go b/models/db/engine_test.go
index c9ae5f1542..ba922821b0 100644
--- a/models/db/engine_test.go
+++ b/models/db/engine_test.go
@@ -6,15 +6,19 @@ package db_test
import (
"path/filepath"
"testing"
+ "time"
"code.gitea.io/gitea/models/db"
issues_model "code.gitea.io/gitea/models/issues"
"code.gitea.io/gitea/models/unittest"
+ "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
+ "code.gitea.io/gitea/modules/test"
_ "code.gitea.io/gitea/cmd" // for TestPrimaryKeys
"github.com/stretchr/testify/assert"
+ "xorm.io/xorm"
)
func TestDumpDatabase(t *testing.T) {
@@ -85,3 +89,37 @@ func TestPrimaryKeys(t *testing.T) {
}
}
}
+
+func TestSlowQuery(t *testing.T) {
+ lc, cleanup := test.NewLogChecker("slow-query")
+ lc.StopMark("[Slow SQL Query]")
+ defer cleanup()
+
+ e := db.GetEngine(db.DefaultContext)
+ engine, ok := e.(*xorm.Engine)
+ assert.True(t, ok)
+
+ // It's not possible to clean this up with XORM, but it's luckily not harmful
+ // to leave around.
+ engine.AddHook(&db.SlowQueryHook{
+ Treshold: time.Second * 10,
+ Logger: log.GetLogger("slow-query"),
+ })
+
+ // NOOP query.
+ e.Exec("SELECT 1 WHERE false;")
+
+ _, stopped := lc.Check(100 * time.Millisecond)
+ assert.False(t, stopped)
+
+ engine.AddHook(&db.SlowQueryHook{
+ Treshold: 0, // Every query should be logged.
+ Logger: log.GetLogger("slow-query"),
+ })
+
+ // NOOP query.
+ e.Exec("SELECT 1 WHERE false;")
+
+ _, stopped = lc.Check(100 * time.Millisecond)
+ assert.True(t, stopped)
+}
diff --git a/models/fixtures/release.yml b/models/fixtures/release.yml
index 4ed7df440d..844deb3a7b 100644
--- a/models/fixtures/release.yml
+++ b/models/fixtures/release.yml
@@ -136,3 +136,17 @@
is_prerelease: false
is_tag: false
created_unix: 946684803
+
+- id: 11
+ repo_id: 59
+ publisher_id: 2
+ tag_name: "v1.0"
+ lower_tag_name: "v1.0"
+ target: "main"
+ title: "v1.0"
+ sha1: "d8f53dfb33f6ccf4169c34970b5e747511c18beb"
+ num_commits: 1
+ is_draft: false
+ is_prerelease: false
+ is_tag: false
+ created_unix: 946684803
diff --git a/models/fixtures/repo_unit.yml b/models/fixtures/repo_unit.yml
index c22eb8c2a2..6afef2a432 100644
--- a/models/fixtures/repo_unit.yml
+++ b/models/fixtures/repo_unit.yml
@@ -608,6 +608,38 @@
type: 1
created_unix: 946684810
+# BEGIN Forgejo [GITEA] Improve HTML title on repositories
+-
+ id: 1093
+ repo_id: 59
+ type: 1
+ created_unix: 946684810
+
+-
+ id: 1094
+ repo_id: 59
+ type: 2
+ created_unix: 946684810
+
+-
+ id: 1095
+ repo_id: 59
+ type: 3
+ created_unix: 946684810
+
+-
+ id: 1096
+ repo_id: 59
+ type: 4
+ created_unix: 946684810
+
+-
+ id: 1097
+ repo_id: 59
+ type: 5
+ created_unix: 946684810
+# END Forgejo [GITEA] Improve HTML title on repositories
+
-
id: 91
repo_id: 58
diff --git a/models/fixtures/repository.yml b/models/fixtures/repository.yml
index 7faba424b6..a7ef741ac1 100644
--- a/models/fixtures/repository.yml
+++ b/models/fixtures/repository.yml
@@ -1467,6 +1467,7 @@
owner_name: user27
lower_name: repo49
name: repo49
+ description: A wonderful repository with more than just a README.md
default_branch: master
num_watches: 0
num_stars: 0
@@ -1693,3 +1694,16 @@
size: 0
is_fsck_enabled: true
close_issues_via_commit_in_any_branch: false
+
+-
+ id: 59
+ owner_id: 2
+ owner_name: user2
+ lower_name: repo59
+ name: repo59
+ default_branch: master
+ is_empty: false
+ is_archived: false
+ is_private: false
+ status: 0
+ num_issues: 0
diff --git a/models/fixtures/user.yml b/models/fixtures/user.yml
index f24d098a7e..c0d3051079 100644
--- a/models/fixtures/user.yml
+++ b/models/fixtures/user.yml
@@ -66,7 +66,7 @@
num_followers: 2
num_following: 1
num_stars: 2
- num_repos: 14
+ num_repos: 15
num_teams: 0
num_members: 0
visibility: 0
diff --git a/models/repo/repo_list_test.go b/models/repo/repo_list_test.go
index 7097b6ea14..3be1ebb3c9 100644
--- a/models/repo/repo_list_test.go
+++ b/models/repo/repo_list_test.go
@@ -138,12 +138,12 @@ func getTestCases() []struct {
{
name: "AllPublic/PublicRepositoriesOfUserIncludingCollaborative",
opts: &repo_model.SearchRepoOptions{ListOptions: db.ListOptions{Page: 1, PageSize: 10}, OwnerID: 15, AllPublic: true, Template: util.OptionalBoolFalse},
- count: 31,
+ count: 32,
},
{
name: "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborative",
opts: &repo_model.SearchRepoOptions{ListOptions: db.ListOptions{Page: 1, PageSize: 10}, OwnerID: 15, Private: true, AllPublic: true, AllLimited: true, Template: util.OptionalBoolFalse},
- count: 36,
+ count: 37,
},
{
name: "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborativeByName",
@@ -158,7 +158,7 @@ func getTestCases() []struct {
{
name: "AllPublic/PublicRepositoriesOfOrganization",
opts: &repo_model.SearchRepoOptions{ListOptions: db.ListOptions{Page: 1, PageSize: 10}, OwnerID: 17, AllPublic: true, Collaborate: util.OptionalBoolFalse, Template: util.OptionalBoolFalse},
- count: 31,
+ count: 32,
},
{
name: "AllTemplates",
diff --git a/modules/markup/orgmode/orgmode.go b/modules/markup/orgmode/orgmode.go
index a6dac12039..7a95ab518c 100644
--- a/modules/markup/orgmode/orgmode.go
+++ b/modules/markup/orgmode/orgmode.go
@@ -153,18 +153,30 @@ func (r *Writer) WriteRegularLink(l org.RegularLink) {
link = []byte(util.URLJoin(r.URLPrefix, lnk))
}
- description := string(link)
- if l.Description != nil {
- description = r.WriteNodesAsString(l.Description...)
- }
switch l.Kind() {
case "image":
- imageSrc := getMediaURL(link)
- fmt.Fprintf(r, ``, imageSrc, description, description)
+ if l.Description == nil {
+ imageSrc := getMediaURL(link)
+ fmt.Fprintf(r, `
`, imageSrc, link, link)
+ } else {
+ description := strings.TrimPrefix(org.String(l.Description...), "file:")
+ imageSrc := getMediaURL([]byte(description))
+ fmt.Fprintf(r, `
`, link, imageSrc, imageSrc)
+ }
case "video":
- videoSrc := getMediaURL(link)
- fmt.Fprintf(r, ``, videoSrc, description, description)
+ if l.Description == nil {
+ imageSrc := getMediaURL(link)
+ fmt.Fprintf(r, ``, imageSrc, link, link)
+ } else {
+ description := strings.TrimPrefix(org.String(l.Description...), "file:")
+ videoSrc := getMediaURL([]byte(description))
+ fmt.Fprintf(r, ``, link, videoSrc, videoSrc)
+ }
default:
+ description := string(link)
+ if l.Description != nil {
+ description = r.WriteNodesAsString(l.Description...)
+ }
fmt.Fprintf(r, `%s`, link, description, description)
}
}
diff --git a/modules/markup/orgmode/orgmode_test.go b/modules/markup/orgmode/orgmode_test.go
index d6467c36f7..8f454e9955 100644
--- a/modules/markup/orgmode/orgmode_test.go
+++ b/modules/markup/orgmode/orgmode_test.go
@@ -42,7 +42,7 @@ func TestRender_StandardLinks(t *testing.T) {
"