Skip to content

Commit 4db1324

Browse files
committed
Merge branch 'main' into lunny/refactor_org_setting
2 parents e9ba6fe + 6b42ea1 commit 4db1324

Some content is hidden

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

59 files changed

+281
-206
lines changed

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ linters:
5050
require-explanation: true
5151
require-specific: true
5252
gocritic:
53+
enabled-checks:
54+
- equalFold
5355
disabled-checks:
5456
- ifElseChain
5557
- singleCaseSwitch # Every time this occurred in the code, there was no other way.

CODE_OF_CONDUCT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ These are the values to which people in the Gitea community should aspire.
3030
- **Be constructive.**
3131
- Avoid derailing: stay on topic; if you want to talk about something else, start a new conversation.
3232
- Avoid unconstructive criticism: don't merely decry the current state of affairs; offer—or at least solicit—suggestions as to how things may be improved.
33-
- Avoid snarking (pithy, unproductive, sniping comments)
33+
- Avoid snarking (pithy, unproductive, sniping comments).
3434
- Avoid discussing potentially offensive or sensitive issues; this all too often leads to unnecessary conflict.
3535
- Avoid microaggressions (brief and commonplace verbal, behavioral and environmental indignities that communicate hostile, derogatory or negative slights and insults to a person or group).
3636
- **Be responsible.**
@@ -42,7 +42,7 @@ People are complicated. You should expect to be misunderstood and to misundersta
4242

4343
### Our Pledge
4444

45-
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
45+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
4646

4747
### Our Standards
4848

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ Expected workflow is: Fork -> Patch -> Push -> Pull Request
8080

8181
[![Crowdin](https://badges.crowdin.net/gitea/localized.svg)](https://translate.gitea.com)
8282

83-
Translations are done through [Crowdin](https://translate.gitea.com). If you want to translate to a new language ask one of the managers in the Crowdin project to add a new language there.
83+
Translations are done through [Crowdin](https://translate.gitea.com). If you want to translate to a new language, ask one of the managers in the Crowdin project to add a new language there.
8484

85-
You can also just create an issue for adding a language or ask on discord on the #translation channel. If you need context or find some translation issues, you can leave a comment on the string or ask on Discord. For general translation questions there is a section in the docs. Currently a bit empty but we hope to fill it as questions pop up.
85+
You can also just create an issue for adding a language or ask on Discord on the #translation channel. If you need context or find some translation issues, you can leave a comment on the string or ask on Discord. For general translation questions there is a section in the docs. Currently a bit empty, but we hope to fill it as questions pop up.
8686

8787
Get more information from [documentation](https://docs.gitea.com/contributing/localization).
8888

models/repo/language_stats.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,17 @@ func UpdateLanguageStats(ctx context.Context, repo *Repository, commitID string,
157157
for lang, size := range stats {
158158
if size > s {
159159
s = size
160-
topLang = strings.ToLower(lang)
160+
topLang = lang
161161
}
162162
}
163163

164164
for lang, size := range stats {
165165
upd := false
166-
llang := strings.ToLower(lang)
167166
for _, s := range oldstats {
168167
// Update already existing language
169-
if strings.ToLower(s.Language) == llang {
168+
if strings.EqualFold(s.Language, lang) {
170169
s.CommitID = commitID
171-
s.IsPrimary = llang == topLang
170+
s.IsPrimary = lang == topLang
172171
s.Size = size
173172
if _, err := sess.ID(s.ID).Cols("`commit_id`", "`size`", "`is_primary`").Update(s); err != nil {
174173
return err
@@ -182,7 +181,7 @@ func UpdateLanguageStats(ctx context.Context, repo *Repository, commitID string,
182181
if err := db.Insert(ctx, &LanguageStat{
183182
RepoID: repo.ID,
184183
CommitID: commitID,
185-
IsPrimary: llang == topLang,
184+
IsPrimary: lang == topLang,
186185
Language: lang,
187186
Size: size,
188187
}); err != nil {

modules/markup/mdstripper/mdstripper.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ func (r *stripRenderer) processAutoLink(w io.Writer, link []byte) {
9191
}
9292

9393
// Note: we're not attempting to match the URL scheme (http/https)
94-
host := strings.ToLower(u.Host)
95-
if host != "" && host != strings.ToLower(r.localhost.Host) {
94+
if u.Host != "" && !strings.EqualFold(u.Host, r.localhost.Host) {
9695
// Process out of band
9796
r.links = append(r.links, linkStr)
9897
return

modules/packages/pub/metadata.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func ParsePackage(r io.Reader) (*Package, error) {
8888
if err != nil {
8989
return nil, err
9090
}
91-
} else if strings.ToLower(hd.Name) == "readme.md" {
91+
} else if strings.EqualFold(hd.Name, "readme.md") {
9292
data, err := io.ReadAll(tr)
9393
if err != nil {
9494
return nil, err

modules/setting/actions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ func (c logCompression) IsValid() bool {
6262
}
6363

6464
func (c logCompression) IsNone() bool {
65-
return strings.ToLower(string(c)) == "none"
65+
return string(c) == "none"
6666
}
6767

6868
func (c logCompression) IsZstd() bool {
69-
return c == "" || strings.ToLower(string(c)) == "zstd"
69+
return c == "" || string(c) == "zstd"
7070
}
7171

7272
func loadActionsFrom(rootCfg ConfigProvider) error {

modules/templates/helper.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ func NewFuncMap() template.FuncMap {
4040
"HTMLFormat": htmlFormat,
4141
"QueryEscape": queryEscape,
4242
"QueryBuild": QueryBuild,
43-
"JSEscape": jsEscapeSafe,
4443
"SanitizeHTML": SanitizeHTML,
4544
"URLJoin": util.URLJoin,
4645
"DotEscape": dotEscape,
@@ -181,10 +180,6 @@ func htmlFormat(s any, args ...any) template.HTML {
181180
panic(fmt.Sprintf("unexpected type %T", s))
182181
}
183182

184-
func jsEscapeSafe(s string) template.HTML {
185-
return template.HTML(template.JSEscapeString(s))
186-
}
187-
188183
func queryEscape(s string) template.URL {
189184
return template.URL(url.QueryEscape(s))
190185
}

modules/templates/helper_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ func TestSubjectBodySeparator(t *testing.T) {
5757
"Insufficient\n--\nSeparators")
5858
}
5959

60-
func TestJSEscapeSafe(t *testing.T) {
61-
assert.EqualValues(t, `\u0026\u003C\u003E\'\"`, jsEscapeSafe(`&<>'"`))
62-
}
63-
6460
func TestSanitizeHTML(t *testing.T) {
6561
assert.Equal(t, template.HTML(`<a href="/" rel="nofollow">link</a> xss <div>inline</div>`), SanitizeHTML(`<a href="/">link</a> <a href="javascript:">xss</a> <div style="dangerous">inline</div>`))
6662
}

modules/util/slice.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import (
1212
// SliceContainsString sequential searches if string exists in slice.
1313
func SliceContainsString(slice []string, target string, insensitive ...bool) bool {
1414
if len(insensitive) != 0 && insensitive[0] {
15-
target = strings.ToLower(target)
16-
return slices.ContainsFunc(slice, func(t string) bool { return strings.ToLower(t) == target })
15+
return slices.ContainsFunc(slice, func(t string) bool { return strings.EqualFold(t, target) })
1716
}
1817

1918
return slices.Contains(slice, target)

0 commit comments

Comments
 (0)