Skip to content

Commit c2742e0

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Ensure that Chinese punctuation is not ambiguous when locale is Chinese (go-gitea#22019) Use GhostUser if needed for TrackedTimes (go-gitea#22021) Add dumb-init to rootless docker (go-gitea#21775) On tag/branch-exist check, dont panic if repo is nil (go-gitea#21787) Fix ListBranches to handle empty case (go-gitea#21921) fix(web): reduce page jitter on browsers that support overlay scrollbar (go-gitea#21850) [skip ci] Updated licenses and gitignores Do not emit ambiguous character warning on rendered pages (go-gitea#22016)
2 parents 6e6b6e6 + a08584e commit c2742e0

File tree

10 files changed

+78
-46
lines changed

10 files changed

+78
-46
lines changed

Dockerfile.rootless

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ EXPOSE 2222 3000
3131
RUN apk --no-cache add \
3232
bash \
3333
ca-certificates \
34+
dumb-init \
3435
gettext \
3536
git \
3637
curl \
@@ -68,6 +69,6 @@ ENV HOME "/var/lib/gitea/git"
6869
VOLUME ["/var/lib/gitea", "/etc/gitea"]
6970
WORKDIR /var/lib/gitea
7071

71-
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
72+
ENTRYPOINT ["/usr/bin/dumb-init", "--", "/usr/local/bin/docker-entrypoint.sh"]
7273
CMD []
7374

models/issues/tracked_time.go

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package issues
55

66
import (
77
"context"
8+
"errors"
89
"time"
910

1011
"code.gitea.io/gitea/models/db"
@@ -46,33 +47,41 @@ func (t *TrackedTime) LoadAttributes() (err error) {
4647
}
4748

4849
func (t *TrackedTime) loadAttributes(ctx context.Context) (err error) {
50+
// Load the issue
4951
if t.Issue == nil {
5052
t.Issue, err = GetIssueByID(ctx, t.IssueID)
51-
if err != nil {
52-
return
53+
if err != nil && !errors.Is(err, util.ErrNotExist) {
54+
return err
5355
}
56+
}
57+
// Now load the repo for the issue (which we may have just loaded)
58+
if t.Issue != nil {
5459
err = t.Issue.LoadRepo(ctx)
55-
if err != nil {
56-
return
60+
if err != nil && !errors.Is(err, util.ErrNotExist) {
61+
return err
5762
}
5863
}
64+
// Load the user
5965
if t.User == nil {
6066
t.User, err = user_model.GetUserByID(ctx, t.UserID)
6167
if err != nil {
62-
return
68+
if !errors.Is(err, util.ErrNotExist) {
69+
return err
70+
}
71+
t.User = user_model.NewGhostUser()
6372
}
6473
}
65-
return err
74+
return nil
6675
}
6776

6877
// LoadAttributes load Issue, User
69-
func (tl TrackedTimeList) LoadAttributes() (err error) {
78+
func (tl TrackedTimeList) LoadAttributes() error {
7079
for _, t := range tl {
71-
if err = t.LoadAttributes(); err != nil {
80+
if err := t.LoadAttributes(); err != nil {
7281
return err
7382
}
7483
}
75-
return err
84+
return nil
7685
}
7786

7887
// FindTrackedTimesOptions represent the filters for tracked times. If an ID is 0 it will be ignored.

modules/charset/ambiguous.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ func AmbiguousTablesForLocale(locale translation.Locale) []*AmbiguousTable {
2828
key = key[:idx]
2929
}
3030
}
31+
if table == nil && (locale.Language() == "zh-CN" || locale.Language() == "zh_CN") {
32+
table = AmbiguousCharacters["zh-hans"]
33+
}
34+
if table == nil && strings.HasPrefix(locale.Language(), "zh") {
35+
table = AmbiguousCharacters["zh-hant"]
36+
}
3137
if table == nil {
3238
table = AmbiguousCharacters["_default"]
3339
}

modules/convert/issue.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,11 @@ func ToAPIIssueList(ctx context.Context, il issues_model.IssueList) []*api.Issue
110110
// ToTrackedTime converts TrackedTime to API format
111111
func ToTrackedTime(ctx context.Context, t *issues_model.TrackedTime) (apiT *api.TrackedTime) {
112112
apiT = &api.TrackedTime{
113-
ID: t.ID,
114-
IssueID: t.IssueID,
115-
UserID: t.UserID,
116-
UserName: t.User.Name,
117-
Time: t.Time,
118-
Created: t.Created,
113+
ID: t.ID,
114+
IssueID: t.IssueID,
115+
UserID: t.UserID,
116+
Time: t.Time,
117+
Created: t.Created,
119118
}
120119
if t.Issue != nil {
121120
apiT.Issue = ToAPIIssue(ctx, t.Issue)

modules/git/repo_branch_nogogit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (repo *Repository) IsReferenceExist(name string) bool {
5252

5353
// IsBranchExist returns true if given branch exists in current repository.
5454
func (repo *Repository) IsBranchExist(name string) bool {
55-
if name == "" {
55+
if repo == nil || name == "" {
5656
return false
5757
}
5858

modules/git/repo_tag_nogogit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
// IsTagExist returns true if given tag exists in the repository.
1717
func (repo *Repository) IsTagExist(name string) bool {
18-
if name == "" {
18+
if repo == nil || name == "" {
1919
return false
2020
}
2121

options/gitignore/Bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/bazel-*
77

88
# Directories for the Bazel IntelliJ plugin containing the generated
9-
# IntelliJ project files and plugin configuration. Separate directories are
9+
# IntelliJ project files and plugin configuration. Seperate directories are
1010
# for the IntelliJ, Android Studio and CLion versions of the plugin.
1111
/.ijwb/
1212
/.aswb/

routers/api/v1/repo/branch.go

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -251,42 +251,50 @@ func ListBranches(ctx *context.APIContext) {
251251
// "200":
252252
// "$ref": "#/responses/BranchList"
253253

254+
var totalNumOfBranches int
255+
var apiBranches []*api.Branch
256+
254257
listOptions := utils.GetListOptions(ctx)
255-
skip, _ := listOptions.GetStartEnd()
256-
branches, totalNumOfBranches, err := ctx.Repo.GitRepo.GetBranches(skip, listOptions.PageSize)
257-
if err != nil {
258-
ctx.Error(http.StatusInternalServerError, "GetBranches", err)
259-
return
260-
}
261258

262-
apiBranches := make([]*api.Branch, 0, len(branches))
263-
for i := range branches {
264-
c, err := branches[i].GetCommit()
259+
if !ctx.Repo.Repository.IsEmpty && ctx.Repo.GitRepo != nil {
260+
skip, _ := listOptions.GetStartEnd()
261+
branches, total, err := ctx.Repo.GitRepo.GetBranches(skip, listOptions.PageSize)
265262
if err != nil {
266-
// Skip if this branch doesn't exist anymore.
267-
if git.IsErrNotExist(err) {
268-
totalNumOfBranches--
269-
continue
270-
}
271-
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
263+
ctx.Error(http.StatusInternalServerError, "GetBranches", err)
272264
return
273265
}
274-
branchProtection, err := git_model.GetProtectedBranchBy(ctx, ctx.Repo.Repository.ID, branches[i].Name)
275-
if err != nil {
276-
ctx.Error(http.StatusInternalServerError, "GetBranchProtection", err)
277-
return
278-
}
279-
apiBranch, err := convert.ToBranch(ctx.Repo.Repository, branches[i], c, branchProtection, ctx.Doer, ctx.Repo.IsAdmin())
280-
if err != nil {
281-
ctx.Error(http.StatusInternalServerError, "convert.ToBranch", err)
282-
return
266+
267+
apiBranches = make([]*api.Branch, 0, len(branches))
268+
for i := range branches {
269+
c, err := branches[i].GetCommit()
270+
if err != nil {
271+
// Skip if this branch doesn't exist anymore.
272+
if git.IsErrNotExist(err) {
273+
total--
274+
continue
275+
}
276+
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
277+
return
278+
}
279+
branchProtection, err := git_model.GetProtectedBranchBy(ctx, ctx.Repo.Repository.ID, branches[i].Name)
280+
if err != nil {
281+
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchBy", err)
282+
return
283+
}
284+
apiBranch, err := convert.ToBranch(ctx.Repo.Repository, branches[i], c, branchProtection, ctx.Doer, ctx.Repo.IsAdmin())
285+
if err != nil {
286+
ctx.Error(http.StatusInternalServerError, "convert.ToBranch", err)
287+
return
288+
}
289+
apiBranches = append(apiBranches, apiBranch)
283290
}
284-
apiBranches = append(apiBranches, apiBranch)
291+
292+
totalNumOfBranches = total
285293
}
286294

287295
ctx.SetLinkHeader(totalNumOfBranches, listOptions.PageSize)
288296
ctx.SetTotalCountHeader(int64(totalNumOfBranches))
289-
ctx.JSON(http.StatusOK, &apiBranches)
297+
ctx.JSON(http.StatusOK, apiBranches)
290298
}
291299

292300
// GetBranchProtection gets a branch protection

templates/repo/view_file.tmpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@
5858
</div>
5959
</h4>
6060
<div class="ui attached table unstackable segment">
61-
{{template "repo/unicode_escape_prompt" dict "EscapeStatus" .EscapeStatus "root" $}}
61+
{{if not (or .IsMarkup .IsRenderedHTML)}}
62+
{{template "repo/unicode_escape_prompt" dict "EscapeStatus" .EscapeStatus "root" $}}
63+
{{end}}
6264
<div class="file-view{{if .IsMarkup}} markup {{.MarkupType}}{{else if .IsRenderedHTML}} plain-text{{else if .IsTextSource}} code-view{{end}}">
6365
{{if .IsMarkup}}
6466
{{if .FileContent}}{{.FileContent | Safe}}{{end}}

web_src/less/_base.less

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,13 @@ body {
222222
overflow-wrap: break-word;
223223
}
224224

225+
@supports (overflow: overlay) {
226+
body {
227+
overflow: overlay;
228+
scrollbar-gutter: stable;
229+
}
230+
}
231+
225232
img {
226233
border-radius: 3px;
227234
}

0 commit comments

Comments
 (0)