Skip to content

Commit afa931e

Browse files
committed
Merge remote-tracking branch 'origin/main' into tsconfig
* origin/main: (21 commits) Fix deprecated Dockerfile ENV format (go-gitea#31450) README Badge maintenance (go-gitea#31441) Improve markdown textarea for indentation and lists (go-gitea#31406) Split common-global.js into separate files (go-gitea#31438) Fix the link for .git-blame-ignore-revs bypass (go-gitea#31432) Bump htmx to 2.0.0 (go-gitea#31413) Fix the wrong line number in the diff view page when expanded twice. (go-gitea#31431) Fix labels and projects menu overflow on issue page (go-gitea#31435) [Fix] Account Linking UpdateMigrationsByType (go-gitea#31428) Fix markdown math brackets render problem (go-gitea#31420) Reduce `air` verbosity (go-gitea#31417) Fix new issue/pr avatar (go-gitea#31419) Increase max length of org team names from 30 to 255 characters (go-gitea#31410) [skip ci] Updated translations via Crowdin Refactor names (go-gitea#31405) Update JS dependencies, remove `eslint-plugin-jquery` (go-gitea#31402) Switch to upstream of `gorilla/feeds` (go-gitea#31400) Fix rendered wiki page link (go-gitea#31398) Refactor repo unit "disabled" check (go-gitea#31389) Refactor route path normalization (go-gitea#31381) ...
2 parents 8b429c1 + 996037f commit afa931e

File tree

234 files changed

+2237
-2311
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

234 files changed

+2237
-2311
lines changed

.air.toml

+3
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ exclude_dir = [
2121
]
2222
exclude_regex = ["_test.go$", "_gen.go$"]
2323
stop_on_error = true
24+
25+
[log]
26+
main_only = true

.eslintrc.yaml

+2-50
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ plugins:
2727
- eslint-plugin-array-func
2828
- eslint-plugin-github
2929
- eslint-plugin-i
30-
- eslint-plugin-jquery
3130
- eslint-plugin-no-jquery
3231
- eslint-plugin-no-use-extend-native
3332
- eslint-plugin-regexp
@@ -45,6 +44,7 @@ overrides:
4544
- files: ["web_src/**/*"]
4645
globals:
4746
__webpack_public_path__: true
47+
htmx: true
4848
process: false # https://github.com/webpack/webpack/issues/15833
4949
- files: ["web_src/**/*", "docs/**/*"]
5050
env:
@@ -308,55 +308,6 @@ rules:
308308
i/prefer-default-export: [0]
309309
i/unambiguous: [0]
310310
init-declarations: [0]
311-
jquery/no-ajax-events: [2]
312-
jquery/no-ajax: [2]
313-
jquery/no-animate: [2]
314-
jquery/no-attr: [2]
315-
jquery/no-bind: [2]
316-
jquery/no-class: [0]
317-
jquery/no-clone: [2]
318-
jquery/no-closest: [0]
319-
jquery/no-css: [2]
320-
jquery/no-data: [0]
321-
jquery/no-deferred: [2]
322-
jquery/no-delegate: [2]
323-
jquery/no-each: [0]
324-
jquery/no-extend: [2]
325-
jquery/no-fade: [2]
326-
jquery/no-filter: [0]
327-
jquery/no-find: [0]
328-
jquery/no-global-eval: [2]
329-
jquery/no-grep: [2]
330-
jquery/no-has: [2]
331-
jquery/no-hide: [2]
332-
jquery/no-html: [0]
333-
jquery/no-in-array: [2]
334-
jquery/no-is-array: [2]
335-
jquery/no-is-function: [2]
336-
jquery/no-is: [2]
337-
jquery/no-load: [2]
338-
jquery/no-map: [2]
339-
jquery/no-merge: [2]
340-
jquery/no-param: [2]
341-
jquery/no-parent: [0]
342-
jquery/no-parents: [2]
343-
jquery/no-parse-html: [2]
344-
jquery/no-prop: [2]
345-
jquery/no-proxy: [2]
346-
jquery/no-ready: [2]
347-
jquery/no-serialize: [2]
348-
jquery/no-show: [2]
349-
jquery/no-size: [2]
350-
jquery/no-sizzle: [2]
351-
jquery/no-slide: [2]
352-
jquery/no-submit: [2]
353-
jquery/no-text: [2]
354-
jquery/no-toggle: [2]
355-
jquery/no-trigger: [0]
356-
jquery/no-trim: [2]
357-
jquery/no-val: [0]
358-
jquery/no-when: [2]
359-
jquery/no-wrap: [2]
360311
line-comment-position: [0]
361312
logical-assignment-operators: [0]
362313
max-classes-per-file: [0]
@@ -766,6 +717,7 @@ rules:
766717
unicorn/no-lonely-if: [2]
767718
unicorn/no-magic-array-flat-depth: [0]
768719
unicorn/no-negated-condition: [0]
720+
unicorn/no-negation-in-equality-check: [2]
769721
unicorn/no-nested-ternary: [0]
770722
unicorn/no-new-array: [0]
771723
unicorn/no-new-buffer: [0]

Dockerfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
FROM docker.io/library/golang:1.22-alpine3.20 AS build-env
33

44
ARG GOPROXY
5-
ENV GOPROXY ${GOPROXY:-direct}
5+
ENV GOPROXY=${GOPROXY:-direct}
66

77
ARG GITEA_VERSION
88
ARG TAGS="sqlite sqlite_unlock_notify"
9-
ENV TAGS "bindata timetzdata $TAGS"
9+
ENV TAGS="bindata timetzdata $TAGS"
1010
ARG CGO_EXTRA_CFLAGS
1111

1212
# Build deps
@@ -72,8 +72,8 @@ RUN addgroup \
7272
git && \
7373
echo "git:*" | chpasswd -e
7474

75-
ENV USER git
76-
ENV GITEA_CUSTOM /data/gitea
75+
ENV USER=git
76+
ENV GITEA_CUSTOM=/data/gitea
7777

7878
VOLUME ["/data"]
7979

Dockerfile.rootless

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
FROM docker.io/library/golang:1.22-alpine3.20 AS build-env
33

44
ARG GOPROXY
5-
ENV GOPROXY ${GOPROXY:-direct}
5+
ENV GOPROXY=${GOPROXY:-direct}
66

77
ARG GITEA_VERSION
88
ARG TAGS="sqlite sqlite_unlock_notify"
9-
ENV TAGS "bindata timetzdata $TAGS"
9+
ENV TAGS="bindata timetzdata $TAGS"
1010
ARG CGO_EXTRA_CFLAGS
1111

1212
#Build deps
@@ -75,14 +75,14 @@ COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_au
7575

7676
# git:git
7777
USER 1000:1000
78-
ENV GITEA_WORK_DIR /var/lib/gitea
79-
ENV GITEA_CUSTOM /var/lib/gitea/custom
80-
ENV GITEA_TEMP /tmp/gitea
81-
ENV TMPDIR /tmp/gitea
78+
ENV GITEA_WORK_DIR=/var/lib/gitea
79+
ENV GITEA_CUSTOM=/var/lib/gitea/custom
80+
ENV GITEA_TEMP=/tmp/gitea
81+
ENV TMPDIR=/tmp/gitea
8282

8383
# TODO add to docs the ability to define the ini to load (useful to test and revert a config)
84-
ENV GITEA_APP_INI /etc/gitea/app.ini
85-
ENV HOME "/var/lib/gitea/git"
84+
ENV GITEA_APP_INI=/etc/gitea/app.ini
85+
ENV HOME="/var/lib/gitea/git"
8686
VOLUME ["/var/lib/gitea", "/etc/gitea"]
8787
WORKDIR /var/lib/gitea
8888

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
[![](https://www.codetriage.com/go-gitea/gitea/badges/users.svg)](https://www.codetriage.com/go-gitea/gitea "Help Contribute to Open Source")
99
[![](https://opencollective.com/gitea/tiers/backers/badge.svg?label=backers&color=brightgreen)](https://opencollective.com/gitea "Become a backer/sponsor of gitea")
1010
[![](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT "License: MIT")
11-
[![Contribute with Gitpod](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/go-gitea/gitea)
11+
[![Contribute with Gitpod](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod&color=green)](https://gitpod.io/#https://github.com/go-gitea/gitea)
1212
[![](https://badges.crowdin.net/gitea/localized.svg)](https://crowdin.com/project/gitea "Crowdin")
13-
[![](https://badgen.net/https/api.tickgit.com/badgen/github.com/go-gitea/gitea/main)](https://www.tickgit.com/browse?repo=github.com/go-gitea/gitea&branch=main "TODOs")
1413

1514
[View this document in Chinese](./README_ZH.md)
1615

README_ZH.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
[![](https://www.codetriage.com/go-gitea/gitea/badges/users.svg)](https://www.codetriage.com/go-gitea/gitea "Help Contribute to Open Source")
99
[![](https://opencollective.com/gitea/tiers/backers/badge.svg?label=backers&color=brightgreen)](https://opencollective.com/gitea "Become a backer/sponsor of gitea")
1010
[![](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT "License: MIT")
11-
[![Contribute with Gitpod](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/go-gitea/gitea)
11+
[![Contribute with Gitpod](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod&color=green)](https://gitpod.io/#https://github.com/go-gitea/gitea)
1212
[![](https://badges.crowdin.net/gitea/localized.svg)](https://crowdin.com/project/gitea "Crowdin")
13-
[![](https://badgen.net/https/api.tickgit.com/badgen/github.com/go-gitea/gitea/main)](https://www.tickgit.com/browse?repo=github.com/go-gitea/gitea&branch=main "TODOs")
1413

1514
[View this document in English](./README.md)
1615

go.mod

+1-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ require (
5959
github.com/google/go-github/v61 v61.0.0
6060
github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7
6161
github.com/google/uuid v1.6.0
62-
github.com/gorilla/feeds v1.1.2
62+
github.com/gorilla/feeds v1.2.0
6363
github.com/gorilla/sessions v1.2.2
6464
github.com/h2non/gock v1.2.0
6565
github.com/hashicorp/go-version v1.6.0
@@ -309,8 +309,6 @@ replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142
309309

310310
replace github.com/nektos/act => gitea.com/gitea/act v0.259.1
311311

312-
replace github.com/gorilla/feeds => github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5
313-
314312
// TODO: This could be removed after https://github.com/mholt/archiver/pull/396 merged
315313
replace github.com/mholt/archiver/v3 => github.com/anchore/archiver/v3 v3.5.2
316314

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,8 @@ github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8
426426
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
427427
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
428428
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
429+
github.com/gorilla/feeds v1.2.0 h1:O6pBiXJ5JHhPvqy53NsjKOThq+dNFm8+DFrxBEdzSCc=
430+
github.com/gorilla/feeds v1.2.0/go.mod h1:WMib8uJP3BbY+X8Szd1rA5Pzhdfh+HCCAYT2z7Fza6Y=
429431
github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE=
430432
github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w=
431433
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
@@ -811,8 +813,6 @@ github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMx
811813
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
812814
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw=
813815
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk=
814-
github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5 h1:3seWKGVhGoc66Ht5QlhQsr4xT2caDnFegsnh2NqvENU=
815-
github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5/go.mod h1:WMib8uJP3BbY+X8Szd1rA5Pzhdfh+HCCAYT2z7Fza6Y=
816816
github.com/yohcop/openid-go v1.0.1 h1:DPRd3iPO5F6O5zX2e62XpVAbPT6wV51cuucH0z9g3js=
817817
github.com/yohcop/openid-go v1.0.1/go.mod h1:b/AvD03P0KHj4yuihb+VtLD6bYYgsy0zqBzPCRjkCNs=
818818
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=

models/repo/repo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ func (repo *Repository) LoadUnits(ctx context.Context) (err error) {
362362
if log.IsTrace() {
363363
unitTypeStrings := make([]string, len(repo.Units))
364364
for i, unit := range repo.Units {
365-
unitTypeStrings[i] = unit.Type.String()
365+
unitTypeStrings[i] = unit.Type.LogString()
366366
}
367367
log.Trace("repo.Units, ID=%d, Types: [%s]", repo.ID, strings.Join(unitTypeStrings, ", "))
368368
}

models/repo/repo_unit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func IsErrUnitTypeNotExist(err error) bool {
3333
}
3434

3535
func (err ErrUnitTypeNotExist) Error() string {
36-
return fmt.Sprintf("Unit type does not exist: %s", err.UT.String())
36+
return fmt.Sprintf("Unit type does not exist: %s", err.UT.LogString())
3737
}
3838

3939
func (err ErrUnitTypeNotExist) Unwrap() error {

models/unit/unit.go

+8-29
Original file line numberDiff line numberDiff line change
@@ -33,39 +33,18 @@ const (
3333
TypeActions // 10 Actions
3434
)
3535

36-
// Value returns integer value for unit type
36+
// Value returns integer value for unit type (used by template)
3737
func (u Type) Value() int {
3838
return int(u)
3939
}
4040

41-
func (u Type) String() string {
42-
switch u {
43-
case TypeCode:
44-
return "TypeCode"
45-
case TypeIssues:
46-
return "TypeIssues"
47-
case TypePullRequests:
48-
return "TypePullRequests"
49-
case TypeReleases:
50-
return "TypeReleases"
51-
case TypeWiki:
52-
return "TypeWiki"
53-
case TypeExternalWiki:
54-
return "TypeExternalWiki"
55-
case TypeExternalTracker:
56-
return "TypeExternalTracker"
57-
case TypeProjects:
58-
return "TypeProjects"
59-
case TypePackages:
60-
return "TypePackages"
61-
case TypeActions:
62-
return "TypeActions"
63-
}
64-
return fmt.Sprintf("Unknown Type %d", u)
65-
}
66-
6741
func (u Type) LogString() string {
68-
return fmt.Sprintf("<UnitType:%d:%s>", u, u.String())
42+
unit, ok := Units[u]
43+
unitName := "unknown"
44+
if ok {
45+
unitName = unit.NameKey
46+
}
47+
return fmt.Sprintf("<UnitType:%d:%s>", u, unitName)
6948
}
7049

7150
var (
@@ -133,7 +112,7 @@ func validateDefaultRepoUnits(defaultUnits, settingDefaultUnits []Type) []Type {
133112
units = make([]Type, 0, len(settingDefaultUnits))
134113
for _, settingUnit := range settingDefaultUnits {
135114
if !settingUnit.CanBeDefault() {
136-
log.Warn("Not allowed as default unit: %s", settingUnit.String())
115+
log.Warn("Not allowed as default unit: %s", settingUnit.LogString())
137116
continue
138117
}
139118
units = append(units, settingUnit)

modules/markup/html.go

+13-50
Original file line numberDiff line numberDiff line change
@@ -144,20 +144,6 @@ func CustomLinkURLSchemes(schemes []string) {
144144
common.LinkRegex, _ = xurls.StrictMatchingScheme(strings.Join(withAuth, "|"))
145145
}
146146

147-
// IsSameDomain checks if given url string has the same hostname as current Gitea instance
148-
func IsSameDomain(s string) bool {
149-
if strings.HasPrefix(s, "/") {
150-
return true
151-
}
152-
if uapp, err := url.Parse(setting.AppURL); err == nil {
153-
if u, err := url.Parse(s); err == nil {
154-
return u.Host == uapp.Host
155-
}
156-
return false
157-
}
158-
return false
159-
}
160-
161147
type postProcessError struct {
162148
context string
163149
err error
@@ -429,7 +415,7 @@ func visitNode(ctx *RenderContext, procs []processor, node *html.Node) *html.Nod
429415
// We ignore code and pre.
430416
switch node.Type {
431417
case html.TextNode:
432-
textNode(ctx, procs, node)
418+
processTextNodes(ctx, procs, node)
433419
case html.ElementNode:
434420
if node.Data == "img" {
435421
next := node.NextSibling
@@ -465,15 +451,16 @@ func visitNode(ctx *RenderContext, procs []processor, node *html.Node) *html.Nod
465451
for n := node.FirstChild; n != nil; {
466452
n = visitNode(ctx, procs, n)
467453
}
454+
default:
468455
}
469456
return node.NextSibling
470457
}
471458

472-
// textNode runs the passed node through various processors, in order to handle
459+
// processTextNodes runs the passed node through various processors, in order to handle
473460
// all kinds of special links handled by the post-processing.
474-
func textNode(ctx *RenderContext, procs []processor, node *html.Node) {
475-
for _, processor := range procs {
476-
processor(ctx, node)
461+
func processTextNodes(ctx *RenderContext, procs []processor, node *html.Node) {
462+
for _, p := range procs {
463+
p(ctx, node)
477464
}
478465
}
479466

@@ -761,10 +748,10 @@ func shortLinkProcessor(ctx *RenderContext, node *html.Node) {
761748
if image {
762749
link = strings.ReplaceAll(link, " ", "+")
763750
} else {
764-
link = strings.ReplaceAll(link, " ", "-")
751+
link = strings.ReplaceAll(link, " ", "-") // FIXME: it should support dashes in the link, eg: "the-dash-support.-"
765752
}
766753
if !strings.Contains(link, "/") {
767-
link = url.PathEscape(link)
754+
link = url.PathEscape(link) // FIXME: it doesn't seem right and it might cause double-escaping
768755
}
769756
}
770757
if image {
@@ -796,28 +783,7 @@ func shortLinkProcessor(ctx *RenderContext, node *html.Node) {
796783
childNode.Attr = childNode.Attr[:2]
797784
}
798785
} else {
799-
if !absoluteLink {
800-
var base string
801-
if ctx.IsWiki {
802-
switch ext {
803-
case "":
804-
// no file extension, create a regular wiki link
805-
base = ctx.Links.WikiLink()
806-
default:
807-
// we have a file extension:
808-
// return a regular wiki link if it's a renderable file (extension),
809-
// raw link otherwise
810-
if Type(link) != "" {
811-
base = ctx.Links.WikiLink()
812-
} else {
813-
base = ctx.Links.WikiRawLink()
814-
}
815-
}
816-
} else {
817-
base = ctx.Links.SrcLink()
818-
}
819-
link = util.URLJoin(base, link)
820-
}
786+
link, _ = ResolveLink(ctx, link, "")
821787
childNode.Type = html.TextNode
822788
childNode.Data = name
823789
}
@@ -939,14 +905,11 @@ func issueIndexPatternProcessor(ctx *RenderContext, node *html.Node) {
939905
// Path determines the type of link that will be rendered. It's unknown at this point whether
940906
// the linked item is actually a PR or an issue. Luckily it's of no real consequence because
941907
// Gitea will redirect on click as appropriate.
942-
path := "issues"
943-
if ref.IsPull {
944-
path = "pulls"
945-
}
908+
issuePath := util.Iif(ref.IsPull, "pulls", "issues")
946909
if ref.Owner == "" {
947-
link = createLink(util.URLJoin(ctx.Links.Prefix(), ctx.Metas["user"], ctx.Metas["repo"], path, ref.Issue), reftext, "ref-issue")
910+
link = createLink(util.URLJoin(ctx.Links.Prefix(), ctx.Metas["user"], ctx.Metas["repo"], issuePath, ref.Issue), reftext, "ref-issue")
948911
} else {
949-
link = createLink(util.URLJoin(ctx.Links.Prefix(), ref.Owner, ref.Name, path, ref.Issue), reftext, "ref-issue")
912+
link = createLink(util.URLJoin(ctx.Links.Prefix(), ref.Owner, ref.Name, issuePath, ref.Issue), reftext, "ref-issue")
950913
}
951914
}
952915

@@ -1207,7 +1170,7 @@ func hashCurrentPatternProcessor(ctx *RenderContext, node *html.Node) {
12071170
return
12081171
}
12091172
ctx.AddCancel(func() {
1210-
closer.Close()
1173+
_ = closer.Close()
12111174
ctx.GitRepo = nil
12121175
})
12131176
}

0 commit comments

Comments
 (0)