loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request 'fix: include last line in file previews with no trailing newline' (#5085) from solomonv/fix-previews-without-trailing-eol into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5085
Reviewed-by: Gusted <gusted@noreply.codeberg.org>

Gusted d34d8ec2 4f549183

+39 -4
+4 -1
modules/markup/file_preview.go
··· 7 7 "bufio" 8 8 "bytes" 9 9 "html/template" 10 + "io" 10 11 "regexp" 11 12 "slices" 12 13 "strconv" ··· 184 185 lineBuffer := new(bytes.Buffer) 185 186 for i := 0; i < lineCount; i++ { 186 187 buf, err := reader.ReadBytes('\n') 188 + if err == nil || err == io.EOF { 189 + lineBuffer.Write(buf) 190 + } 187 191 if err != nil { 188 192 break 189 193 } 190 - lineBuffer.Write(buf) 191 194 } 192 195 193 196 // highlight the file...
+34 -2
modules/markup/html_test.go
··· 688 688 require.NoError(t, err) 689 689 defer gitRepo.Close() 690 690 691 - commit, err := gitRepo.GetCommit("HEAD") 691 + commit, err := gitRepo.GetCommit(commitSha) 692 692 require.NoError(t, err) 693 693 694 - blob, err := commit.GetBlobByPath("path/to/file.go") 694 + blob, err := commit.GetBlobByPath(filePath) 695 695 require.NoError(t, err) 696 696 697 697 return blob, nil ··· 768 768 `<tr>`+ 769 769 `<td class="lines-num"><span data-line-number="3"></span></td>`+ 770 770 `<td class="lines-code chroma"><code class="code-inner"><span class="nx">C</span>`+"\n"+`</code></td>`+ 771 + `</tr>`+ 772 + `</tbody>`+ 773 + `</table>`+ 774 + `</div>`+ 775 + `</div>`+ 776 + `<p></p>`, 777 + map[string]string{ 778 + "user": "gogits", 779 + "repo": "gogs2", 780 + }, 781 + ) 782 + }) 783 + t.Run("single-line", func(t *testing.T) { 784 + testRender( 785 + util.URLJoin(markup.TestRepoURL, "src", "commit", "4c1aaf56bcb9f39dcf65f3f250726850aed13cd6", "single-line.txt")+"#L1", 786 + `<p></p>`+ 787 + `<div class="file-preview-box">`+ 788 + `<div class="header">`+ 789 + `<div>`+ 790 + `<a href="http://localhost:3000/gogits/gogs/" rel="nofollow">gogits/gogs</a> – `+ 791 + `<a href="http://localhost:3000/gogits/gogs/src/commit/4c1aaf56bcb9f39dcf65f3f250726850aed13cd6/single-line.txt#L1" class="muted" rel="nofollow">single-line.txt</a>`+ 792 + `</div>`+ 793 + `<span class="text small grey">`+ 794 + `Line 1 in <a href="http://localhost:3000/gogits/gogs/src/commit/4c1aaf56bcb9f39dcf65f3f250726850aed13cd6" class="text black" rel="nofollow">gogits/gogs@4c1aaf5</a>`+ 795 + `</span>`+ 796 + `</div>`+ 797 + `<div class="ui table">`+ 798 + `<table class="file-preview">`+ 799 + `<tbody>`+ 800 + `<tr>`+ 801 + `<td class="lines-num"><span data-line-number="1"></span></td>`+ 802 + `<td class="lines-code chroma"><code class="code-inner">A`+`</code></td>`+ 771 803 `</tr>`+ 772 804 `</tbody>`+ 773 805 `</table>`+
modules/markup/tests/repo/repo1_filepreview/objects/3f/ed9bce8610a52048747f627b3863374642c85c

This is a binary file and will not be displayed.

modules/markup/tests/repo/repo1_filepreview/objects/4c/1aaf56bcb9f39dcf65f3f250726850aed13cd6

This is a binary file and will not be displayed.

modules/markup/tests/repo/repo1_filepreview/objects/8c/7e5a667f1b771847fe88c01c3de34413a1b220

This is a binary file and will not be displayed.

+1 -1
modules/markup/tests/repo/repo1_filepreview/refs/heads/master
··· 1 - 190d9492934af498c3f669d6a2431dc5459e5b20 1 + 4c1aaf56bcb9f39dcf65f3f250726850aed13cd6