Skip to content

Commit 24b0634

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: [skip ci] Updated licenses and gitignores Fix repo home row-right grow (go-gitea#32763) Refactor issue list (go-gitea#32755) Fix compare page bug view as anonymous (go-gitea#32754) Split issue/pull view router function as multiple smaller functions (go-gitea#32749) fix: render job title as commit message (go-gitea#32748) Fix typescript errors in Vue files, fix regression in "Recent Commits" chart (go-gitea#32649) Refactor LabelEdit (go-gitea#32752) [skip ci] Updated translations via Crowdin fix(project): add title to project view page (go-gitea#32747) [skip ci] Updated translations via Crowdin Fix case of .tsbuildinfo in .gitignore (go-gitea#32737) Support "merge upstream branch" (Sync fork) (go-gitea#32741) Update changelog to add missed changelog (go-gitea#32734) GitHub like repo home page (go-gitea#32213) Refactor markdown render (go-gitea#32736) Make wiki pages visit fast (go-gitea#32732) Refactor markdown render (go-gitea#32728) Refactor RepoActionView.vue, add `::group::` support (go-gitea#32713)
2 parents 5b3d5b9 + 145b583 commit 24b0634

File tree

115 files changed

+4640
-2512
lines changed

Some content is hidden

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

115 files changed

+4640
-2512
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ _testmain.go
2828
*.exe
2929
*.test
3030
*.prof
31-
*.tsbuildInfo
31+
*.tsbuildinfo
3232

3333
*coverage.out
3434
coverage.all

CHANGELOG.md

Lines changed: 393 additions & 0 deletions
Large diffs are not rendered by default.

modules/git/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func Push(ctx context.Context, repoPath string, opts PushOptions) error {
223223
if err != nil {
224224
if strings.Contains(stderr, "non-fast-forward") {
225225
return &ErrPushOutOfDate{StdOut: stdout, StdErr: stderr, Err: err}
226-
} else if strings.Contains(stderr, "! [remote rejected]") {
226+
} else if strings.Contains(stderr, "! [remote rejected]") || strings.Contains(stderr, "! [rejected]") {
227227
err := &ErrPushRejected{StdOut: stdout, StdErr: stderr, Err: err}
228228
err.GenerateMessage()
229229
return err
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright 2024 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package markdown_test
5+
6+
import (
7+
"strings"
8+
"testing"
9+
10+
"code.gitea.io/gitea/modules/markup"
11+
"code.gitea.io/gitea/modules/markup/markdown"
12+
"code.gitea.io/gitea/modules/svg"
13+
14+
"github.com/stretchr/testify/assert"
15+
"golang.org/x/text/cases"
16+
"golang.org/x/text/language"
17+
)
18+
19+
func TestAttention(t *testing.T) {
20+
defer svg.MockIcon("octicon-info")()
21+
defer svg.MockIcon("octicon-light-bulb")()
22+
defer svg.MockIcon("octicon-report")()
23+
defer svg.MockIcon("octicon-alert")()
24+
defer svg.MockIcon("octicon-stop")()
25+
26+
renderAttention := func(attention, icon string) string {
27+
tmpl := `<blockquote class="attention-header attention-{attention}"><p><svg class="attention-icon attention-{attention} svg {icon}" width="16" height="16"></svg><strong class="attention-{attention}">{Attention}</strong></p>`
28+
tmpl = strings.ReplaceAll(tmpl, "{attention}", attention)
29+
tmpl = strings.ReplaceAll(tmpl, "{icon}", icon)
30+
tmpl = strings.ReplaceAll(tmpl, "{Attention}", cases.Title(language.English).String(attention))
31+
return tmpl
32+
}
33+
34+
test := func(input, expected string) {
35+
result, err := markdown.RenderString(markup.NewTestRenderContext(), input)
36+
assert.NoError(t, err)
37+
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(string(result)))
38+
}
39+
40+
test(`
41+
> [!NOTE]
42+
> text
43+
`, renderAttention("note", "octicon-info")+"\n<p>text</p>\n</blockquote>")
44+
45+
test(`> [!note]`, renderAttention("note", "octicon-info")+"\n</blockquote>")
46+
test(`> [!tip]`, renderAttention("tip", "octicon-light-bulb")+"\n</blockquote>")
47+
test(`> [!important]`, renderAttention("important", "octicon-report")+"\n</blockquote>")
48+
test(`> [!warning]`, renderAttention("warning", "octicon-alert")+"\n</blockquote>")
49+
test(`> [!caution]`, renderAttention("caution", "octicon-stop")+"\n</blockquote>")
50+
51+
// escaped by mdformat
52+
test(`> \[!NOTE\]`, renderAttention("note", "octicon-info")+"\n</blockquote>")
53+
54+
// legacy GitHub style
55+
test(`> **warning**`, renderAttention("warning", "octicon-alert")+"\n</blockquote>")
56+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2024 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package markdown_test
5+
6+
import (
7+
"testing"
8+
9+
"code.gitea.io/gitea/modules/markup"
10+
"code.gitea.io/gitea/modules/markup/markdown"
11+
)
12+
13+
func BenchmarkSpecializedMarkdown(b *testing.B) {
14+
// 240856 4719 ns/op
15+
for i := 0; i < b.N; i++ {
16+
markdown.SpecializedMarkdown(&markup.RenderContext{})
17+
}
18+
}
19+
20+
func BenchmarkMarkdownRender(b *testing.B) {
21+
// 23202 50840 ns/op
22+
for i := 0; i < b.N; i++ {
23+
_, _ = markdown.RenderString(markup.NewTestRenderContext(), "https://example.com\n- a\n- b\n")
24+
}
25+
}
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
// Copyright 2024 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package markdown
5+
6+
import (
7+
"strings"
8+
"testing"
9+
10+
"code.gitea.io/gitea/modules/markup"
11+
12+
"github.com/stretchr/testify/assert"
13+
)
14+
15+
func TestMathRender(t *testing.T) {
16+
const nl = "\n"
17+
testcases := []struct {
18+
testcase string
19+
expected string
20+
}{
21+
{
22+
"$a$",
23+
`<p><code class="language-math is-loading">a</code></p>` + nl,
24+
},
25+
{
26+
"$ a $",
27+
`<p><code class="language-math is-loading">a</code></p>` + nl,
28+
},
29+
{
30+
"$a$ $b$",
31+
`<p><code class="language-math is-loading">a</code> <code class="language-math is-loading">b</code></p>` + nl,
32+
},
33+
{
34+
`\(a\) \(b\)`,
35+
`<p><code class="language-math is-loading">a</code> <code class="language-math is-loading">b</code></p>` + nl,
36+
},
37+
{
38+
`$a$.`,
39+
`<p><code class="language-math is-loading">a</code>.</p>` + nl,
40+
},
41+
{
42+
`.$a$`,
43+
`<p>.$a$</p>` + nl,
44+
},
45+
{
46+
`$a a$b b$`,
47+
`<p>$a a$b b$</p>` + nl,
48+
},
49+
{
50+
`a a$b b`,
51+
`<p>a a$b b</p>` + nl,
52+
},
53+
{
54+
`a$b $a a$b b$`,
55+
`<p>a$b $a a$b b$</p>` + nl,
56+
},
57+
{
58+
"a$x$",
59+
`<p>a$x$</p>` + nl,
60+
},
61+
{
62+
"$x$a",
63+
`<p>$x$a</p>` + nl,
64+
},
65+
{
66+
"$a$ ($b$) [$c$] {$d$}",
67+
`<p><code class="language-math is-loading">a</code> (<code class="language-math is-loading">b</code>) [$c$] {$d$}</p>` + nl,
68+
},
69+
{
70+
"$$a$$",
71+
`<code class="chroma language-math display">a</code>` + nl,
72+
},
73+
{
74+
"$$a$$ test",
75+
`<p><code class="language-math display is-loading">a</code> test</p>` + nl,
76+
},
77+
{
78+
"test $$a$$",
79+
`<p>test <code class="language-math display is-loading">a</code></p>` + nl,
80+
},
81+
{
82+
`foo $x=\$$ bar`,
83+
`<p>foo <code class="language-math is-loading">x=\$</code> bar</p>` + nl,
84+
},
85+
{
86+
`$\text{$b$}$`,
87+
`<p><code class="language-math is-loading">\text{$b$}</code></p>` + nl,
88+
},
89+
}
90+
91+
for _, test := range testcases {
92+
t.Run(test.testcase, func(t *testing.T) {
93+
res, err := RenderString(markup.NewTestRenderContext(), test.testcase)
94+
assert.NoError(t, err)
95+
assert.Equal(t, test.expected, string(res))
96+
})
97+
}
98+
}
99+
100+
func TestMathRenderBlockIndent(t *testing.T) {
101+
testcases := []struct {
102+
name string
103+
testcase string
104+
expected string
105+
}{
106+
{
107+
"indent-0",
108+
`
109+
\[
110+
\alpha
111+
\]
112+
`,
113+
`<pre class="code-block is-loading"><code class="chroma language-math display">
114+
\alpha
115+
</code></pre>
116+
`,
117+
},
118+
{
119+
"indent-1",
120+
`
121+
\[
122+
\alpha
123+
\]
124+
`,
125+
`<pre class="code-block is-loading"><code class="chroma language-math display">
126+
\alpha
127+
</code></pre>
128+
`,
129+
},
130+
{
131+
"indent-2-mismatch",
132+
`
133+
\[
134+
a
135+
b
136+
c
137+
d
138+
\]
139+
`,
140+
`<pre class="code-block is-loading"><code class="chroma language-math display">
141+
a
142+
b
143+
c
144+
d
145+
</code></pre>
146+
`,
147+
},
148+
{
149+
"indent-2",
150+
`
151+
\[
152+
a
153+
b
154+
c
155+
\]
156+
`,
157+
`<pre class="code-block is-loading"><code class="chroma language-math display">
158+
a
159+
b
160+
c
161+
</code></pre>
162+
`,
163+
},
164+
{
165+
"indent-0-oneline",
166+
`$$ x $$
167+
foo`,
168+
`<code class="chroma language-math display"> x </code>
169+
<p>foo</p>
170+
`,
171+
},
172+
{
173+
"indent-3-oneline",
174+
` $$ x $$<SPACE>
175+
foo`,
176+
`<code class="chroma language-math display"> x </code>
177+
<p>foo</p>
178+
`,
179+
},
180+
{
181+
"quote-block",
182+
`
183+
> \[
184+
> a
185+
> \]
186+
> \[
187+
> b
188+
> \]
189+
`,
190+
`<blockquote>
191+
<pre class="code-block is-loading"><code class="chroma language-math display">
192+
a
193+
</code></pre>
194+
<pre class="code-block is-loading"><code class="chroma language-math display">
195+
b
196+
</code></pre>
197+
</blockquote>
198+
`,
199+
},
200+
{
201+
"list-block",
202+
`
203+
1. a
204+
\[
205+
x
206+
\]
207+
2. b`,
208+
`<ol>
209+
<li>a
210+
<pre class="code-block is-loading"><code class="chroma language-math display">
211+
x
212+
</code></pre>
213+
</li>
214+
<li>b</li>
215+
</ol>
216+
`,
217+
},
218+
}
219+
220+
for _, test := range testcases {
221+
t.Run(test.name, func(t *testing.T) {
222+
res, err := RenderString(markup.NewTestRenderContext(), strings.ReplaceAll(test.testcase, "<SPACE>", " "))
223+
assert.NoError(t, err)
224+
assert.Equal(t, test.expected, string(res), "unexpected result for test case:\n%s", test.testcase)
225+
})
226+
}
227+
}

0 commit comments

Comments
 (0)