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

26 files changed

+97
-72
lines changed

modules/markup/html.go

+1-1
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

+1
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

+1
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

+1
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

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
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

+2-2
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

-2
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

+1
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

+3-4
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

templates/base/head_navbar.tmpl

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{{end}}
55

66
<nav id="navbar" aria-label="{{ctx.Locale.Tr "aria.navbar"}}">
7-
<div class="navbar-left ui secondary menu">
7+
<div class="navbar-left">
88
<!-- the logo -->
99
<a class="item" id="navbar-logo" href="{{AppSubUrl}}/" aria-label="{{if .IsSigned}}{{ctx.Locale.Tr "dashboard"}}{{else}}{{ctx.Locale.Tr "home"}}{{end}}">
1010
<img width="30" height="30" src="{{AssetUrlPrefix}}/img/logo.svg" alt="{{ctx.Locale.Tr "logo"}}" aria-hidden="true">
@@ -63,7 +63,7 @@
6363
</div>
6464

6565
<!-- the full dropdown menus -->
66-
<div class="navbar-right ui secondary menu">
66+
<div class="navbar-right">
6767
{{if and .IsSigned .MustChangePassword}}
6868
<div class="ui dropdown jump item" data-tooltip-content="{{ctx.Locale.Tr "user_profile_and_more"}}">
6969
<span class="text tw-flex tw-items-center">
@@ -106,7 +106,7 @@
106106
<span class="not-mobile">{{svg "octicon-triangle-down"}}</span>
107107
<span class="only-mobile">{{ctx.Locale.Tr "create_new"}}</span>
108108
</span>
109-
<div class="menu left">
109+
<div class="menu">
110110
<a class="item" href="{{AppSubUrl}}/repo/create">
111111
{{svg "octicon-plus"}} {{ctx.Locale.Tr "new_repo"}}
112112
</a>

templates/repo/blame.tmpl

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
<div class="file-view code-view unicode-escaped">
3333
{{if .IsFileTooLarge}}
3434
{{template "shared/filetoolarge" dict "RawFileLink" .RawFileLink}}
35+
{{else if not .FileSize}}
36+
{{template "shared/fileisempty"}}
3537
{{else}}
3638
<table>
3739
<tbody>

templates/repo/file_info.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
{{ctx.Locale.Tr "repo.symbolic_link"}}
55
</div>
66
{{end}}
7-
{{if .NumLinesSet}}{{/* Explicit attribute needed to show 0 line changes */}}
7+
{{if ne .NumLines nil}}
88
<div class="file-info-entry">
99
{{.NumLines}} {{ctx.Locale.TrN .NumLines "repo.line" "repo.lines"}}
1010
</div>
1111
{{end}}
12-
{{if .FileSize}}
12+
{{if ne .FileSize nil}}
1313
<div class="file-info-entry">
1414
{{FileSize .FileSize}}{{if .IsLFSFile}} ({{ctx.Locale.Tr "repo.stored_lfs"}}){{end}}
1515
</div>

templates/repo/issue/labels/label_list.tmpl

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
<h4 class="ui top attached header">
22
{{ctx.Locale.Tr "repo.issues.label_count" .NumLabels}}
33
<div class="ui right">
4-
<div class="ui secondary menu">
5-
<!-- Sort -->
6-
<div class="item ui jump dropdown tw-py-2">
7-
<span class="text">
8-
{{ctx.Locale.Tr "repo.issues.filter_sort"}}
9-
</span>
10-
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
11-
<div class="menu">
12-
<a class="{{if or (eq .SortType "alphabetically") (not .SortType)}}active {{end}}item" href="?sort=alphabetically&state={{$.State}}">{{ctx.Locale.Tr "repo.issues.label.filter_sort.alphabetically"}}</a>
13-
<a class="{{if eq .SortType "reversealphabetically"}}active {{end}}item" href="?sort=reversealphabetically&state={{$.State}}">{{ctx.Locale.Tr "repo.issues.label.filter_sort.reverse_alphabetically"}}</a>
14-
<a class="{{if eq .SortType "leastissues"}}active {{end}}item" href="?sort=leastissues&state={{$.State}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.least_issues"}}</a>
15-
<a class="{{if eq .SortType "mostissues"}}active {{end}}item" href="?sort=mostissues&state={{$.State}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.most_issues"}}</a>
16-
</div>
4+
<!-- Sort -->
5+
<div class="item ui jump dropdown tw-py-2">
6+
<span class="text">
7+
{{ctx.Locale.Tr "repo.issues.filter_sort"}}
8+
</span>
9+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
10+
<div class="menu">
11+
<a class="{{if or (eq .SortType "alphabetically") (not .SortType)}}active {{end}}item" href="?sort=alphabetically&state={{$.State}}">{{ctx.Locale.Tr "repo.issues.label.filter_sort.alphabetically"}}</a>
12+
<a class="{{if eq .SortType "reversealphabetically"}}active {{end}}item" href="?sort=reversealphabetically&state={{$.State}}">{{ctx.Locale.Tr "repo.issues.label.filter_sort.reverse_alphabetically"}}</a>
13+
<a class="{{if eq .SortType "leastissues"}}active {{end}}item" href="?sort=leastissues&state={{$.State}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.least_issues"}}</a>
14+
<a class="{{if eq .SortType "mostissues"}}active {{end}}item" href="?sort=mostissues&state={{$.State}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.most_issues"}}</a>
1715
</div>
1816
</div>
1917
</div> <!-- filter menu -->

