Upgrade to golangci-lint@v1.55.0 (#27756)
https://github.com/golangci/golangci-lint/releases/tag/v1.55.0
This commit is contained in:
parent
def907de7b
commit
ce83609ff6
2
Makefile
2
Makefile
|
@ -28,7 +28,7 @@ XGO_VERSION := go-1.21.x
|
||||||
AIR_PACKAGE ?= github.com/cosmtrek/air@v1.44.0
|
AIR_PACKAGE ?= github.com/cosmtrek/air@v1.44.0
|
||||||
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.7.0
|
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.7.0
|
||||||
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.5.0
|
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.5.0
|
||||||
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.1
|
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.0
|
||||||
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11
|
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11
|
||||||
MISSPELL_PACKAGE ?= github.com/client9/misspell/cmd/misspell@v0.3.4
|
MISSPELL_PACKAGE ?= github.com/client9/misspell/cmd/misspell@v0.3.4
|
||||||
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.30.5
|
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.30.5
|
||||||
|
|
|
@ -279,7 +279,7 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
|
||||||
return nil, false, fmt.Errorf("parse workflow of job %d: %w", job.ID, err)
|
return nil, false, fmt.Errorf("parse workflow of job %d: %w", job.ID, err)
|
||||||
} else if len(gots) != 1 {
|
} else if len(gots) != 1 {
|
||||||
return nil, false, fmt.Errorf("workflow of job %d: not single workflow", job.ID)
|
return nil, false, fmt.Errorf("workflow of job %d: not single workflow", job.ID)
|
||||||
} else {
|
} else { //nolint:revive
|
||||||
_, workflowJob = gots[0].Job()
|
_, workflowJob = gots[0].Job()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -713,9 +713,8 @@ func DeleteIssueActions(ctx context.Context, repoID, issueID, issueIndex int64)
|
||||||
break
|
break
|
||||||
} else if _, err = db.GetEngine(ctx).In("comment_id", commentIDs).Delete(&Action{}); err != nil {
|
} else if _, err = db.GetEngine(ctx).In("comment_id", commentIDs).Delete(&Action{}); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
|
||||||
lastCommentID = commentIDs[len(commentIDs)-1]
|
|
||||||
}
|
}
|
||||||
|
lastCommentID = commentIDs[len(commentIDs)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := e.Where("repo_id = ?", repoID).
|
_, err := e.Where("repo_id = ?", repoID).
|
||||||
|
|
|
@ -213,9 +213,8 @@ func GetReviewByID(ctx context.Context, id int64) (*Review, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrReviewNotExist{ID: id}
|
return nil, ErrReviewNotExist{ID: id}
|
||||||
} else {
|
|
||||||
return review, nil
|
|
||||||
}
|
}
|
||||||
|
return review, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateReviewOptions represent the options to create a review. Type, Issue and Reviewer are required.
|
// CreateReviewOptions represent the options to create a review. Type, Issue and Reviewer are required.
|
||||||
|
|
|
@ -29,11 +29,10 @@ func GetKeyPair(ctx context.Context, user *user_model.User) (pub, priv string, e
|
||||||
return pub, priv, err
|
return pub, priv, err
|
||||||
}
|
}
|
||||||
return pub, priv, err
|
return pub, priv, err
|
||||||
} else {
|
|
||||||
priv = settings[user_model.UserActivityPubPrivPem].SettingValue
|
|
||||||
pub = settings[user_model.UserActivityPubPubPem].SettingValue
|
|
||||||
return pub, priv, err
|
|
||||||
}
|
}
|
||||||
|
priv = settings[user_model.UserActivityPubPrivPem].SettingValue
|
||||||
|
pub = settings[user_model.UserActivityPubPubPem].SettingValue
|
||||||
|
return pub, priv, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPublicKey function returns a user's public key
|
// GetPublicKey function returns a user's public key
|
||||||
|
|
|
@ -101,9 +101,8 @@ func getRefURL(refURL, urlPrefix, repoFullName, sshDomain string) string {
|
||||||
return ref.Scheme + "://" + ref.Host + ref.Path
|
return ref.Scheme + "://" + ref.Host + ref.Path
|
||||||
} else if urlPrefixHostname == refHostname || refHostname == sshDomain {
|
} else if urlPrefixHostname == refHostname || refHostname == sshDomain {
|
||||||
return urlPrefix + path.Clean(path.Join("/", ref.Path))
|
return urlPrefix + path.Clean(path.Join("/", ref.Path))
|
||||||
} else {
|
|
||||||
return "http://" + refHostname + ref.Path
|
|
||||||
}
|
}
|
||||||
|
return "http://" + refHostname + ref.Path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,10 +62,9 @@ func TestBasicTransferAdapter(t *testing.T) {
|
||||||
json.NewEncoder(payload).Encode(er)
|
json.NewEncoder(payload).Encode(er)
|
||||||
|
|
||||||
return &http.Response{StatusCode: http.StatusNotFound, Body: io.NopCloser(payload)}
|
return &http.Response{StatusCode: http.StatusNotFound, Body: io.NopCloser(payload)}
|
||||||
} else {
|
|
||||||
t.Errorf("Unknown test case: %s", url)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
t.Errorf("Unknown test case: %s", url)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
hc := &http.Client{Transport: RoundTripFunc(roundTripHandler)}
|
hc := &http.Client{Transport: RoundTripFunc(roundTripHandler)}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/emoji"
|
"code.gitea.io/gitea/modules/emoji"
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
. "code.gitea.io/gitea/modules/markup"
|
"code.gitea.io/gitea/modules/markup"
|
||||||
"code.gitea.io/gitea/modules/markup/markdown"
|
"code.gitea.io/gitea/modules/markup/markdown"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/modules/util"
|
"code.gitea.io/gitea/modules/util"
|
||||||
|
@ -37,12 +37,12 @@ func TestMain(m *testing.M) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRender_Commits(t *testing.T) {
|
func TestRender_Commits(t *testing.T) {
|
||||||
setting.AppURL = TestAppURL
|
setting.AppURL = markup.TestAppURL
|
||||||
test := func(input, expected string) {
|
test := func(input, expected string) {
|
||||||
buffer, err := RenderString(&RenderContext{
|
buffer, err := markup.RenderString(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
RelativePath: ".md",
|
RelativePath: ".md",
|
||||||
URLPrefix: TestRepoURL,
|
URLPrefix: markup.TestRepoURL,
|
||||||
Metas: localMetas,
|
Metas: localMetas,
|
||||||
}, input)
|
}, input)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
@ -50,7 +50,7 @@ func TestRender_Commits(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sha := "65f1bf27bc3bf70f64657658635e66094edbcb4d"
|
sha := "65f1bf27bc3bf70f64657658635e66094edbcb4d"
|
||||||
repo := TestRepoURL
|
repo := markup.TestRepoURL
|
||||||
commit := util.URLJoin(repo, "commit", sha)
|
commit := util.URLJoin(repo, "commit", sha)
|
||||||
tree := util.URLJoin(repo, "tree", sha, "src")
|
tree := util.URLJoin(repo, "tree", sha, "src")
|
||||||
|
|
||||||
|
@ -87,10 +87,10 @@ func TestRender_Commits(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRender_CrossReferences(t *testing.T) {
|
func TestRender_CrossReferences(t *testing.T) {
|
||||||
setting.AppURL = TestAppURL
|
setting.AppURL = markup.TestAppURL
|
||||||
|
|
||||||
test := func(input, expected string) {
|
test := func(input, expected string) {
|
||||||
buffer, err := RenderString(&RenderContext{
|
buffer, err := markup.RenderString(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
RelativePath: "a.md",
|
RelativePath: "a.md",
|
||||||
URLPrefix: setting.AppSubURL,
|
URLPrefix: setting.AppSubURL,
|
||||||
|
@ -102,43 +102,43 @@ func TestRender_CrossReferences(t *testing.T) {
|
||||||
|
|
||||||
test(
|
test(
|
||||||
"gogits/gogs#12345",
|
"gogits/gogs#12345",
|
||||||
`<p><a href="`+util.URLJoin(TestAppURL, "gogits", "gogs", "issues", "12345")+`" class="ref-issue" rel="nofollow">gogits/gogs#12345</a></p>`)
|
`<p><a href="`+util.URLJoin(markup.TestAppURL, "gogits", "gogs", "issues", "12345")+`" class="ref-issue" rel="nofollow">gogits/gogs#12345</a></p>`)
|
||||||
test(
|
test(
|
||||||
"go-gitea/gitea#12345",
|
"go-gitea/gitea#12345",
|
||||||
`<p><a href="`+util.URLJoin(TestAppURL, "go-gitea", "gitea", "issues", "12345")+`" class="ref-issue" rel="nofollow">go-gitea/gitea#12345</a></p>`)
|
`<p><a href="`+util.URLJoin(markup.TestAppURL, "go-gitea", "gitea", "issues", "12345")+`" class="ref-issue" rel="nofollow">go-gitea/gitea#12345</a></p>`)
|
||||||
test(
|
test(
|
||||||
"/home/gitea/go-gitea/gitea#12345",
|
"/home/gitea/go-gitea/gitea#12345",
|
||||||
`<p>/home/gitea/go-gitea/gitea#12345</p>`)
|
`<p>/home/gitea/go-gitea/gitea#12345</p>`)
|
||||||
test(
|
test(
|
||||||
util.URLJoin(TestAppURL, "gogitea", "gitea", "issues", "12345"),
|
util.URLJoin(markup.TestAppURL, "gogitea", "gitea", "issues", "12345"),
|
||||||
`<p><a href="`+util.URLJoin(TestAppURL, "gogitea", "gitea", "issues", "12345")+`" class="ref-issue" rel="nofollow">gogitea/gitea#12345</a></p>`)
|
`<p><a href="`+util.URLJoin(markup.TestAppURL, "gogitea", "gitea", "issues", "12345")+`" class="ref-issue" rel="nofollow">gogitea/gitea#12345</a></p>`)
|
||||||
test(
|
test(
|
||||||
util.URLJoin(TestAppURL, "go-gitea", "gitea", "issues", "12345"),
|
util.URLJoin(markup.TestAppURL, "go-gitea", "gitea", "issues", "12345"),
|
||||||
`<p><a href="`+util.URLJoin(TestAppURL, "go-gitea", "gitea", "issues", "12345")+`" class="ref-issue" rel="nofollow">go-gitea/gitea#12345</a></p>`)
|
`<p><a href="`+util.URLJoin(markup.TestAppURL, "go-gitea", "gitea", "issues", "12345")+`" class="ref-issue" rel="nofollow">go-gitea/gitea#12345</a></p>`)
|
||||||
test(
|
test(
|
||||||
util.URLJoin(TestAppURL, "gogitea", "some-repo-name", "issues", "12345"),
|
util.URLJoin(markup.TestAppURL, "gogitea", "some-repo-name", "issues", "12345"),
|
||||||
`<p><a href="`+util.URLJoin(TestAppURL, "gogitea", "some-repo-name", "issues", "12345")+`" class="ref-issue" rel="nofollow">gogitea/some-repo-name#12345</a></p>`)
|
`<p><a href="`+util.URLJoin(markup.TestAppURL, "gogitea", "some-repo-name", "issues", "12345")+`" class="ref-issue" rel="nofollow">gogitea/some-repo-name#12345</a></p>`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMisc_IsSameDomain(t *testing.T) {
|
func TestMisc_IsSameDomain(t *testing.T) {
|
||||||
setting.AppURL = TestAppURL
|
setting.AppURL = markup.TestAppURL
|
||||||
|
|
||||||
sha := "b6dd6210eaebc915fd5be5579c58cce4da2e2579"
|
sha := "b6dd6210eaebc915fd5be5579c58cce4da2e2579"
|
||||||
commit := util.URLJoin(TestRepoURL, "commit", sha)
|
commit := util.URLJoin(markup.TestRepoURL, "commit", sha)
|
||||||
|
|
||||||
assert.True(t, IsSameDomain(commit))
|
assert.True(t, markup.IsSameDomain(commit))
|
||||||
assert.False(t, IsSameDomain("http://google.com/ncr"))
|
assert.False(t, markup.IsSameDomain("http://google.com/ncr"))
|
||||||
assert.False(t, IsSameDomain("favicon.ico"))
|
assert.False(t, markup.IsSameDomain("favicon.ico"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRender_links(t *testing.T) {
|
func TestRender_links(t *testing.T) {
|
||||||
setting.AppURL = TestAppURL
|
setting.AppURL = markup.TestAppURL
|
||||||
|
|
||||||
test := func(input, expected string) {
|
test := func(input, expected string) {
|
||||||
buffer, err := RenderString(&RenderContext{
|
buffer, err := markup.RenderString(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
RelativePath: "a.md",
|
RelativePath: "a.md",
|
||||||
URLPrefix: TestRepoURL,
|
URLPrefix: markup.TestRepoURL,
|
||||||
}, input)
|
}, input)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
|
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
|
||||||
|
@ -147,8 +147,8 @@ func TestRender_links(t *testing.T) {
|
||||||
|
|
||||||
defaultCustom := setting.Markdown.CustomURLSchemes
|
defaultCustom := setting.Markdown.CustomURLSchemes
|
||||||
setting.Markdown.CustomURLSchemes = []string{"ftp", "magnet"}
|
setting.Markdown.CustomURLSchemes = []string{"ftp", "magnet"}
|
||||||
InitializeSanitizer()
|
markup.InitializeSanitizer()
|
||||||
CustomLinkURLSchemes(setting.Markdown.CustomURLSchemes)
|
markup.CustomLinkURLSchemes(setting.Markdown.CustomURLSchemes)
|
||||||
|
|
||||||
test(
|
test(
|
||||||
"https://www.example.com",
|
"https://www.example.com",
|
||||||
|
@ -227,18 +227,18 @@ func TestRender_links(t *testing.T) {
|
||||||
|
|
||||||
// Restore previous settings
|
// Restore previous settings
|
||||||
setting.Markdown.CustomURLSchemes = defaultCustom
|
setting.Markdown.CustomURLSchemes = defaultCustom
|
||||||
InitializeSanitizer()
|
markup.InitializeSanitizer()
|
||||||
CustomLinkURLSchemes(setting.Markdown.CustomURLSchemes)
|
markup.CustomLinkURLSchemes(setting.Markdown.CustomURLSchemes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRender_email(t *testing.T) {
|
func TestRender_email(t *testing.T) {
|
||||||
setting.AppURL = TestAppURL
|
setting.AppURL = markup.TestAppURL
|
||||||
|
|
||||||
test := func(input, expected string) {
|
test := func(input, expected string) {
|
||||||
res, err := RenderString(&RenderContext{
|
res, err := markup.RenderString(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
RelativePath: "a.md",
|
RelativePath: "a.md",
|
||||||
URLPrefix: TestRepoURL,
|
URLPrefix: markup.TestRepoURL,
|
||||||
}, input)
|
}, input)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(res))
|
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(res))
|
||||||
|
@ -289,15 +289,15 @@ func TestRender_email(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRender_emoji(t *testing.T) {
|
func TestRender_emoji(t *testing.T) {
|
||||||
setting.AppURL = TestAppURL
|
setting.AppURL = markup.TestAppURL
|
||||||
setting.StaticURLPrefix = TestAppURL
|
setting.StaticURLPrefix = markup.TestAppURL
|
||||||
|
|
||||||
test := func(input, expected string) {
|
test := func(input, expected string) {
|
||||||
expected = strings.ReplaceAll(expected, "&", "&")
|
expected = strings.ReplaceAll(expected, "&", "&")
|
||||||
buffer, err := RenderString(&RenderContext{
|
buffer, err := markup.RenderString(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
RelativePath: "a.md",
|
RelativePath: "a.md",
|
||||||
URLPrefix: TestRepoURL,
|
URLPrefix: markup.TestRepoURL,
|
||||||
}, input)
|
}, input)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
|
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
|
||||||
|
@ -354,19 +354,19 @@ func TestRender_emoji(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRender_ShortLinks(t *testing.T) {
|
func TestRender_ShortLinks(t *testing.T) {
|
||||||
setting.AppURL = TestAppURL
|
setting.AppURL = markup.TestAppURL
|
||||||
tree := util.URLJoin(TestRepoURL, "src", "master")
|
tree := util.URLJoin(markup.TestRepoURL, "src", "master")
|
||||||
|
|
||||||
test := func(input, expected, expectedWiki string) {
|
test := func(input, expected, expectedWiki string) {
|
||||||
buffer, err := markdown.RenderString(&RenderContext{
|
buffer, err := markdown.RenderString(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
URLPrefix: tree,
|
URLPrefix: tree,
|
||||||
}, input)
|
}, input)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
|
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
|
||||||
buffer, err = markdown.RenderString(&RenderContext{
|
buffer, err = markdown.RenderString(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
URLPrefix: TestRepoURL,
|
URLPrefix: markup.TestRepoURL,
|
||||||
Metas: localMetas,
|
Metas: localMetas,
|
||||||
IsWiki: true,
|
IsWiki: true,
|
||||||
}, input)
|
}, input)
|
||||||
|
@ -374,7 +374,7 @@ func TestRender_ShortLinks(t *testing.T) {
|
||||||
assert.Equal(t, strings.TrimSpace(expectedWiki), strings.TrimSpace(buffer))
|
assert.Equal(t, strings.TrimSpace(expectedWiki), strings.TrimSpace(buffer))
|
||||||
}
|
}
|
||||||
|
|
||||||
rawtree := util.URLJoin(TestRepoURL, "raw", "master")
|
rawtree := util.URLJoin(markup.TestRepoURL, "raw", "master")
|
||||||
url := util.URLJoin(tree, "Link")
|
url := util.URLJoin(tree, "Link")
|
||||||
otherURL := util.URLJoin(tree, "Other-Link")
|
otherURL := util.URLJoin(tree, "Other-Link")
|
||||||
encodedURL := util.URLJoin(tree, "Link%3F")
|
encodedURL := util.URLJoin(tree, "Link%3F")
|
||||||
|
@ -382,13 +382,13 @@ func TestRender_ShortLinks(t *testing.T) {
|
||||||
otherImgurl := util.URLJoin(rawtree, "Link+Other.jpg")
|
otherImgurl := util.URLJoin(rawtree, "Link+Other.jpg")
|
||||||
encodedImgurl := util.URLJoin(rawtree, "Link+%23.jpg")
|
encodedImgurl := util.URLJoin(rawtree, "Link+%23.jpg")
|
||||||
notencodedImgurl := util.URLJoin(rawtree, "some", "path", "Link+#.jpg")
|
notencodedImgurl := util.URLJoin(rawtree, "some", "path", "Link+#.jpg")
|
||||||
urlWiki := util.URLJoin(TestRepoURL, "wiki", "Link")
|
urlWiki := util.URLJoin(markup.TestRepoURL, "wiki", "Link")
|
||||||
otherURLWiki := util.URLJoin(TestRepoURL, "wiki", "Other-Link")
|
otherURLWiki := util.URLJoin(markup.TestRepoURL, "wiki", "Other-Link")
|
||||||
encodedURLWiki := util.URLJoin(TestRepoURL, "wiki", "Link%3F")
|
encodedURLWiki := util.URLJoin(markup.TestRepoURL, "wiki", "Link%3F")
|
||||||
imgurlWiki := util.URLJoin(TestRepoURL, "wiki", "raw", "Link.jpg")
|
imgurlWiki := util.URLJoin(markup.TestRepoURL, "wiki", "raw", "Link.jpg")
|
||||||
otherImgurlWiki := util.URLJoin(TestRepoURL, "wiki", "raw", "Link+Other.jpg")
|
otherImgurlWiki := util.URLJoin(markup.TestRepoURL, "wiki", "raw", "Link+Other.jpg")
|
||||||
encodedImgurlWiki := util.URLJoin(TestRepoURL, "wiki", "raw", "Link+%23.jpg")
|
encodedImgurlWiki := util.URLJoin(markup.TestRepoURL, "wiki", "raw", "Link+%23.jpg")
|
||||||
notencodedImgurlWiki := util.URLJoin(TestRepoURL, "wiki", "raw", "some", "path", "Link+#.jpg")
|
notencodedImgurlWiki := util.URLJoin(markup.TestRepoURL, "wiki", "raw", "some", "path", "Link+#.jpg")
|
||||||
favicon := "http://google.com/favicon.ico"
|
favicon := "http://google.com/favicon.ico"
|
||||||
|
|
||||||
test(
|
test(
|
||||||
|
@ -462,20 +462,20 @@ func TestRender_ShortLinks(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRender_RelativeImages(t *testing.T) {
|
func TestRender_RelativeImages(t *testing.T) {
|
||||||
setting.AppURL = TestAppURL
|
setting.AppURL = markup.TestAppURL
|
||||||
tree := util.URLJoin(TestRepoURL, "src", "master")
|
tree := util.URLJoin(markup.TestRepoURL, "src", "master")
|
||||||
|
|
||||||
test := func(input, expected, expectedWiki string) {
|
test := func(input, expected, expectedWiki string) {
|
||||||
buffer, err := markdown.RenderString(&RenderContext{
|
buffer, err := markdown.RenderString(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
URLPrefix: tree,
|
URLPrefix: tree,
|
||||||
Metas: localMetas,
|
Metas: localMetas,
|
||||||
}, input)
|
}, input)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
|
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
|
||||||
buffer, err = markdown.RenderString(&RenderContext{
|
buffer, err = markdown.RenderString(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
URLPrefix: TestRepoURL,
|
URLPrefix: markup.TestRepoURL,
|
||||||
Metas: localMetas,
|
Metas: localMetas,
|
||||||
IsWiki: true,
|
IsWiki: true,
|
||||||
}, input)
|
}, input)
|
||||||
|
@ -483,8 +483,8 @@ func TestRender_RelativeImages(t *testing.T) {
|
||||||
assert.Equal(t, strings.TrimSpace(expectedWiki), strings.TrimSpace(buffer))
|
assert.Equal(t, strings.TrimSpace(expectedWiki), strings.TrimSpace(buffer))
|
||||||
}
|
}
|
||||||
|
|
||||||
rawwiki := util.URLJoin(TestRepoURL, "wiki", "raw")
|
rawwiki := util.URLJoin(markup.TestRepoURL, "wiki", "raw")
|
||||||
mediatree := util.URLJoin(TestRepoURL, "media", "master")
|
mediatree := util.URLJoin(markup.TestRepoURL, "media", "master")
|
||||||
|
|
||||||
test(
|
test(
|
||||||
`<img src="Link">`,
|
`<img src="Link">`,
|
||||||
|
@ -498,7 +498,7 @@ func TestRender_RelativeImages(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_ParseClusterFuzz(t *testing.T) {
|
func Test_ParseClusterFuzz(t *testing.T) {
|
||||||
setting.AppURL = TestAppURL
|
setting.AppURL = markup.TestAppURL
|
||||||
|
|
||||||
localMetas := map[string]string{
|
localMetas := map[string]string{
|
||||||
"user": "go-gitea",
|
"user": "go-gitea",
|
||||||
|
@ -508,7 +508,7 @@ func Test_ParseClusterFuzz(t *testing.T) {
|
||||||
data := "<A><maTH><tr><MN><bodY ÿ><temPlate></template><tH><tr></A><tH><d<bodY "
|
data := "<A><maTH><tr><MN><bodY ÿ><temPlate></template><tH><tr></A><tH><d<bodY "
|
||||||
|
|
||||||
var res strings.Builder
|
var res strings.Builder
|
||||||
err := PostProcess(&RenderContext{
|
err := markup.PostProcess(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
URLPrefix: "https://example.com",
|
URLPrefix: "https://example.com",
|
||||||
Metas: localMetas,
|
Metas: localMetas,
|
||||||
|
@ -519,7 +519,7 @@ func Test_ParseClusterFuzz(t *testing.T) {
|
||||||
data = "<!DOCTYPE html>\n<A><maTH><tr><MN><bodY ÿ><temPlate></template><tH><tr></A><tH><d<bodY "
|
data = "<!DOCTYPE html>\n<A><maTH><tr><MN><bodY ÿ><temPlate></template><tH><tr></A><tH><d<bodY "
|
||||||
|
|
||||||
res.Reset()
|
res.Reset()
|
||||||
err = PostProcess(&RenderContext{
|
err = markup.PostProcess(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
URLPrefix: "https://example.com",
|
URLPrefix: "https://example.com",
|
||||||
Metas: localMetas,
|
Metas: localMetas,
|
||||||
|
@ -530,7 +530,7 @@ func Test_ParseClusterFuzz(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPostProcess_RenderDocument(t *testing.T) {
|
func TestPostProcess_RenderDocument(t *testing.T) {
|
||||||
setting.AppURL = TestAppURL
|
setting.AppURL = markup.TestAppURL
|
||||||
|
|
||||||
localMetas := map[string]string{
|
localMetas := map[string]string{
|
||||||
"user": "go-gitea",
|
"user": "go-gitea",
|
||||||
|
@ -540,7 +540,7 @@ func TestPostProcess_RenderDocument(t *testing.T) {
|
||||||
|
|
||||||
test := func(input, expected string) {
|
test := func(input, expected string) {
|
||||||
var res strings.Builder
|
var res strings.Builder
|
||||||
err := PostProcess(&RenderContext{
|
err := markup.PostProcess(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
URLPrefix: "https://example.com",
|
URLPrefix: "https://example.com",
|
||||||
Metas: localMetas,
|
Metas: localMetas,
|
||||||
|
@ -566,7 +566,7 @@ func TestPostProcess_RenderDocument(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIssue16020(t *testing.T) {
|
func TestIssue16020(t *testing.T) {
|
||||||
setting.AppURL = TestAppURL
|
setting.AppURL = markup.TestAppURL
|
||||||
|
|
||||||
localMetas := map[string]string{
|
localMetas := map[string]string{
|
||||||
"user": "go-gitea",
|
"user": "go-gitea",
|
||||||
|
@ -576,7 +576,7 @@ func TestIssue16020(t *testing.T) {
|
||||||
data := `<img src="data:image/png;base64,i//V"/>`
|
data := `<img src="data:image/png;base64,i//V"/>`
|
||||||
|
|
||||||
var res strings.Builder
|
var res strings.Builder
|
||||||
err := PostProcess(&RenderContext{
|
err := markup.PostProcess(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
URLPrefix: "https://example.com",
|
URLPrefix: "https://example.com",
|
||||||
Metas: localMetas,
|
Metas: localMetas,
|
||||||
|
@ -593,7 +593,7 @@ func BenchmarkEmojiPostprocess(b *testing.B) {
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
var res strings.Builder
|
var res strings.Builder
|
||||||
err := PostProcess(&RenderContext{
|
err := markup.PostProcess(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
URLPrefix: "https://example.com",
|
URLPrefix: "https://example.com",
|
||||||
Metas: localMetas,
|
Metas: localMetas,
|
||||||
|
@ -604,7 +604,7 @@ func BenchmarkEmojiPostprocess(b *testing.B) {
|
||||||
|
|
||||||
func TestFuzz(t *testing.T) {
|
func TestFuzz(t *testing.T) {
|
||||||
s := "t/l/issues/8#/../../a"
|
s := "t/l/issues/8#/../../a"
|
||||||
renderContext := RenderContext{
|
renderContext := markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
URLPrefix: "https://example.com/go-gitea/gitea",
|
URLPrefix: "https://example.com/go-gitea/gitea",
|
||||||
Metas: map[string]string{
|
Metas: map[string]string{
|
||||||
|
@ -613,7 +613,7 @@ func TestFuzz(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err := PostProcess(&renderContext, strings.NewReader(s), io.Discard)
|
err := markup.PostProcess(&renderContext, strings.NewReader(s), io.Discard)
|
||||||
|
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
@ -622,7 +622,7 @@ func TestIssue18471(t *testing.T) {
|
||||||
data := `http://domain/org/repo/compare/783b039...da951ce`
|
data := `http://domain/org/repo/compare/783b039...da951ce`
|
||||||
|
|
||||||
var res strings.Builder
|
var res strings.Builder
|
||||||
err := PostProcess(&RenderContext{
|
err := markup.PostProcess(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
URLPrefix: "https://example.com",
|
URLPrefix: "https://example.com",
|
||||||
Metas: localMetas,
|
Metas: localMetas,
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/markup"
|
"code.gitea.io/gitea/modules/markup"
|
||||||
. "code.gitea.io/gitea/modules/markup/markdown"
|
"code.gitea.io/gitea/modules/markup/markdown"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/modules/util"
|
"code.gitea.io/gitea/modules/util"
|
||||||
|
|
||||||
|
@ -51,14 +51,14 @@ func TestRender_StandardLinks(t *testing.T) {
|
||||||
setting.AppSubURL = AppSubURL
|
setting.AppSubURL = AppSubURL
|
||||||
|
|
||||||
test := func(input, expected, expectedWiki string) {
|
test := func(input, expected, expectedWiki string) {
|
||||||
buffer, err := RenderString(&markup.RenderContext{
|
buffer, err := markdown.RenderString(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
URLPrefix: setting.AppSubURL,
|
URLPrefix: setting.AppSubURL,
|
||||||
}, input)
|
}, input)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
|
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
|
||||||
|
|
||||||
buffer, err = RenderString(&markup.RenderContext{
|
buffer, err = markdown.RenderString(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
URLPrefix: setting.AppSubURL,
|
URLPrefix: setting.AppSubURL,
|
||||||
IsWiki: true,
|
IsWiki: true,
|
||||||
|
@ -82,7 +82,7 @@ func TestRender_Images(t *testing.T) {
|
||||||
setting.AppSubURL = AppSubURL
|
setting.AppSubURL = AppSubURL
|
||||||
|
|
||||||
test := func(input, expected string) {
|
test := func(input, expected string) {
|
||||||
buffer, err := RenderString(&markup.RenderContext{
|
buffer, err := markdown.RenderString(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
URLPrefix: setting.AppSubURL,
|
URLPrefix: setting.AppSubURL,
|
||||||
}, input)
|
}, input)
|
||||||
|
@ -289,7 +289,7 @@ func TestTotal_RenderWiki(t *testing.T) {
|
||||||
answers := testAnswers(util.URLJoin(AppSubURL, "wiki/"), util.URLJoin(AppSubURL, "wiki", "raw/"))
|
answers := testAnswers(util.URLJoin(AppSubURL, "wiki/"), util.URLJoin(AppSubURL, "wiki", "raw/"))
|
||||||
|
|
||||||
for i := 0; i < len(sameCases); i++ {
|
for i := 0; i < len(sameCases); i++ {
|
||||||
line, err := RenderString(&markup.RenderContext{
|
line, err := markdown.RenderString(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
URLPrefix: AppSubURL,
|
URLPrefix: AppSubURL,
|
||||||
Metas: localMetas,
|
Metas: localMetas,
|
||||||
|
@ -313,7 +313,7 @@ func TestTotal_RenderWiki(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(testCases); i += 2 {
|
for i := 0; i < len(testCases); i += 2 {
|
||||||
line, err := RenderString(&markup.RenderContext{
|
line, err := markdown.RenderString(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
URLPrefix: AppSubURL,
|
URLPrefix: AppSubURL,
|
||||||
IsWiki: true,
|
IsWiki: true,
|
||||||
|
@ -330,7 +330,7 @@ func TestTotal_RenderString(t *testing.T) {
|
||||||
answers := testAnswers(util.URLJoin(AppSubURL, "src", "master/"), util.URLJoin(AppSubURL, "raw", "master/"))
|
answers := testAnswers(util.URLJoin(AppSubURL, "src", "master/"), util.URLJoin(AppSubURL, "raw", "master/"))
|
||||||
|
|
||||||
for i := 0; i < len(sameCases); i++ {
|
for i := 0; i < len(sameCases); i++ {
|
||||||
line, err := RenderString(&markup.RenderContext{
|
line, err := markdown.RenderString(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
URLPrefix: util.URLJoin(AppSubURL, "src", "master/"),
|
URLPrefix: util.URLJoin(AppSubURL, "src", "master/"),
|
||||||
Metas: localMetas,
|
Metas: localMetas,
|
||||||
|
@ -342,7 +342,7 @@ func TestTotal_RenderString(t *testing.T) {
|
||||||
testCases := []string{}
|
testCases := []string{}
|
||||||
|
|
||||||
for i := 0; i < len(testCases); i += 2 {
|
for i := 0; i < len(testCases); i += 2 {
|
||||||
line, err := RenderString(&markup.RenderContext{
|
line, err := markdown.RenderString(&markup.RenderContext{
|
||||||
Ctx: git.DefaultContext,
|
Ctx: git.DefaultContext,
|
||||||
URLPrefix: AppSubURL,
|
URLPrefix: AppSubURL,
|
||||||
}, testCases[i])
|
}, testCases[i])
|
||||||
|
@ -353,17 +353,17 @@ func TestTotal_RenderString(t *testing.T) {
|
||||||
|
|
||||||
func TestRender_RenderParagraphs(t *testing.T) {
|
func TestRender_RenderParagraphs(t *testing.T) {
|
||||||
test := func(t *testing.T, str string, cnt int) {
|
test := func(t *testing.T, str string, cnt int) {
|
||||||
res, err := RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, str)
|
res, err := markdown.RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, str)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, cnt, strings.Count(res, "<p"), "Rendered result for unix should have %d paragraph(s) but has %d:\n%s\n", cnt, strings.Count(res, "<p"), res)
|
assert.Equal(t, cnt, strings.Count(res, "<p"), "Rendered result for unix should have %d paragraph(s) but has %d:\n%s\n", cnt, strings.Count(res, "<p"), res)
|
||||||
|
|
||||||
mac := strings.ReplaceAll(str, "\n", "\r")
|
mac := strings.ReplaceAll(str, "\n", "\r")
|
||||||
res, err = RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, mac)
|
res, err = markdown.RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, mac)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, cnt, strings.Count(res, "<p"), "Rendered result for mac should have %d paragraph(s) but has %d:\n%s\n", cnt, strings.Count(res, "<p"), res)
|
assert.Equal(t, cnt, strings.Count(res, "<p"), "Rendered result for mac should have %d paragraph(s) but has %d:\n%s\n", cnt, strings.Count(res, "<p"), res)
|
||||||
|
|
||||||
dos := strings.ReplaceAll(str, "\n", "\r\n")
|
dos := strings.ReplaceAll(str, "\n", "\r\n")
|
||||||
res, err = RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, dos)
|
res, err = markdown.RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, dos)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, cnt, strings.Count(res, "<p"), "Rendered result for windows should have %d paragraph(s) but has %d:\n%s\n", cnt, strings.Count(res, "<p"), res)
|
assert.Equal(t, cnt, strings.Count(res, "<p"), "Rendered result for windows should have %d paragraph(s) but has %d:\n%s\n", cnt, strings.Count(res, "<p"), res)
|
||||||
}
|
}
|
||||||
|
@ -391,7 +391,7 @@ func TestMarkdownRenderRaw(t *testing.T) {
|
||||||
|
|
||||||
for _, testcase := range testcases {
|
for _, testcase := range testcases {
|
||||||
log.Info("Test markdown render error with fuzzy data: %x, the following errors can be recovered", testcase)
|
log.Info("Test markdown render error with fuzzy data: %x, the following errors can be recovered", testcase)
|
||||||
_, err := RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, string(testcase))
|
_, err := markdown.RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, string(testcase))
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -403,7 +403,7 @@ func TestRenderSiblingImages_Issue12925(t *testing.T) {
|
||||||
expected := `<p><a href="/image1" target="_blank" rel="nofollow noopener"><img src="/image1" alt="image1"></a><br>
|
expected := `<p><a href="/image1" target="_blank" rel="nofollow noopener"><img src="/image1" alt="image1"></a><br>
|
||||||
<a href="/image2" target="_blank" rel="nofollow noopener"><img src="/image2" alt="image2"></a></p>
|
<a href="/image2" target="_blank" rel="nofollow noopener"><img src="/image2" alt="image2"></a></p>
|
||||||
`
|
`
|
||||||
res, err := RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, testcase)
|
res, err := markdown.RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, testcase)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, expected, res)
|
assert.Equal(t, expected, res)
|
||||||
}
|
}
|
||||||
|
@ -412,7 +412,7 @@ func TestRenderEmojiInLinks_Issue12331(t *testing.T) {
|
||||||
testcase := `[Link with emoji :moon: in text](https://gitea.io)`
|
testcase := `[Link with emoji :moon: in text](https://gitea.io)`
|
||||||
expected := `<p><a href="https://gitea.io" rel="nofollow">Link with emoji <span class="emoji" aria-label="waxing gibbous moon">🌔</span> in text</a></p>
|
expected := `<p><a href="https://gitea.io" rel="nofollow">Link with emoji <span class="emoji" aria-label="waxing gibbous moon">🌔</span> in text</a></p>
|
||||||
`
|
`
|
||||||
res, err := RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, testcase)
|
res, err := markdown.RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, testcase)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, expected, res)
|
assert.Equal(t, expected, res)
|
||||||
}
|
}
|
||||||
|
@ -446,7 +446,7 @@ func TestColorPreview(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range positiveTests {
|
for _, test := range positiveTests {
|
||||||
res, err := RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, test.testcase)
|
res, err := markdown.RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, test.testcase)
|
||||||
assert.NoError(t, err, "Unexpected error in testcase: %q", test.testcase)
|
assert.NoError(t, err, "Unexpected error in testcase: %q", test.testcase)
|
||||||
assert.Equal(t, test.expected, res, "Unexpected result in testcase %q", test.testcase)
|
assert.Equal(t, test.expected, res, "Unexpected result in testcase %q", test.testcase)
|
||||||
|
|
||||||
|
@ -466,7 +466,7 @@ func TestColorPreview(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range negativeTests {
|
for _, test := range negativeTests {
|
||||||
res, err := RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, test)
|
res, err := markdown.RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, test)
|
||||||
assert.NoError(t, err, "Unexpected error in testcase: %q", test)
|
assert.NoError(t, err, "Unexpected error in testcase: %q", test)
|
||||||
assert.NotContains(t, res, `<span class="color-preview" style="background-color: `, "Unexpected result in testcase %q", test)
|
assert.NotContains(t, res, `<span class="color-preview" style="background-color: `, "Unexpected result in testcase %q", test)
|
||||||
}
|
}
|
||||||
|
@ -513,7 +513,7 @@ func TestMathBlock(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range testcases {
|
for _, test := range testcases {
|
||||||
res, err := RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, test.testcase)
|
res, err := markdown.RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, test.testcase)
|
||||||
assert.NoError(t, err, "Unexpected error in testcase: %q", test.testcase)
|
assert.NoError(t, err, "Unexpected error in testcase: %q", test.testcase)
|
||||||
assert.Equal(t, test.expected, res, "Unexpected result in testcase %q", test.testcase)
|
assert.Equal(t, test.expected, res, "Unexpected result in testcase %q", test.testcase)
|
||||||
|
|
||||||
|
@ -551,7 +551,7 @@ foo: bar
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range testcases {
|
for _, test := range testcases {
|
||||||
res, err := RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, test.testcase)
|
res, err := markdown.RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, test.testcase)
|
||||||
assert.NoError(t, err, "Unexpected error in testcase: %q", test.testcase)
|
assert.NoError(t, err, "Unexpected error in testcase: %q", test.testcase)
|
||||||
assert.Equal(t, test.expected, res, "Unexpected result in testcase %q", test.testcase)
|
assert.Equal(t, test.expected, res, "Unexpected result in testcase %q", test.testcase)
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,9 +210,8 @@ func (p *templateErrorPrettier) handleTemplateRenderingError(err error) string {
|
||||||
} else if execErr, ok := err.(texttemplate.ExecError); ok {
|
} else if execErr, ok := err.(texttemplate.ExecError); ok {
|
||||||
layerName := p.assets.GetFileLayerName(execErr.Name + ".tmpl")
|
layerName := p.assets.GetFileLayerName(execErr.Name + ".tmpl")
|
||||||
return fmt.Sprintf("asset from: %s, %s", layerName, err.Error())
|
return fmt.Sprintf("asset from: %s, %s", layerName, err.Error())
|
||||||
} else {
|
|
||||||
return err.Error()
|
|
||||||
}
|
}
|
||||||
|
return err.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
func HandleTemplateRenderingError(err error) string {
|
func HandleTemplateRenderingError(err error) string {
|
||||||
|
|
|
@ -40,9 +40,8 @@ func PathJoinRel(elem ...string) string {
|
||||||
return ""
|
return ""
|
||||||
} else if p == "/" {
|
} else if p == "/" {
|
||||||
return "."
|
return "."
|
||||||
} else {
|
|
||||||
return p[1:]
|
|
||||||
}
|
}
|
||||||
|
return p[1:]
|
||||||
}
|
}
|
||||||
|
|
||||||
// PathJoinRelX joins the path elements into a single path like PathJoinRel,
|
// PathJoinRelX joins the path elements into a single path like PathJoinRel,
|
||||||
|
|
|
@ -625,9 +625,8 @@ func EditPullRequest(ctx *context.APIContext) {
|
||||||
} else if models.IsErrPullRequestHasMerged(err) {
|
} else if models.IsErrPullRequestHasMerged(err) {
|
||||||
ctx.Error(http.StatusConflict, "IsErrPullRequestHasMerged", err)
|
ctx.Error(http.StatusConflict, "IsErrPullRequestHasMerged", err)
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
ctx.InternalServerError(err)
|
|
||||||
}
|
}
|
||||||
|
ctx.InternalServerError(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
notify_service.PullRequestChangeTargetBranch(ctx, ctx.Doer, pr, form.Base)
|
notify_service.PullRequestChangeTargetBranch(ctx, ctx.Doer, pr, form.Base)
|
||||||
|
|
|
@ -171,10 +171,9 @@ func CherryPickPost(ctx *context.Context) {
|
||||||
} else if models.IsErrCommitIDDoesNotMatch(err) {
|
} else if models.IsErrCommitIDDoesNotMatch(err) {
|
||||||
ctx.RenderWithErr(ctx.Tr("repo.editor.file_changed_while_editing", ctx.Repo.RepoLink+"/compare/"+form.LastCommit+"..."+ctx.Repo.CommitID), tplPatchFile, &form)
|
ctx.RenderWithErr(ctx.Tr("repo.editor.file_changed_while_editing", ctx.Repo.RepoLink+"/compare/"+form.LastCommit+"..."+ctx.Repo.CommitID), tplPatchFile, &form)
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
ctx.RenderWithErr(ctx.Tr("repo.editor.fail_to_apply_patch", err), tplPatchFile, &form)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
ctx.RenderWithErr(ctx.Tr("repo.editor.fail_to_apply_patch", err), tplPatchFile, &form)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,10 +80,9 @@ func AddDependency(ctx *context.Context) {
|
||||||
} else if issues_model.IsErrCircularDependency(err) {
|
} else if issues_model.IsErrCircularDependency(err) {
|
||||||
ctx.Flash.Error(ctx.Tr("repo.issues.dependency.add_error_cannot_create_circular"))
|
ctx.Flash.Error(ctx.Tr("repo.issues.dependency.add_error_cannot_create_circular"))
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
ctx.ServerError("CreateOrUpdateIssueDependency", err)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
ctx.ServerError("CreateOrUpdateIssueDependency", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,10 +104,9 @@ func NewDiffPatchPost(ctx *context.Context) {
|
||||||
} else if models.IsErrCommitIDDoesNotMatch(err) {
|
} else if models.IsErrCommitIDDoesNotMatch(err) {
|
||||||
ctx.RenderWithErr(ctx.Tr("repo.editor.file_changed_while_editing", ctx.Repo.RepoLink+"/compare/"+form.LastCommit+"..."+ctx.Repo.CommitID), tplPatchFile, &form)
|
ctx.RenderWithErr(ctx.Tr("repo.editor.file_changed_while_editing", ctx.Repo.RepoLink+"/compare/"+form.LastCommit+"..."+ctx.Repo.CommitID), tplPatchFile, &form)
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
ctx.RenderWithErr(ctx.Tr("repo.editor.fail_to_apply_patch", err), tplPatchFile, &form)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
ctx.RenderWithErr(ctx.Tr("repo.editor.fail_to_apply_patch", err), tplPatchFile, &form)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if form.CommitChoice == frmCommitChoiceNewBranch && ctx.Repo.Repository.UnitEnabled(ctx, unit.TypePullRequests) {
|
if form.CommitChoice == frmCommitChoiceNewBranch && ctx.Repo.Repository.UnitEnabled(ctx, unit.TypePullRequests) {
|
||||||
|
|
|
@ -361,9 +361,8 @@ func (s *sendmailSender) Send(from string, to []string, msg io.WriterTo) error {
|
||||||
return err
|
return err
|
||||||
} else if closeError != nil {
|
} else if closeError != nil {
|
||||||
return closeError
|
return closeError
|
||||||
} else {
|
|
||||||
return waitError
|
|
||||||
}
|
}
|
||||||
|
return waitError
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sender sendmail mail sender
|
// Sender sendmail mail sender
|
||||||
|
|
|
@ -65,9 +65,8 @@ func (t *TemporaryUploadRepository) Clone(branch string) error {
|
||||||
OwnerName: t.repo.OwnerName,
|
OwnerName: t.repo.OwnerName,
|
||||||
Name: t.repo.Name,
|
Name: t.repo.Name,
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return fmt.Errorf("Clone: %w %s", err, stderr)
|
|
||||||
}
|
}
|
||||||
|
return fmt.Errorf("Clone: %w %s", err, stderr)
|
||||||
}
|
}
|
||||||
gitRepo, err := git.OpenRepository(t.ctx, t.basePath)
|
gitRepo, err := git.OpenRepository(t.ctx, t.basePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -419,9 +419,8 @@ func logUnexpectedResponse(t testing.TB, recorder *httptest.ResponseRecorder) {
|
||||||
// if body is short, just log the whole thing
|
// if body is short, just log the whole thing
|
||||||
t.Log("Response: ", string(respBytes))
|
t.Log("Response: ", string(respBytes))
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
t.Log("Response length: ", len(respBytes))
|
|
||||||
}
|
}
|
||||||
|
t.Log("Response length: ", len(respBytes))
|
||||||
|
|
||||||
// log the "flash" error message, if one exists
|
// log the "flash" error message, if one exists
|
||||||
// we must create a new buffer, so that we don't "use up" resp.Body
|
// we must create a new buffer, so that we don't "use up" resp.Body
|
||||||
|
|
Loading…
Reference in a new issue