From 635d188e77acb97c9c5841d3db41a35130a185c3 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 17 Feb 2024 23:40:36 +0800 Subject: [PATCH 1/6] use repo as of renderctx's member rather than a repoPath on metas --- models/issues/comment_code.go | 3 ++- models/repo/repo.go | 7 +++---- modules/markup/html.go | 6 +++--- modules/markup/renderer.go | 2 ++ routers/common/markup.go | 3 ++- routers/web/feed/convert.go | 3 ++- routers/web/repo/commit.go | 1 + routers/web/repo/issue.go | 5 +++++ routers/web/repo/milestone.go | 2 ++ routers/web/repo/projects.go | 2 ++ routers/web/repo/release.go | 2 ++ routers/web/user/home.go | 1 + services/mailer/mail.go | 3 ++- services/mailer/mail_release.go | 3 ++- 14 files changed, 31 insertions(+), 12 deletions(-) diff --git a/models/issues/comment_code.go b/models/issues/comment_code.go index 384a595dd90dc..1e23a4db6a650 100644 --- a/models/issues/comment_code.go +++ b/models/issues/comment_code.go @@ -109,7 +109,8 @@ func findCodeComments(ctx context.Context, opts FindCommentsOptions, issue *Issu var err error if comment.RenderedContent, err = markdown.RenderString(&markup.RenderContext{ - Ctx: ctx, + Ctx: ctx, + Repo: issue.Repo, Links: markup.Links{ Base: issue.Repo.Link(), }, diff --git a/models/repo/repo.go b/models/repo/repo.go index 13493ba6e80e6..5eb0f68a25dc2 100644 --- a/models/repo/repo.go +++ b/models/repo/repo.go @@ -460,10 +460,9 @@ func (repo *Repository) MustOwner(ctx context.Context) *user_model.User { func (repo *Repository) ComposeMetas(ctx context.Context) map[string]string { if len(repo.RenderingMetas) == 0 { metas := map[string]string{ - "user": repo.OwnerName, - "repo": repo.Name, - "repoPath": repo.RepoPath(), - "mode": "comment", + "user": repo.OwnerName, + "repo": repo.Name, + "mode": "comment", } unit, err := repo.GetUnit(ctx, unit.TypeExternalTracker) diff --git a/modules/markup/html.go b/modules/markup/html.go index b7291823b506b..d1705ab74b912 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -15,7 +15,7 @@ import ( "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/emoji" - "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/markup/common" "code.gitea.io/gitea/modules/references" @@ -1114,7 +1114,7 @@ func emojiProcessor(ctx *RenderContext, node *html.Node) { // hashCurrentPatternProcessor renders SHA1 strings to corresponding links that // are assumed to be in the same repository. func hashCurrentPatternProcessor(ctx *RenderContext, node *html.Node) { - if ctx.Metas == nil || ctx.Metas["user"] == "" || ctx.Metas["repo"] == "" || ctx.Metas["repoPath"] == "" { + if ctx.Metas == nil || ctx.Metas["user"] == "" || ctx.Metas["repo"] == "" || (ctx.Repo == nil && ctx.GitRepo == nil) { return } @@ -1146,7 +1146,7 @@ func hashCurrentPatternProcessor(ctx *RenderContext, node *html.Node) { if !inCache { if ctx.GitRepo == nil { var err error - ctx.GitRepo, err = git.OpenRepository(ctx.Ctx, ctx.Metas["repoPath"]) + ctx.GitRepo, _, err = gitrepo.RepositoryFromContextOrOpen(ctx.Ctx, ctx.Repo) if err != nil { log.Error("unable to open repository: %s Error: %v", ctx.Metas["repoPath"], err) return diff --git a/modules/markup/renderer.go b/modules/markup/renderer.go index 5a7adcc553226..bed2421a69650 100644 --- a/modules/markup/renderer.go +++ b/modules/markup/renderer.go @@ -15,6 +15,7 @@ import ( "sync" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" @@ -74,6 +75,7 @@ type RenderContext struct { Metas map[string]string DefaultLink string GitRepo *git.Repository + Repo gitrepo.Repository ShaExistCache map[string]bool cancelFn func() SidebarTocNode ast.Node diff --git a/routers/common/markup.go b/routers/common/markup.go index a1c2c37ac07a4..ff93fa193679a 100644 --- a/routers/common/markup.go +++ b/routers/common/markup.go @@ -77,7 +77,8 @@ func RenderMarkup(ctx *context.Base, repo *context.Repository, mode, text, urlPr } if err := markup.Render(&markup.RenderContext{ - Ctx: ctx, + Ctx: ctx, + Repo: repo.Repository, Links: markup.Links{ Base: urlPrefix, }, diff --git a/routers/web/feed/convert.go b/routers/web/feed/convert.go index 1e040ed819eb6..2a24d9cd1676a 100644 --- a/routers/web/feed/convert.go +++ b/routers/web/feed/convert.go @@ -292,7 +292,8 @@ func releasesToFeedItems(ctx *context.Context, releases []*repo_model.Release, i link := &feeds.Link{Href: rel.HTMLURL()} content, err = markdown.RenderString(&markup.RenderContext{ - Ctx: ctx, + Ctx: ctx, + Repo: rel.Repo, Links: markup.Links{ Base: rel.Repo.Link(), }, diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index 32fa973ef61e5..2ef29f98fca80 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -384,6 +384,7 @@ func Diff(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, template.HTMLEscapeString(string(charset.ToUTF8WithFallback(note.Message, charset.ConvertOpts{})))) if err != nil { diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index d5e49960a1ec8..4c96cf0e9ff8b 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -1458,6 +1458,7 @@ func ViewIssue(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, issue.Content) if err != nil { @@ -1623,6 +1624,7 @@ func ViewIssue(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, comment.Content) if err != nil { @@ -1702,6 +1704,7 @@ func ViewIssue(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, comment.Content) if err != nil { @@ -2262,6 +2265,7 @@ func UpdateIssueContent(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, issue.Content) if err != nil { @@ -3173,6 +3177,7 @@ func UpdateCommentContent(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, comment.Content) if err != nil { diff --git a/routers/web/repo/milestone.go b/routers/web/repo/milestone.go index 400748b963d5d..8177a5e13cabe 100644 --- a/routers/web/repo/milestone.go +++ b/routers/web/repo/milestone.go @@ -86,6 +86,7 @@ func Milestones(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, m.Content) if err != nil { @@ -282,6 +283,7 @@ func MilestoneIssuesAndPulls(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, milestone.Content) if err != nil { diff --git a/routers/web/repo/projects.go b/routers/web/repo/projects.go index cc0127e7e173a..3c48b5f6ba63c 100644 --- a/routers/web/repo/projects.go +++ b/routers/web/repo/projects.go @@ -95,6 +95,7 @@ func Projects(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, projects[i].Description) if err != nil { @@ -364,6 +365,7 @@ func ViewProject(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, project.Description) if err != nil { diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go index fdb247d413835..ce549b26d40d2 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -141,6 +141,7 @@ func Releases(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, r.Note) if err != nil { @@ -294,6 +295,7 @@ func SingleRelease(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, release.Note) if err != nil { diff --git a/routers/web/user/home.go b/routers/web/user/home.go index b7abbcbc00281..653544c71b178 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -263,6 +263,7 @@ func Milestones(ctx *context.Context) { }, Metas: milestones[i].Repo.ComposeMetas(ctx), Ctx: ctx, + Repo: milestones[i].Repo, }, milestones[i].Content) if err != nil { ctx.ServerError("RenderString", err) diff --git a/services/mailer/mail.go b/services/mailer/mail.go index 38973ea9352fa..cb1d00e443d94 100644 --- a/services/mailer/mail.go +++ b/services/mailer/mail.go @@ -220,7 +220,8 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient // This is the body of the new issue or comment, not the mail body body, err := markdown.RenderString(&markup.RenderContext{ - Ctx: ctx, + Ctx: ctx, + Repo: ctx.Issue.Repo, Links: markup.Links{ Base: ctx.Issue.Repo.HTMLURL(), }, diff --git a/services/mailer/mail_release.go b/services/mailer/mail_release.go index 6682774a04b7a..6382b7da6267f 100644 --- a/services/mailer/mail_release.go +++ b/services/mailer/mail_release.go @@ -57,7 +57,8 @@ func mailNewRelease(ctx context.Context, lang string, tos []string, rel *repo_mo var err error rel.RenderedNote, err = markdown.RenderString(&markup.RenderContext{ - Ctx: ctx, + Ctx: ctx, + Repo: rel.Repo, Links: markup.Links{ Base: rel.Repo.HTMLURL(), }, From 01022da134694bb2ef72220e6ba49689686eb56a Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 18 Feb 2024 11:37:05 +0800 Subject: [PATCH 2/6] Fix test --- modules/markup/html.go | 2 +- modules/markup/html_test.go | 9 ++++++--- routers/common/markup.go | 5 ++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/markup/html.go b/modules/markup/html.go index d1705ab74b912..3ae2e5f775377 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -1148,7 +1148,7 @@ func hashCurrentPatternProcessor(ctx *RenderContext, node *html.Node) { var err error ctx.GitRepo, _, err = gitrepo.RepositoryFromContextOrOpen(ctx.Ctx, ctx.Repo) if err != nil { - log.Error("unable to open repository: %s Error: %v", ctx.Metas["repoPath"], err) + log.Error("unable to open repository: %s/%s Error: %v", ctx.Repo.GetOwnerName(), ctx.Repo.GetName(), err) return } ctx.AddCancel(func() { diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go index 89ecfc036b587..bdf535e20e667 100644 --- a/modules/markup/html_test.go +++ b/modules/markup/html_test.go @@ -23,9 +23,9 @@ import ( ) var localMetas = map[string]string{ - "user": "gogits", - "repo": "gogs", - "repoPath": "../../tests/gitea-repositories-meta/user13/repo11.git/", + "user": "gogits", + "repo": "gogs", + //"repoPath": "../../tests/gitea-repositories-meta/user13/repo11.git/", } func TestMain(m *testing.M) { @@ -45,6 +45,9 @@ func TestRender_Commits(t *testing.T) { Links: markup.Links{ Base: markup.TestRepoURL, }, + ShaExistCache: map[string]bool{ + input: true, + }, Metas: localMetas, }, input) assert.NoError(t, err) diff --git a/routers/common/markup.go b/routers/common/markup.go index ff93fa193679a..431a17e71e92f 100644 --- a/routers/common/markup.go +++ b/routers/common/markup.go @@ -9,6 +9,7 @@ import ( "net/http" "strings" + repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/markdown" @@ -65,7 +66,9 @@ func RenderMarkup(ctx *context.Base, repo *context.Repository, mode, text, urlPr } meta := map[string]string{} + var repoCtx *repo_model.Repository if repo != nil && repo.Repository != nil { + repoCtx = repo.Repository if mode == "comment" { meta = repo.Repository.ComposeMetas(ctx) } else { @@ -78,7 +81,7 @@ func RenderMarkup(ctx *context.Base, repo *context.Repository, mode, text, urlPr if err := markup.Render(&markup.RenderContext{ Ctx: ctx, - Repo: repo.Repository, + Repo: repoCtx, Links: markup.Links{ Base: urlPrefix, }, From acd9d7b11510c60bffdc74eab41dfcce355d3ae7 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 19 Feb 2024 11:43:54 +0800 Subject: [PATCH 3/6] Fix tests --- modules/gitrepo/url.go | 8 ++++ modules/markup/html.go | 2 +- modules/markup/html_test.go | 44 +++++++++++-------- modules/markup/main_test.go | 14 ++++++ modules/markup/markdown/main_test.go | 21 +++++++++ modules/markup/markdown/markdown_test.go | 54 ++++++++++++++---------- 6 files changed, 102 insertions(+), 41 deletions(-) create mode 100644 modules/gitrepo/url.go create mode 100644 modules/markup/main_test.go create mode 100644 modules/markup/markdown/main_test.go diff --git a/modules/gitrepo/url.go b/modules/gitrepo/url.go new file mode 100644 index 0000000000000..b355d0fa93aac --- /dev/null +++ b/modules/gitrepo/url.go @@ -0,0 +1,8 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package gitrepo + +func RepoGitURL(repo Repository) string { + return repoPath(repo) +} diff --git a/modules/markup/html.go b/modules/markup/html.go index 3ae2e5f775377..da6471bb45eef 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -1148,7 +1148,7 @@ func hashCurrentPatternProcessor(ctx *RenderContext, node *html.Node) { var err error ctx.GitRepo, _, err = gitrepo.RepositoryFromContextOrOpen(ctx.Ctx, ctx.Repo) if err != nil { - log.Error("unable to open repository: %s/%s Error: %v", ctx.Repo.GetOwnerName(), ctx.Repo.GetName(), err) + log.Error("unable to open repository: %s Error: %v", gitrepo.RepoGitURL(ctx.Repo), err) return } ctx.AddCancel(func() { diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go index bdf535e20e667..8f66c0743a862 100644 --- a/modules/markup/html_test.go +++ b/modules/markup/html_test.go @@ -4,16 +4,13 @@ package markup_test import ( - "context" "io" - "os" "strings" "testing" - "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/emoji" "code.gitea.io/gitea/modules/git" - "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/markdown" "code.gitea.io/gitea/modules/setting" @@ -22,18 +19,33 @@ import ( "github.com/stretchr/testify/assert" ) -var localMetas = map[string]string{ - "user": "gogits", - "repo": "gogs", - //"repoPath": "../../tests/gitea-repositories-meta/user13/repo11.git/", +var ( + testRepoOwnerName = "user13" + testRepoName = "repo11" + localMetas = map[string]string{ + "user": testRepoOwnerName, + "repo": testRepoName, + } +) + +type mockRepo struct { + OwnerName string + RepoName string +} + +func (m *mockRepo) GetOwnerName() string { + return m.OwnerName +} + +func (m *mockRepo) GetName() string { + return m.RepoName } -func TestMain(m *testing.M) { - unittest.InitSettings() - if err := git.InitSimple(context.Background()); err != nil { - log.Fatal("git init failed, err: %v", err) +func newMockRepo(ownerName, repoName string) gitrepo.Repository { + return &mockRepo{ + OwnerName: ownerName, + RepoName: repoName, } - os.Exit(m.Run()) } func TestRender_Commits(t *testing.T) { @@ -45,9 +57,7 @@ func TestRender_Commits(t *testing.T) { Links: markup.Links{ Base: markup.TestRepoURL, }, - ShaExistCache: map[string]bool{ - input: true, - }, + Repo: newMockRepo(testRepoOwnerName, testRepoName), Metas: localMetas, }, input) assert.NoError(t, err) @@ -55,7 +65,7 @@ func TestRender_Commits(t *testing.T) { } sha := "65f1bf27bc3bf70f64657658635e66094edbcb4d" - repo := markup.TestRepoURL + repo := markup.TestAppURL + testRepoOwnerName + "/" + testRepoName + "/" commit := util.URLJoin(repo, "commit", sha) tree := util.URLJoin(repo, "tree", sha, "src") diff --git a/modules/markup/main_test.go b/modules/markup/main_test.go new file mode 100644 index 0000000000000..a8f6f1c56469d --- /dev/null +++ b/modules/markup/main_test.go @@ -0,0 +1,14 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package markup_test + +import ( + "testing" + + "code.gitea.io/gitea/models/unittest" +) + +func TestMain(m *testing.M) { + unittest.MainTest(m) +} diff --git a/modules/markup/markdown/main_test.go b/modules/markup/markdown/main_test.go new file mode 100644 index 0000000000000..f33eeb13b2dc5 --- /dev/null +++ b/modules/markup/markdown/main_test.go @@ -0,0 +1,21 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package markdown + +import ( + "context" + "testing" + + "code.gitea.io/gitea/models/unittest" + "code.gitea.io/gitea/modules/markup" +) + +func TestMain(m *testing.M) { + markup.Init(&markup.ProcessorHelper{ + IsUsernameMentionable: func(ctx context.Context, username string) bool { + return username == "r-lyeh" + }, + }) + unittest.MainTest(m) +} diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go index bdf4011fa2486..a5b2c75c42372 100644 --- a/modules/markup/markdown/markdown_test.go +++ b/modules/markup/markdown/markdown_test.go @@ -5,12 +5,11 @@ package markdown_test import ( "context" - "os" "strings" "testing" - "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/markdown" @@ -21,29 +20,36 @@ import ( ) const ( - AppURL = "http://localhost:3000/" - Repo = "gogits/gogs" - AppSubURL = AppURL + Repo + "/" + AppURL = "http://localhost:3000/" + testRepoOwnerName = "user13" + testRepoName = "repo11" + AppSubURL = AppURL + testRepoOwnerName + "/" + testRepoName + "/" ) // these values should match the Repo const above var localMetas = map[string]string{ - "user": "gogits", - "repo": "gogs", - "repoPath": "../../../tests/gitea-repositories-meta/user13/repo11.git/", + "user": testRepoOwnerName, + "repo": testRepoName, } -func TestMain(m *testing.M) { - unittest.InitSettings() - if err := git.InitSimple(context.Background()); err != nil { - log.Fatal("git init failed, err: %v", err) +type mockRepo struct { + OwnerName string + RepoName string +} + +func (m *mockRepo) GetOwnerName() string { + return m.OwnerName +} + +func (m *mockRepo) GetName() string { + return m.RepoName +} + +func newMockRepo(ownerName, repoName string) gitrepo.Repository { + return &mockRepo{ + OwnerName: ownerName, + RepoName: repoName, } - markup.Init(&markup.ProcessorHelper{ - IsUsernameMentionable: func(ctx context.Context, username string) bool { - return username == "r-lyeh" - }, - }) - os.Exit(m.Run()) } func TestRender_StandardLinks(t *testing.T) { @@ -132,11 +138,11 @@ func testAnswers(baseURLContent, baseURLImages string) []string {
  • Links, Language bindings, Engine bindings
  • Tips
  • -

    See commit 65f1bf27bc

    +

    See commit 65f1bf27bc

    Ideas and codes

    • Bezier widget (by @r-lyeh) ocornut/imgui#786
    • -
    • Bezier widget (by @r-lyeh) #786
    • +
    • Bezier widget (by @r-lyeh) #786
    • Node graph editors https://github.com/ocornut/imgui/issues/306
    • Memory Editor
    • Plot var helper
    • @@ -221,7 +227,7 @@ See commit 65f1bf27bc Ideas and codes - Bezier widget (by @r-lyeh) ` + AppURL + `ocornut/imgui/issues/786 -- Bezier widget (by @r-lyeh) ` + AppURL + `gogits/gogs/issues/786 +- Bezier widget (by @r-lyeh) ` + AppURL + `user13/repo11/issues/786 - Node graph editors https://github.com/ocornut/imgui/issues/306 - [[Memory Editor|memory_editor_example]] - [[Plot var helper|plot_var_example]]`, @@ -299,6 +305,7 @@ func TestTotal_RenderWiki(t *testing.T) { Links: markup.Links{ Base: setting.AppSubURL, }, + Repo: newMockRepo(testRepoOwnerName, testRepoName), Metas: localMetas, IsWiki: true, }, sameCases[i]) @@ -345,6 +352,7 @@ func TestTotal_RenderString(t *testing.T) { Base: AppSubURL, BranchPath: "master", }, + Repo: newMockRepo(testRepoOwnerName, testRepoName), Metas: localMetas, }, sameCases[i]) assert.NoError(t, err) @@ -572,7 +580,7 @@ foo: bar } func TestRenderLinks(t *testing.T) { - input := ` space @mention-user + input := ` space @mention-user /just/a/path.bin https://example.com/file.bin [local link](file.bin) @@ -593,7 +601,7 @@ com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit mail@domain.com @mention-user test #123 - space + space ` cases := []struct { Links markup.Links From bc4459d515a13acc9fb8f730ef8a7deef6e2f40b Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 2 Mar 2024 17:38:08 +0800 Subject: [PATCH 4/6] Fix closer --- modules/markup/html.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/markup/html.go b/modules/markup/html.go index d00621c19a3d9..70da74c46dfa6 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -1146,13 +1146,14 @@ func hashCurrentPatternProcessor(ctx *RenderContext, node *html.Node) { if !inCache { if ctx.GitRepo == nil { var err error - ctx.GitRepo, _, err = gitrepo.RepositoryFromContextOrOpen(ctx.Ctx, ctx.Repo) + var closer io.Closer + ctx.GitRepo, closer, err = gitrepo.RepositoryFromContextOrOpen(ctx.Ctx, ctx.Repo) if err != nil { log.Error("unable to open repository: %s Error: %v", gitrepo.RepoGitURL(ctx.Repo), err) return } ctx.AddCancel(func() { - ctx.GitRepo.Close() + closer.Close() ctx.GitRepo = nil }) } From 0815c2910d6e4c8149c44966b12901943ce918a8 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 28 May 2024 11:42:50 +0800 Subject: [PATCH 5/6] Follow yp05327's suggestion --- modules/markup/markdown/markdown_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go index 818e9e48c4f7f..0414ca1133648 100644 --- a/modules/markup/markdown/markdown_test.go +++ b/modules/markup/markdown/markdown_test.go @@ -229,7 +229,7 @@ See commit 65f1bf27bc Ideas and codes - Bezier widget (by @r-lyeh) ` + AppURL + `ocornut/imgui/issues/786 -- Bezier widget (by @r-lyeh) ` + AppURL + `user13/repo11/issues/786 +- Bezier widget (by @r-lyeh) ` + FullURL + `issues/786 - Node graph editors https://github.com/ocornut/imgui/issues/306 - [[Memory Editor|memory_editor_example]] - [[Plot var helper|plot_var_example]]`, From c23b5b13fc13a0bedc37e74ce91b89bd0b51f591 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 29 May 2024 14:45:26 +0800 Subject: [PATCH 6/6] improve test --- modules/markup/markdown/markdown_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go index 0414ca1133648..b4a7efa8dd876 100644 --- a/modules/markup/markdown/markdown_test.go +++ b/modules/markup/markdown/markdown_test.go @@ -140,11 +140,11 @@ func testAnswers(baseURLContent, baseURLImages string) []string {
    • Links, Language bindings, Engine bindings
    • Tips
    -

    See commit 65f1bf27bc

    +

    See commit 65f1bf27bc

    Ideas and codes