templates/repo/settings/lfs_file.tmpl

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
<div class="file-view{{if .IsMarkup}} markup {{.MarkupType}}{{else if .IsPlainText}} plain-text{{else if .IsTextFile}} code-view{{end}}">
1717
{{if .IsFileTooLarge}}
1818
{{template "shared/filetoolarge" dict "RawFileLink" .RawFileLink}}
19-
{{else if .IsMarkup}}
20-
{{if .FileContent}}{{.FileContent | SafeHTML}}{{end}}
21-
{{else if .IsPlainText}}
22-
<pre>{{if .FileContent}}{{.FileContent | SafeHTML}}{{end}}</pre>
19+
{{else if not .FileSize}}
20+
{{template "shared/fileisempty"}}
2321
{{else if not .IsTextFile}}
2422
<div class="view-raw">
2523
{{if .IsImageFile}}

templates/repo/view_file.tmpl

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
<div class="file-view{{if .IsMarkup}} markup {{.MarkupType}}{{else if .IsPlainText}} plain-text{{else if .IsTextSource}} code-view{{end}}">
9292
{{if .IsFileTooLarge}}
9393
{{template "shared/filetoolarge" dict "RawFileLink" .RawFileLink}}
94+
{{else if not .FileSize}}
95+
{{template "shared/fileisempty"}}
9496
{{else if .IsMarkup}}
9597
{{if .FileContent}}{{.FileContent}}{{end}}
9698
{{else if .IsPlainText}}

templates/shared/fileisempty.tmpl

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="file-not-rendered-prompt">
2+
{{ctx.Locale.Tr "repo.file_is_empty"}}
3+
</div>

templates/shared/filetoolarge.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="tw-p-4">
1+
<div class="file-not-rendered-prompt">
22
{{ctx.Locale.Tr "repo.file_too_large"}}
33
{{if .RawFileLink}}<a href="{{.RawFileLink}}" rel="nofollow">{{ctx.Locale.Tr "repo.file_view_raw"}}</a>{{end}}
44
</div>

templates/shared/user/profile_big_avatar.tmpl

+2-10
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,8 @@
4848
<li>
4949
{{svg "octicon-mail"}}
5050
<a class="tw-flex-1" href="mailto:{{.ContextUser.Email}}" rel="nofollow">{{.ContextUser.Email}}</a>
51-
<a href="{{AppSubUrl}}/user/settings#privacy-user-settings">
52-
{{if .ShowUserEmail}}
53-
<i data-tooltip-content="{{ctx.Locale.Tr "user.email_visibility.limited"}}">
54-
{{svg "octicon-unlock"}}
55-
</i>
56-
{{else}}
57-
<i data-tooltip-content="{{ctx.Locale.Tr "user.email_visibility.private"}}">
58-
{{svg "octicon-lock"}}
59-
</i>
60-
{{end}}
51+
<a class="flex-text-inline" href="{{AppSubUrl}}/user/settings#privacy-user-settings" data-tooltip-content="{{ctx.Locale.Tr (Iif .ShowUserEmail "user.email_visibility.limited" "user.email_visibility.private")}}">
52+
{{svg (Iif .ShowUserEmail "octicon-unlock" "octicon-lock")}}
6153
</a>
6254
</li>
6355
{{else}}

