diff --git a/models/repo/repo.go b/models/repo/repo.go
index eba41481aaf41..7d78cee2877d4 100644
--- a/models/repo/repo.go
+++ b/models/repo/repo.go
@@ -517,7 +517,7 @@ func (repo *Repository) composeCommonMetas(ctx context.Context) map[string]strin
func (repo *Repository) ComposeMetas(ctx context.Context) map[string]string {
metas := maps.Clone(repo.composeCommonMetas(ctx))
metas["markdownLineBreakStyle"] = "comment"
- metas["markdownAllowShortIssuePattern"] = "true"
+ metas["markupAllowShortIssuePattern"] = "true"
return metas
}
@@ -526,7 +526,7 @@ func (repo *Repository) ComposeWikiMetas(ctx context.Context) map[string]string
// does wiki need the "teams" and "org" from common metas?
metas := maps.Clone(repo.composeCommonMetas(ctx))
metas["markdownLineBreakStyle"] = "document"
- metas["markdownAllowShortIssuePattern"] = "true"
+ metas["markupAllowShortIssuePattern"] = "true"
return metas
}
diff --git a/models/repo/repo_test.go b/models/repo/repo_test.go
index ab8eb025cba36..6468e0f605889 100644
--- a/models/repo/repo_test.go
+++ b/models/repo/repo_test.go
@@ -1,13 +1,12 @@
// Copyright 2017 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package repo_test
+package repo
import (
"testing"
"code.gitea.io/gitea/models/db"
- repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unit"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
@@ -20,18 +19,18 @@ import (
)
var (
- countRepospts = repo_model.CountRepositoryOptions{OwnerID: 10}
- countReposptsPublic = repo_model.CountRepositoryOptions{OwnerID: 10, Private: optional.Some(false)}
- countReposptsPrivate = repo_model.CountRepositoryOptions{OwnerID: 10, Private: optional.Some(true)}
+ countRepospts = CountRepositoryOptions{OwnerID: 10}
+ countReposptsPublic = CountRepositoryOptions{OwnerID: 10, Private: optional.Some(false)}
+ countReposptsPrivate = CountRepositoryOptions{OwnerID: 10, Private: optional.Some(true)}
)
func TestGetRepositoryCount(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
ctx := db.DefaultContext
- count, err1 := repo_model.CountRepositories(ctx, countRepospts)
- privateCount, err2 := repo_model.CountRepositories(ctx, countReposptsPrivate)
- publicCount, err3 := repo_model.CountRepositories(ctx, countReposptsPublic)
+ count, err1 := CountRepositories(ctx, countRepospts)
+ privateCount, err2 := CountRepositories(ctx, countReposptsPrivate)
+ publicCount, err3 := CountRepositories(ctx, countReposptsPublic)
assert.NoError(t, err1)
assert.NoError(t, err2)
assert.NoError(t, err3)
@@ -42,7 +41,7 @@ func TestGetRepositoryCount(t *testing.T) {
func TestGetPublicRepositoryCount(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- count, err := repo_model.CountRepositories(db.DefaultContext, countReposptsPublic)
+ count, err := CountRepositories(db.DefaultContext, countReposptsPublic)
assert.NoError(t, err)
assert.Equal(t, int64(1), count)
}
@@ -50,14 +49,14 @@ func TestGetPublicRepositoryCount(t *testing.T) {
func TestGetPrivateRepositoryCount(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- count, err := repo_model.CountRepositories(db.DefaultContext, countReposptsPrivate)
+ count, err := CountRepositories(db.DefaultContext, countReposptsPrivate)
assert.NoError(t, err)
assert.Equal(t, int64(2), count)
}
func TestRepoAPIURL(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 10})
+ repo := unittest.AssertExistsAndLoadBean(t, &Repository{ID: 10})
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user12/repo10", repo.APIURL())
}
@@ -65,22 +64,22 @@ func TestRepoAPIURL(t *testing.T) {
func TestWatchRepo(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 3})
+ repo := unittest.AssertExistsAndLoadBean(t, &Repository{ID: 3})
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
- assert.NoError(t, repo_model.WatchRepo(db.DefaultContext, user, repo, true))
- unittest.AssertExistsAndLoadBean(t, &repo_model.Watch{RepoID: repo.ID, UserID: user.ID})
- unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: repo.ID})
+ assert.NoError(t, WatchRepo(db.DefaultContext, user, repo, true))
+ unittest.AssertExistsAndLoadBean(t, &Watch{RepoID: repo.ID, UserID: user.ID})
+ unittest.CheckConsistencyFor(t, &Repository{ID: repo.ID})
- assert.NoError(t, repo_model.WatchRepo(db.DefaultContext, user, repo, false))
- unittest.AssertNotExistsBean(t, &repo_model.Watch{RepoID: repo.ID, UserID: user.ID})
- unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: repo.ID})
+ assert.NoError(t, WatchRepo(db.DefaultContext, user, repo, false))
+ unittest.AssertNotExistsBean(t, &Watch{RepoID: repo.ID, UserID: user.ID})
+ unittest.CheckConsistencyFor(t, &Repository{ID: repo.ID})
}
func TestMetas(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- repo := &repo_model.Repository{Name: "testRepo"}
+ repo := &Repository{Name: "testRepo"}
repo.Owner = &user_model.User{Name: "testOwner"}
repo.OwnerName = repo.Owner.Name
@@ -90,15 +89,15 @@ func TestMetas(t *testing.T) {
assert.Equal(t, "testRepo", metas["repo"])
assert.Equal(t, "testOwner", metas["user"])
- externalTracker := repo_model.RepoUnit{
+ externalTracker := RepoUnit{
Type: unit.TypeExternalTracker,
- Config: &repo_model.ExternalTrackerConfig{
+ Config: &ExternalTrackerConfig{
ExternalTrackerFormat: "https://someurl.com/{user}/{repo}/{issue}",
},
}
testSuccess := func(expectedStyle string) {
- repo.Units = []*repo_model.RepoUnit{&externalTracker}
+ repo.Units = []*RepoUnit{&externalTracker}
repo.commonRenderingMetas = nil
metas := repo.ComposeMetas(db.DefaultContext)
assert.Equal(t, expectedStyle, metas["style"])
@@ -118,7 +117,7 @@ func TestMetas(t *testing.T) {
externalTracker.ExternalTrackerConfig().ExternalTrackerStyle = markup.IssueNameStyleRegexp
testSuccess(markup.IssueNameStyleRegexp)
- repo, err := repo_model.GetRepositoryByID(db.DefaultContext, 3)
+ repo, err := GetRepositoryByID(db.DefaultContext, 3)
assert.NoError(t, err)
metas = repo.ComposeMetas(db.DefaultContext)
@@ -132,7 +131,7 @@ func TestGetRepositoryByURL(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
t.Run("InvalidPath", func(t *testing.T) {
- repo, err := repo_model.GetRepositoryByURL(db.DefaultContext, "something")
+ repo, err := GetRepositoryByURL(db.DefaultContext, "something")
assert.Nil(t, repo)
assert.Error(t, err)
@@ -140,7 +139,7 @@ func TestGetRepositoryByURL(t *testing.T) {
t.Run("ValidHttpURL", func(t *testing.T) {
test := func(t *testing.T, url string) {
- repo, err := repo_model.GetRepositoryByURL(db.DefaultContext, url)
+ repo, err := GetRepositoryByURL(db.DefaultContext, url)
assert.NotNil(t, repo)
assert.NoError(t, err)
@@ -155,7 +154,7 @@ func TestGetRepositoryByURL(t *testing.T) {
t.Run("ValidGitSshURL", func(t *testing.T) {
test := func(t *testing.T, url string) {
- repo, err := repo_model.GetRepositoryByURL(db.DefaultContext, url)
+ repo, err := GetRepositoryByURL(db.DefaultContext, url)
assert.NotNil(t, repo)
assert.NoError(t, err)
@@ -173,7 +172,7 @@ func TestGetRepositoryByURL(t *testing.T) {
t.Run("ValidImplicitSshURL", func(t *testing.T) {
test := func(t *testing.T, url string) {
- repo, err := repo_model.GetRepositoryByURL(db.DefaultContext, url)
+ repo, err := GetRepositoryByURL(db.DefaultContext, url)
assert.NotNil(t, repo)
assert.NoError(t, err)
@@ -200,21 +199,21 @@ func TestComposeSSHCloneURL(t *testing.T) {
setting.SSH.Domain = "domain"
setting.SSH.Port = 22
setting.Repository.UseCompatSSHURI = false
- assert.Equal(t, "git@domain:user/repo.git", repo_model.ComposeSSHCloneURL("user", "repo"))
+ assert.Equal(t, "git@domain:user/repo.git", ComposeSSHCloneURL("user", "repo"))
setting.Repository.UseCompatSSHURI = true
- assert.Equal(t, "ssh://git@domain/user/repo.git", repo_model.ComposeSSHCloneURL("user", "repo"))
+ assert.Equal(t, "ssh://git@domain/user/repo.git", ComposeSSHCloneURL("user", "repo"))
// test SSH_DOMAIN while use non-standard SSH port
setting.SSH.Port = 123
setting.Repository.UseCompatSSHURI = false
- assert.Equal(t, "ssh://git@domain:123/user/repo.git", repo_model.ComposeSSHCloneURL("user", "repo"))
+ assert.Equal(t, "ssh://git@domain:123/user/repo.git", ComposeSSHCloneURL("user", "repo"))
setting.Repository.UseCompatSSHURI = true
- assert.Equal(t, "ssh://git@domain:123/user/repo.git", repo_model.ComposeSSHCloneURL("user", "repo"))
+ assert.Equal(t, "ssh://git@domain:123/user/repo.git", ComposeSSHCloneURL("user", "repo"))
// test IPv6 SSH_DOMAIN
setting.Repository.UseCompatSSHURI = false
setting.SSH.Domain = "::1"
setting.SSH.Port = 22
- assert.Equal(t, "git@[::1]:user/repo.git", repo_model.ComposeSSHCloneURL("user", "repo"))
+ assert.Equal(t, "git@[::1]:user/repo.git", ComposeSSHCloneURL("user", "repo"))
setting.SSH.Port = 123
- assert.Equal(t, "ssh://git@[::1]:123/user/repo.git", repo_model.ComposeSSHCloneURL("user", "repo"))
+ assert.Equal(t, "ssh://git@[::1]:123/user/repo.git", ComposeSSHCloneURL("user", "repo"))
}
diff --git a/modules/markup/html_internal_test.go b/modules/markup/html_internal_test.go
index b5bcb43e9c26d..8c44dcf827005 100644
--- a/modules/markup/html_internal_test.go
+++ b/modules/markup/html_internal_test.go
@@ -40,17 +40,19 @@ func link(href, class, contents string) string {
}
var numericMetas = map[string]string{
- "format": "https://someurl.com/{user}/{repo}/{index}",
- "user": "someUser",
- "repo": "someRepo",
- "style": IssueNameStyleNumeric,
+ "format": "https://someurl.com/{user}/{repo}/{index}",
+ "user": "someUser",
+ "repo": "someRepo",
+ "style": IssueNameStyleNumeric,
+ "markupAllowShortIssuePattern": "true",
}
var alphanumericMetas = map[string]string{
- "format": "https://someurl.com/{user}/{repo}/{index}",
- "user": "someUser",
- "repo": "someRepo",
- "style": IssueNameStyleAlphanumeric,
+ "format": "https://someurl.com/{user}/{repo}/{index}",
+ "user": "someUser",
+ "repo": "someRepo",
+ "style": IssueNameStyleAlphanumeric,
+ "markupAllowShortIssuePattern": "true",
}
var regexpMetas = map[string]string{
@@ -62,14 +64,15 @@ var regexpMetas = map[string]string{
// these values should match the TestOrgRepo const above
var localMetas = map[string]string{
- "user": "test-owner",
- "repo": "test-repo",
+ "user": "test-owner",
+ "repo": "test-repo",
+ "markupAllowShortIssuePattern": "true",
}
var localWikiMetas = map[string]string{
"user": "test-owner",
"repo": "test-repo",
- "renderContentMode": "wiki",
+ "markupContentMode": "wiki",
}
func TestRender_IssueIndexPattern(t *testing.T) {
diff --git a/modules/markup/html_issue.go b/modules/markup/html_issue.go
index 1dc36eed8d3b1..3a315268b6fb9 100644
--- a/modules/markup/html_issue.go
+++ b/modules/markup/html_issue.go
@@ -70,7 +70,7 @@ func issueIndexPatternProcessor(ctx *RenderContext, node *html.Node) {
// crossLinkOnly: do not parse "#123", only parse "owner/repo#123"
// if there is no repo in the context, then the "#123" format can't be parsed
// old logic: crossLinkOnly := ctx.Metas["mode"] == "document" && !ctx.IsWiki
- crossLinkOnly := ctx.Metas["markdownAllowShortIssuePattern"] != "true"
+ crossLinkOnly := ctx.Metas["markupAllowShortIssuePattern"] != "true"
var (
found bool
diff --git a/modules/markup/html_link.go b/modules/markup/html_link.go
index 2916385ad8456..1a7c5c8d92c13 100644
--- a/modules/markup/html_link.go
+++ b/modules/markup/html_link.go
@@ -20,7 +20,7 @@ func ResolveLink(ctx *RenderContext, link, userContentAnchorPrefix string) (resu
isAnchorFragment := link != "" && link[0] == '#'
if !isAnchorFragment && !IsFullURLString(link) {
linkBase := ctx.Links.Base
- if ctx.IsContentModeWiki() {
+ if ctx.IsMarkupContentWiki() {
// no need to check if the link should be resolved as a wiki link or a wiki raw link
// just use wiki link here, and it will be redirected to a wiki raw link if necessary
linkBase = ctx.Links.WikiLink()
@@ -147,7 +147,7 @@ func shortLinkProcessor(ctx *RenderContext, node *html.Node) {
}
if image {
if !absoluteLink {
- link = util.URLJoin(ctx.Links.ResolveMediaLink(ctx.IsContentModeWiki()), link)
+ link = util.URLJoin(ctx.Links.ResolveMediaLink(ctx.IsMarkupContentWiki()), link)
}
title := props["title"]
if title == "" {
diff --git a/modules/markup/html_node.go b/modules/markup/html_node.go
index 4bbaee9a447af..234adba2bfa8d 100644
--- a/modules/markup/html_node.go
+++ b/modules/markup/html_node.go
@@ -17,7 +17,7 @@ func visitNodeImg(ctx *RenderContext, img *html.Node) (next *html.Node) {
}
if IsNonEmptyRelativePath(attr.Val) {
- attr.Val = util.URLJoin(ctx.Links.ResolveMediaLink(ctx.IsContentModeWiki()), attr.Val)
+ attr.Val = util.URLJoin(ctx.Links.ResolveMediaLink(ctx.IsMarkupContentWiki()), attr.Val)
// By default, the "" tag should also be clickable,
// because frontend use `` to paste the re-scaled image into the markdown,
@@ -53,7 +53,7 @@ func visitNodeVideo(ctx *RenderContext, node *html.Node) (next *html.Node) {
continue
}
if IsNonEmptyRelativePath(attr.Val) {
- attr.Val = util.URLJoin(ctx.Links.ResolveMediaLink(ctx.IsContentModeWiki()), attr.Val)
+ attr.Val = util.URLJoin(ctx.Links.ResolveMediaLink(ctx.IsMarkupContentWiki()), attr.Val)
}
attr.Val = camoHandleLink(attr.Val)
node.Attr[i] = attr
diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go
index 4d97db509d3b7..67ac2758a31fb 100644
--- a/modules/markup/html_test.go
+++ b/modules/markup/html_test.go
@@ -30,7 +30,7 @@ var (
localWikiMetas = map[string]string{
"user": testRepoOwnerName,
"repo": testRepoName,
- "renderContentMode": "wiki",
+ "markupContentMode": "wiki",
}
)
@@ -532,7 +532,7 @@ func TestRender_RelativeMedias(t *testing.T) {
buffer, err := markdown.RenderString(&markup.RenderContext{
Ctx: git.DefaultContext,
Links: links,
- Metas: util.Iif(isWiki, localMetas, localWikiMetas),
+ Metas: util.Iif(isWiki, localWikiMetas, localMetas),
}, input)
assert.NoError(t, err)
return strings.TrimSpace(string(buffer))
diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go
index 4e9a3e7e7371b..780df8727f0c8 100644
--- a/modules/markup/markdown/markdown_test.go
+++ b/modules/markup/markdown/markdown_test.go
@@ -40,7 +40,7 @@ var localMetas = map[string]string{
var localWikiMetas = map[string]string{
"user": testRepoOwnerName,
"repo": testRepoName,
- "renderContentMode": "wiki",
+ "markupContentMode": "wiki",
}
type mockRepo struct {
@@ -662,9 +662,9 @@ mail@domain.com
-https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
+88fc37a3c0...12fc37a3c0 (hash)
com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
-https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
+88fc37a3c0
com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
👍
mail@domain.com
@@ -689,9 +689,9 @@ space
88fc37a3c0...12fc37a3c0 (hash)
88fc37a3c0
88fc37a3c0...12fc37a3c0 (hash)
88fc37a3c0
88fc37a3c0...12fc37a3c0 (hash)
88fc37a3c0
88fc37a3c0...12fc37a3c0 (hash)
88fc37a3c0
88fc37a3c0...12fc37a3c0 (hash)
88fc37a3c0
88fc37a3c0...12fc37a3c0 (hash)
88fc37a3c0
88fc37a3c0...12fc37a3c0 (hash)
88fc37a3c0
88fc37a3c0...12fc37a3c0 (hash)
88fc37a3c0
88fc37a3c0...12fc37a3c0 (hash)
88fc37a3c0
88fc37a3c0...12fc37a3c0 (hash)
88fc37a3c0
88fc37a3c0...12fc37a3c0 (hash)
88fc37a3c0