Skip to content

Commit 5b45fc8

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Fixed incorrect localization `explorer.go` (go-gitea#31348) Improve detecting empty files (go-gitea#31332) Fix hash render end with colon (go-gitea#31319) Fix line number widths (go-gitea#31341) Fix navbar `+` menu flashing on page load (go-gitea#31281) Reduce memory usage for chunked artifact uploads to MinIO (go-gitea#31325) Fix dates displaying in a wrong manner when we're close to the end of the month (go-gitea#31331) Fix adopt repository has empty object name in database (go-gitea#31333) Optimize profile layout to enhance visual experience (go-gitea#31278)
2 parents 66bf728 + fede3cb commit 5b45fc8

File tree

26 files changed

+97
-72
lines changed

26 files changed

+97
-72
lines changed

modules/markup/html.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var (
4949
// hashCurrentPattern matches string that represents a commit SHA, e.g. d8a994ef243349f321568f9e36d5c3f444b99cae
5050
// Although SHA1 hashes are 40 chars long, SHA256 are 64, the regex matches the hash from 7 to 64 chars in length
5151
// so that abbreviated hash links can be used as well. This matches git and GitHub usability.
52-
hashCurrentPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-f]{7,64})(?:\s|$|\)|\]|[.,](\s|$))`)
52+
hashCurrentPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-f]{7,64})(?:\s|$|\)|\]|[.,:](\s|$))`)
5353

5454
// shortLinkPattern matches short but difficult to parse [[name|link|arg=test]] syntax
5555
shortLinkPattern = regexp.MustCompile(`\[\[(.*?)\]\](\w*)`)

modules/markup/html_internal_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ func TestRegExp_sha1CurrentPattern(t *testing.T) {
380380
"(abcdefabcdefabcdefabcdefabcdefabcdefabcd)",
381381
"[abcdefabcdefabcdefabcdefabcdefabcdefabcd]",
382382
"abcdefabcdefabcdefabcdefabcdefabcdefabcd.",
383+
"abcdefabcdefabcdefabcdefabcdefabcdefabcd:",
383384
}
384385
falseTestCases := []string{
385386
"test",

modules/repository/branch.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func SyncRepoBranchesWithRepo(ctx context.Context, repo *repo_model.Repository,
4545
if err != nil {
4646
return 0, fmt.Errorf("UpdateRepository: %w", err)
4747
}
48+
repo.ObjectFormatName = objFmt.Name() // keep consistent with db
4849

4950
allBranches := container.Set[string]{}
5051
{

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,7 @@ file_view_rendered = View Rendered
12381238
file_view_raw = View Raw
12391239
file_permalink = Permalink
12401240
file_too_large = The file is too large to be shown.
1241+
file_is_empty = The file is empty.
12411242
code_preview_line_from_to = Lines %[1]d to %[2]d in %[3]s
12421243
code_preview_line_in = Line %[1]d in %[2]s
12431244
invisible_runes_header = `This file contains invisible Unicode characters`

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"@citation-js/plugin-csl": "0.7.11",
1010
"@citation-js/plugin-software-formats": "0.6.1",
1111
"@github/markdown-toolbar-element": "2.2.3",
12-
"@github/relative-time-element": "4.4.1",
12+
"@github/relative-time-element": "4.4.2",
1313
"@github/text-expander-element": "2.6.1",
1414
"@mcaptcha/vanilla-glue": "0.1.0-alpha-3",
1515
"@primer/octicons": "19.9.0",

routers/api/actions/artifacts_chunks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func saveUploadChunkBase(st storage.ObjectStorage, ctx *ArtifactContext,
3939
r = io.TeeReader(r, hasher)
4040
}
4141
// save chunk to storage
42-
writtenSize, err := st.Save(storagePath, r, -1)
42+
writtenSize, err := st.Save(storagePath, r, contentSize)
4343
if err != nil {
4444
return -1, fmt.Errorf("save chunk to storage error: %v", err)
4545
}
@@ -208,7 +208,7 @@ func mergeChunksForArtifact(ctx *ArtifactContext, chunks []*chunkFileItem, st st
208208

209209
// save merged file
210210
storagePath := fmt.Sprintf("%d/%d/%d.%s", artifact.RunID%255, artifact.ID%255, time.Now().UnixNano(), extension)
211-
written, err := st.Save(storagePath, mergedReader, -1)
211+
written, err := st.Save(storagePath, mergedReader, artifact.FileCompressedSize)
212212
if err != nil {
213213
return fmt.Errorf("save merged file error: %v", err)
214214
}

routers/web/repo/blame.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ func RefBlame(ctx *context.Context) {
9999
}
100100

101101
ctx.Data["NumLines"], err = blob.GetBlobLineCount()
102-
ctx.Data["NumLinesSet"] = true
103-
104102
if err != nil {
105103
ctx.NotFound("GetBlobLineCount", err)
106104
return

routers/web/repo/setting/lfs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ func LFSFileGet(ctx *context.Context) {
303303
rd := charset.ToUTF8WithFallbackReader(io.MultiReader(bytes.NewReader(buf), dataRc), charset.ConvertOpts{})
304304

305305
// Building code view blocks with line number on server side.
306+
// FIXME: the logic is not right here: it first calls EscapeControlReader then calls HTMLEscapeString: double-escaping
306307
escapedContent := &bytes.Buffer{}
307308
ctx.Data["EscapeStatus"], _ = charset.EscapeControlReader(rd, escapedContent, ctx.Locale)
308309

routers/web/repo/view.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ func renderReadmeFile(ctx *context.Context, subfolder string, readmeFile *git.Tr
286286

287287
ctx.Data["FileIsText"] = fInfo.isTextFile
288288
ctx.Data["FileName"] = path.Join(subfolder, readmeFile.Name())
289+
ctx.Data["FileSize"] = fInfo.fileSize
289290
ctx.Data["IsLFSFile"] = fInfo.isLFSFile
290291

291292
if fInfo.isLFSFile {
@@ -301,7 +302,6 @@ func renderReadmeFile(ctx *context.Context, subfolder string, readmeFile *git.Tr
301302
// Pretend that this is a normal text file to display 'This file is too large to be shown'
302303
ctx.Data["IsFileTooLarge"] = true
303304
ctx.Data["IsTextFile"] = true
304-
ctx.Data["FileSize"] = fInfo.fileSize
305305
return
306306
}
307307

@@ -552,7 +552,6 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry) {
552552
} else {
553553
ctx.Data["NumLines"] = bytes.Count(buf, []byte{'\n'}) + 1
554554
}
555-
ctx.Data["NumLinesSet"] = true
556555

557556
language, err := files_service.TryGetContentLanguage(ctx.Repo.GitRepo, ctx.Repo.CommitID, ctx.Repo.TreePath)
558557
if err != nil {
@@ -606,8 +605,8 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry) {
606605
break
607606
}
608607

609-
// TODO: this logic seems strange, it duplicates with "isRepresentableAsText=true", it is not the same as "LFSFileGet" in "lfs.go"
610-
// maybe for this case, the file is a binary file, and shouldn't be rendered?
608+
// TODO: this logic duplicates with "isRepresentableAsText=true", it is not the same as "LFSFileGet" in "lfs.go"
609+
// It is used by "external renders", markupRender will execute external programs to get rendered content.
611610
if markupType := markup.Type(blob.Name()); markupType != "" {
612611
rd := io.MultiReader(bytes.NewReader(buf), dataRc)
613612
ctx.Data["IsMarkup"] = true

0 commit comments

Comments
 (0)