templates/user/dashboard/issues.tmpl

+1-5
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@
5151
<input type="hidden" name="type" value="{{$.ViewType}}">
5252
<input type="hidden" name="sort" value="{{$.SortType}}">
5353
<input type="hidden" name="state" value="{{$.State}}">
54-
{{if .PageIsPulls}}
55-
{{template "shared/search/combo_fuzzy" dict "Value" $.Keyword "IsFuzzy" $.IsFuzzy "Placeholder" (ctx.Locale.Tr "search.pull_kind") "Tooltip" (ctx.Locale.Tr "explorer.go")}}
56-
{{else}}
57-
{{template "shared/search/combo_fuzzy" dict "Value" $.Keyword "IsFuzzy" $.IsFuzzy "Placeholder" (ctx.Locale.Tr "search.issue_kind") "Tooltip" (ctx.Locale.Tr "explorer.go")}}
58-
{{end}}
54+
{{template "shared/search/combo_fuzzy" dict "Value" $.Keyword "IsFuzzy" $.IsFuzzy "Placeholder" (ctx.Locale.Tr (Iif .PageIsPulls "search.pull_kind" "search.issue_kind")) "Tooltip" (ctx.Locale.Tr "explore.go_to")}}
5955
</div>
6056
</form>
6157
<!-- Sort -->

web_src/css/base.css

+9
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,13 @@ overflow-menu .ui.label {
10011001
padding: 0 8px;
10021002
text-align: right !important;
10031003
color: var(--color-text-light-2);
1004+
width: 1%; /* this apparently needs to be a percentage so that code column stretches in diffs */
1005+
min-width: 72px;
1006+
white-space: nowrap;
1007+
}
1008+
1009+
.code-diff .lines-num {
1010+
min-width: 50px;
10041011
}
10051012

10061013
.lines-num span.bottom-line::after {
@@ -1020,6 +1027,7 @@ overflow-menu .ui.label {
10201027

10211028
.lines-type-marker {
10221029
vertical-align: top;
1030+
white-space: nowrap;
10231031
}
10241032

10251033
.lines-num,
@@ -1052,6 +1060,7 @@ overflow-menu .ui.label {
10521060

10531061
.lines-escape {
10541062
width: 0;
1063+
white-space: nowrap;
10551064
}
10561065

10571066
.lines-code {

web_src/css/modules/header.css

-6
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,6 @@ h4.ui.header .sub.header {
134134
font-weight: var(--font-weight-normal);
135135
}
136136

137-
/* open dropdown menus to the left in right-attached headers */
138-
.ui.attached.header > .ui.right .ui.dropdown .menu {
139-
right: 0;
140-
left: auto;
141-
}
142-
143137
/* if a .top.attached.header is followed by a .segment, add some margin */
144138
.ui.segments + .ui.top.attached.header,
145139
.ui.attached.segment + .ui.top.attached.header {

web_src/css/modules/navbar.css

+15-5
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,26 @@
1919
margin: 0;
2020
display: flex;
2121
align-items: center;
22+
gap: 5px;
2223
}
2324

2425
#navbar-logo {
2526
margin: 0;
2627
}
2728

29+
.navbar-left > .item,
30+
.navbar-right > .item {
31+
color: var(--color-nav-text);
32+
position: relative;
33+
text-decoration: none;
34+
line-height: var(--line-height-default);
35+
flex: 0 0 auto;
36+
font-weight: var(--font-weight-normal);
37+
align-items: center;
38+
padding: .78571429em .92857143em;
39+
border-radius: .28571429rem;
40+
}
41+
2842
#navbar .item {
2943
min-height: 36px;
3044
min-width: 36px;
@@ -33,10 +47,6 @@
3347
display: flex;
3448
}
3549

36-
#navbar > .menu > .item {
37-
color: var(--color-nav-text);
38-
}
39-
4050
#navbar .dropdown .item {
4151
justify-content: stretch;
4252
}
@@ -70,7 +80,7 @@
7080
}
7181
#navbar .navbar-mobile-right {
7282
display: flex;
73-
margin-left: auto !important;
83+
margin: 0 0 0 auto !important;
7484
width: auto !important;
7585
}
7686
#navbar .navbar-mobile-right > .item {

0 commit comments

Comments
 (0)