Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
zjjhot committed Dec 5, 2022
2 parents 6e6b6e6 + a08584e commit c2742e0
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 46 deletions.
3 changes: 2 additions & 1 deletion Dockerfile.rootless
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ EXPOSE 2222 3000
RUN apk --no-cache add \
bash \
ca-certificates \
dumb-init \
gettext \
git \
curl \
Expand Down Expand Up @@ -68,6 +69,6 @@ ENV HOME "/var/lib/gitea/git"
VOLUME ["/var/lib/gitea", "/etc/gitea"]
WORKDIR /var/lib/gitea

ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
ENTRYPOINT ["/usr/bin/dumb-init", "--", "/usr/local/bin/docker-entrypoint.sh"]
CMD []

27 changes: 18 additions & 9 deletions models/issues/tracked_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package issues

import (
"context"
"errors"
"time"

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

func (t *TrackedTime) loadAttributes(ctx context.Context) (err error) {
// Load the issue
if t.Issue == nil {
t.Issue, err = GetIssueByID(ctx, t.IssueID)
if err != nil {
return
if err != nil && !errors.Is(err, util.ErrNotExist) {
return err
}
}
// Now load the repo for the issue (which we may have just loaded)
if t.Issue != nil {
err = t.Issue.LoadRepo(ctx)
if err != nil {
return
if err != nil && !errors.Is(err, util.ErrNotExist) {
return err
}
}
// Load the user
if t.User == nil {
t.User, err = user_model.GetUserByID(ctx, t.UserID)
if err != nil {
return
if !errors.Is(err, util.ErrNotExist) {
return err
}
t.User = user_model.NewGhostUser()
}
}
return err
return nil
}

// LoadAttributes load Issue, User
func (tl TrackedTimeList) LoadAttributes() (err error) {
func (tl TrackedTimeList) LoadAttributes() error {
for _, t := range tl {
if err = t.LoadAttributes(); err != nil {
if err := t.LoadAttributes(); err != nil {
return err
}
}
return err
return nil
}

// FindTrackedTimesOptions represent the filters for tracked times. If an ID is 0 it will be ignored.
Expand Down
6 changes: 6 additions & 0 deletions modules/charset/ambiguous.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ func AmbiguousTablesForLocale(locale translation.Locale) []*AmbiguousTable {
key = key[:idx]
}
}
if table == nil && (locale.Language() == "zh-CN" || locale.Language() == "zh_CN") {
table = AmbiguousCharacters["zh-hans"]
}
if table == nil && strings.HasPrefix(locale.Language(), "zh") {
table = AmbiguousCharacters["zh-hant"]
}
if table == nil {
table = AmbiguousCharacters["_default"]
}
Expand Down
11 changes: 5 additions & 6 deletions modules/convert/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,11 @@ func ToAPIIssueList(ctx context.Context, il issues_model.IssueList) []*api.Issue
// ToTrackedTime converts TrackedTime to API format
func ToTrackedTime(ctx context.Context, t *issues_model.TrackedTime) (apiT *api.TrackedTime) {
apiT = &api.TrackedTime{
ID: t.ID,
IssueID: t.IssueID,
UserID: t.UserID,
UserName: t.User.Name,
Time: t.Time,
Created: t.Created,
ID: t.ID,
IssueID: t.IssueID,
UserID: t.UserID,
Time: t.Time,
Created: t.Created,
}
if t.Issue != nil {
apiT.Issue = ToAPIIssue(ctx, t.Issue)
Expand Down
2 changes: 1 addition & 1 deletion modules/git/repo_branch_nogogit.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (repo *Repository) IsReferenceExist(name string) bool {

// IsBranchExist returns true if given branch exists in current repository.
func (repo *Repository) IsBranchExist(name string) bool {
if name == "" {
if repo == nil || name == "" {
return false
}

Expand Down
2 changes: 1 addition & 1 deletion modules/git/repo_tag_nogogit.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

// IsTagExist returns true if given tag exists in the repository.
func (repo *Repository) IsTagExist(name string) bool {
if name == "" {
if repo == nil || name == "" {
return false
}

Expand Down
2 changes: 1 addition & 1 deletion options/gitignore/Bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/bazel-*

# Directories for the Bazel IntelliJ plugin containing the generated
# IntelliJ project files and plugin configuration. Separate directories are
# IntelliJ project files and plugin configuration. Seperate directories are
# for the IntelliJ, Android Studio and CLion versions of the plugin.
/.ijwb/
/.aswb/
Expand Down
60 changes: 34 additions & 26 deletions routers/api/v1/repo/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,42 +251,50 @@ func ListBranches(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/BranchList"

var totalNumOfBranches int
var apiBranches []*api.Branch

listOptions := utils.GetListOptions(ctx)
skip, _ := listOptions.GetStartEnd()
branches, totalNumOfBranches, err := ctx.Repo.GitRepo.GetBranches(skip, listOptions.PageSize)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetBranches", err)
return
}

apiBranches := make([]*api.Branch, 0, len(branches))
for i := range branches {
c, err := branches[i].GetCommit()
if !ctx.Repo.Repository.IsEmpty && ctx.Repo.GitRepo != nil {
skip, _ := listOptions.GetStartEnd()
branches, total, err := ctx.Repo.GitRepo.GetBranches(skip, listOptions.PageSize)
if err != nil {
// Skip if this branch doesn't exist anymore.
if git.IsErrNotExist(err) {
totalNumOfBranches--
continue
}
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
ctx.Error(http.StatusInternalServerError, "GetBranches", err)
return
}
branchProtection, err := git_model.GetProtectedBranchBy(ctx, ctx.Repo.Repository.ID, branches[i].Name)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetBranchProtection", err)
return
}
apiBranch, err := convert.ToBranch(ctx.Repo.Repository, branches[i], c, branchProtection, ctx.Doer, ctx.Repo.IsAdmin())
if err != nil {
ctx.Error(http.StatusInternalServerError, "convert.ToBranch", err)
return

apiBranches = make([]*api.Branch, 0, len(branches))
for i := range branches {
c, err := branches[i].GetCommit()
if err != nil {
// Skip if this branch doesn't exist anymore.
if git.IsErrNotExist(err) {
total--
continue
}
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
return
}
branchProtection, err := git_model.GetProtectedBranchBy(ctx, ctx.Repo.Repository.ID, branches[i].Name)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchBy", err)
return
}
apiBranch, err := convert.ToBranch(ctx.Repo.Repository, branches[i], c, branchProtection, ctx.Doer, ctx.Repo.IsAdmin())
if err != nil {
ctx.Error(http.StatusInternalServerError, "convert.ToBranch", err)
return
}
apiBranches = append(apiBranches, apiBranch)
}
apiBranches = append(apiBranches, apiBranch)

totalNumOfBranches = total
}

ctx.SetLinkHeader(totalNumOfBranches, listOptions.PageSize)
ctx.SetTotalCountHeader(int64(totalNumOfBranches))
ctx.JSON(http.StatusOK, &apiBranches)
ctx.JSON(http.StatusOK, apiBranches)
}

// GetBranchProtection gets a branch protection
Expand Down
4 changes: 3 additions & 1 deletion templates/repo/view_file.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
</div>
</h4>
<div class="ui attached table unstackable segment">
{{template "repo/unicode_escape_prompt" dict "EscapeStatus" .EscapeStatus "root" $}}
{{if not (or .IsMarkup .IsRenderedHTML)}}
{{template "repo/unicode_escape_prompt" dict "EscapeStatus" .EscapeStatus "root" $}}
{{end}}
<div class="file-view{{if .IsMarkup}} markup {{.MarkupType}}{{else if .IsRenderedHTML}} plain-text{{else if .IsTextSource}} code-view{{end}}">
{{if .IsMarkup}}
{{if .FileContent}}{{.FileContent | Safe}}{{end}}
Expand Down
7 changes: 7 additions & 0 deletions web_src/less/_base.less
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@ body {
overflow-wrap: break-word;
}

@supports (overflow: overlay) {
body {
overflow: overlay;
scrollbar-gutter: stable;
}
}

img {
border-radius: 3px;
}
Expand Down

0 comments on commit c2742e0

Please sign in to comment.