Skip to content

Commit 9ada9c1

Browse files
committed
Merge remote-tracking branch 'giteaoffical/main'
* giteaoffical/main: Fix 500 error if there is a name conflict when edit authentication source (go-gitea#23832) Use different SVG for pending and running actions (go-gitea#23836) CSS color tweaks (go-gitea#23828) Clarify Gitea/Crowdin locale behaviors, add tests for LocaleStore, fix some strings with semicolons (go-gitea#23819)
2 parents c9ca0a0 + 6e58f84 commit 9ada9c1

File tree

10 files changed

+107
-34
lines changed

10 files changed

+107
-34
lines changed

build/update-locales.sh

+4-11
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,10 @@ fi
1717

1818
mv ./options/locale/locale_en-US.ini ./options/
1919

20-
# the "ini" library for locale has many quirks
21-
# * `a="xx"` gets `xx` (no quote)
22-
# * `a=x\"y` gets `x\"y` (no unescaping)
23-
# * `a="x\"y"` gets `"x\"y"` (no unescaping, the quotes are still there)
24-
# * `a='x\"y'` gets `x\"y` (no unescaping, no quote)
25-
# * `a="foo` gets `"foo` (although the quote is not closed)
26-
# * 'a=`foo`' works like single-quote
27-
# crowdin needs the strings to be quoted correctly and doesn't like incomplete quotes
28-
# crowdin always outputs quoted strings if there are quotes in the strings.
29-
30-
# this script helps to unquote the crowdin outputs for the quirky ini library
20+
# the "ini" library for locale has many quirks, its behavior is different from Crowdin.
21+
# see i18n_test.go for more details
22+
23+
# this script helps to unquote the Crowdin outputs for the quirky ini library
3124
# * find all `key="...\"..."` lines
3225
# * remove the leading quote
3326
# * remove the trailing quote

models/auth/source.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,14 @@ func UpdateSource(source *Source) error {
317317
}
318318
}
319319

320-
_, err := db.GetEngine(db.DefaultContext).ID(source.ID).AllCols().Update(source)
320+
has, err := db.GetEngine(db.DefaultContext).Where("name=? AND id!=?", source.Name, source.ID).Exist(new(Source))
321+
if err != nil {
322+
return err
323+
} else if has {
324+
return ErrSourceAlreadyExist{source.Name}
325+
}
326+
327+
_, err = db.GetEngine(db.DefaultContext).ID(source.ID).AllCols().Update(source)
321328
if err != nil {
322329
return err
323330
}

modules/translation/i18n/i18n_test.go

+54
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package i18n
55

66
import (
7+
"strings"
78
"testing"
89

910
"github.com/stretchr/testify/assert"
@@ -75,3 +76,56 @@ c=22
7576
assert.Equal(t, "21", ls.Tr("lang1", "b"))
7677
assert.Equal(t, "22", ls.Tr("lang1", "c"))
7778
}
79+
80+
func TestLocaleStoreQuirks(t *testing.T) {
81+
const nl = "\n"
82+
q := func(q1, s string, q2 ...string) string {
83+
return q1 + s + strings.Join(q2, "")
84+
}
85+
testDataList := []struct {
86+
in string
87+
out string
88+
hint string
89+
}{
90+
{` xx`, `xx`, "simple, no quote"},
91+
{`" xx"`, ` xx`, "simple, double-quote"},
92+
{`' xx'`, ` xx`, "simple, single-quote"},
93+
{"` xx`", ` xx`, "simple, back-quote"},
94+
95+
{`x\"y`, `x\"y`, "no unescape, simple"},
96+
{q(`"`, `x\"y`, `"`), `"x\"y"`, "unescape, double-quote"},
97+
{q(`'`, `x\"y`, `'`), `x\"y`, "no unescape, single-quote"},
98+
{q("`", `x\"y`, "`"), `x\"y`, "no unescape, back-quote"},
99+
100+
{q(`"`, `x\"y`) + nl + "b=", `"x\"y`, "half open, double-quote"},
101+
{q(`'`, `x\"y`) + nl + "b=", `'x\"y`, "half open, single-quote"},
102+
{q("`", `x\"y`) + nl + "b=`", `x\"y` + nl + "b=", "half open, back-quote, multi-line"},
103+
104+
{`x ; y`, `x ; y`, "inline comment (;)"},
105+
{`x # y`, `x # y`, "inline comment (#)"},
106+
{`x \; y`, `x ; y`, `inline comment (\;)`},
107+
{`x \# y`, `x # y`, `inline comment (\#)`},
108+
}
109+
110+
for _, testData := range testDataList {
111+
ls := NewLocaleStore()
112+
err := ls.AddLocaleByIni("lang1", "Lang1", []byte("a="+testData.in), nil)
113+
assert.NoError(t, err, testData.hint)
114+
assert.Equal(t, testData.out, ls.Tr("lang1", "a"), testData.hint)
115+
assert.NoError(t, ls.Close())
116+
}
117+
118+
// TODO: Crowdin needs the strings to be quoted correctly and doesn't like incomplete quotes
119+
// and Crowdin always outputs quoted strings if there are quotes in the strings.
120+
// So, Gitea's `key="quoted" unquoted` content shouldn't be used on Crowdin directly,
121+
// it should be converted to `key="\"quoted\" unquoted"` first.
122+
// TODO: We can not use UnescapeValueDoubleQuotes=true, because there are a lot of back-quotes in en-US.ini,
123+
// then Crowdin will output:
124+
// > key = "`x \" y`"
125+
// Then Gitea will read a string with back-quotes, which is incorrect.
126+
// TODO: Crowdin might generate multi-line strings, quoted by double-quote, it's not supported by LocaleStore
127+
// LocaleStore uses back-quote for multi-line strings, it's not supported by Crowdin.
128+
// TODO: Crowdin doesn't support back-quote as string quoter, it mainly uses double-quote
129+
// so, the following line will be parsed as: value="`first", comment="second`" on Crowdin
130+
// > a = `first; second`
131+
}

options/locale/locale_en-US.ini

+4-4
Original file line numberDiff line numberDiff line change
@@ -2140,10 +2140,10 @@ settings.dismiss_stale_approvals_desc = When new commits that change the content
21402140
settings.require_signed_commits = Require Signed Commits
21412141
settings.require_signed_commits_desc = Reject pushes to this branch if they are unsigned or unverifiable.
21422142
settings.protect_branch_name_pattern = Protected Branch Name Pattern
2143-
settings.protect_protected_file_patterns = `Protected file patterns (separated using semicolon ';'):`
2144-
settings.protect_protected_file_patterns_desc = `Protected files are not allowed to be changed directly even if user has rights to add, edit, or delete files in this branch. Multiple patterns can be separated using semicolon (';'). See <a href="https://pkg.go.dev/github.com/gobwas/glob#Compile">github.com/gobwas/glob</a> documentation for pattern syntax. Examples: <code>.drone.yml</code>, <code>/docs/**/*.txt</code>.`
2145-
settings.protect_unprotected_file_patterns = `Unprotected file patterns (separated using semicolon ';'):`
2146-
settings.protect_unprotected_file_patterns_desc = `Unprotected files that are allowed to be changed directly if user has write access, bypassing push restriction. Multiple patterns can be separated using semicolon (';'). See <a href="https://pkg.go.dev/github.com/gobwas/glob#Compile">github.com/gobwas/glob</a> documentation for pattern syntax. Examples: <code>.drone.yml</code>, <code>/docs/**/*.txt</code>.`
2143+
settings.protect_protected_file_patterns = "Protected file patterns (separated using semicolon ';'):"
2144+
settings.protect_protected_file_patterns_desc = "Protected files are not allowed to be changed directly even if user has rights to add, edit, or delete files in this branch. Multiple patterns can be separated using semicolon (';'). See <a href='https://pkg.go.dev/github.com/gobwas/glob#Compile'>github.com/gobwas/glob</a> documentation for pattern syntax. Examples: <code>.drone.yml</code>, <code>/docs/**/*.txt</code>."
2145+
settings.protect_unprotected_file_patterns = "Unprotected file patterns (separated using semicolon ';'):"
2146+
settings.protect_unprotected_file_patterns_desc = "Unprotected files that are allowed to be changed directly if user has write access, bypassing push restriction. Multiple patterns can be separated using semicolon (';'). See <a href='https://pkg.go.dev/github.com/gobwas/glob#Compile'>github.com/gobwas/glob</a> documentation for pattern syntax. Examples: <code>.drone.yml</code>, <code>/docs/**/*.txt</code>."
21472147
settings.add_protected_branch = Enable protection
21482148
settings.delete_protected_branch = Disable protection
21492149
settings.update_protect_branch_success = Branch protection for rule '%s' has been updated.

routers/web/admin/auths.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,11 @@ func EditAuthSourcePost(ctx *context.Context) {
426426
source.IsActive = form.IsActive
427427
source.IsSyncEnabled = form.IsSyncEnabled
428428
source.Cfg = config
429-
// FIXME: if the name conflicts, it will result in 500: Error 1062: Duplicate entry 'aa' for key 'login_source.UQE_login_source_name'
430429
if err := auth.UpdateSource(source); err != nil {
431-
if oauth2.IsErrOpenIDConnectInitialize(err) {
430+
if auth.IsErrSourceAlreadyExist(err) {
431+
ctx.Data["Err_Name"] = true
432+
ctx.RenderWithErr(ctx.Tr("admin.auths.login_source_exist", err.(auth.ErrSourceAlreadyExist).Name), tplAuthEdit, form)
433+
} else if oauth2.IsErrOpenIDConnectInitialize(err) {
432434
ctx.Flash.Error(err.Error(), true)
433435
ctx.Data["Err_DiscoveryURL"] = true
434436
ctx.HTML(http.StatusOK, tplAuthEdit)

templates/repo/commit_status.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{if eq .State "pending"}}
2-
{{svg "octicon-dot-fill" 18 "commit-status icon text yellow"}}
2+
{{svg "octicon-dot-fill" 18 "commit-status icon text grey"}}
33
{{end}}
44
{{if eq .State "running"}}
55
{{svg "octicon-dot-fill" 18 "commit-status icon text yellow"}}

tests/integration/repo_commits_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func testRepoCommitsWithStatus(t *testing.T, resp, respOne *httptest.ResponseRec
110110
}
111111

112112
func TestRepoCommitsWithStatusPending(t *testing.T) {
113-
doTestRepoCommitWithStatus(t, "pending", "octicon-dot-fill", "yellow")
113+
doTestRepoCommitWithStatus(t, "pending", "octicon-dot-fill", "grey")
114114
}
115115

116116
func TestRepoCommitsWithStatusSuccess(t *testing.T) {
@@ -129,6 +129,10 @@ func TestRepoCommitsWithStatusWarning(t *testing.T) {
129129
doTestRepoCommitWithStatus(t, "warning", "gitea-exclamation", "yellow")
130130
}
131131

132+
func TestRepoCommitsWithStatusRunning(t *testing.T) {
133+
doTestRepoCommitWithStatus(t, "running", "octicon-dot-fill", "yellow")
134+
}
135+
132136
func TestRepoCommitsStatusParallel(t *testing.T) {
133137
defer tests.PrepareTestEnv(t)()
134138

web_src/css/base.css

+6-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
--color-purple: #a333c8;
7979
--color-pink: #e03997;
8080
--color-brown: #a5673f;
81-
--color-grey: #888888;
8281
--color-black: #1b1c1d;
8382
/* light variants - produced via Sass scale-color(color, $lightness: +25%) */
8483
--color-red-light: #e45e5e;
@@ -92,9 +91,10 @@
9291
--color-purple-light: #bb64d8;
9392
--color-pink-light: #e86bb1;
9493
--color-brown-light: #c58b66;
95-
--color-grey-light: #a6a6a6;
9694
--color-black-light: #525558;
9795
/* other colors */
96+
--color-grey: #707070;
97+
--color-grey-light: #838383;
9898
--color-gold: #a1882b;
9999
--color-white: #ffffff;
100100
--color-diff-removed-word-bg: #fdb8c0;
@@ -2657,6 +2657,10 @@ table th[data-sortt-desc] .svg {
26572657
border-radius: 0 0 var(--border-radius) var(--border-radius);
26582658
}
26592659

2660+
.ui.multiple.dropdown > .label {
2661+
box-shadow: 0 0 0 1px var(--color-secondary) inset;
2662+
}
2663+
26602664
.text-label {
26612665
display: inline-flex !important;
26622666
align-items: center !important;

web_src/css/form.css

+9
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ textarea:focus,
9494
color: var(--color-text);
9595
}
9696

97+
.ui.form .required.fields:not(.grouped) > .field > label::after,
98+
.ui.form .required.fields.grouped > label::after,
99+
.ui.form .required.field > label::after,
100+
.ui.form .required.fields:not(.grouped) > .field > .checkbox::after,
101+
.ui.form .required.field > .checkbox::after,
102+
.ui.form label.required::after {
103+
color: var(--color-red);
104+
}
105+
97106
.ui.input,
98107
.ui.checkbox input:focus ~ label::after,
99108
.ui.checkbox input:checked ~ label::after,

web_src/css/themes/theme-arc-green.css

+12-12
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@
6868
--color-purple: #b259d0;
6969
--color-pink: #d22e8b;
7070
--color-brown: #a47252;
71-
--color-grey: #9ea2aa;
72-
--color-black: #1e222e;
71+
--color-black: #2e323e;
7372
/* light variants - produced via Sass scale-color(color, $lightness: -10%) */
7473
--color-red-light: #c23636;
7574
--color-orange-light: #b84f0b;
@@ -82,9 +81,10 @@
8281
--color-purple-light: #a742c9;
8382
--color-pink-light: #be297d;
8483
--color-brown-light: #94674a;
85-
--color-grey-light: #8d919b;
86-
--color-black-light: #1b1f29;
84+
--color-black-light: #292d38;
8785
/* other colors */
86+
--color-grey: #505665;
87+
--color-grey-light: #a1a6b7;
8888
--color-gold: #b1983b;
8989
--color-white: #ffffff;
9090
--color-diff-removed-word-bg: #6f3333;
@@ -124,19 +124,19 @@
124124
--color-orange-badge-hover-bg: #f2711c4d;
125125
--color-git: #f05133;
126126
/* target-based colors */
127-
--color-body: #383c4a;
127+
--color-body: #373b47;
128128
--color-box-header: #404652;
129129
--color-box-body: #2a2e3a;
130130
--color-box-body-highlight: #353945;
131131
--color-text-dark: #dbe0ea;
132-
--color-text: #bbc0ca;
133-
--color-text-light: #a6aab5;
134-
--color-text-light-1: #979ba6;
135-
--color-text-light-2: #8a8e99;
136-
--color-text-light-3: #707687;
132+
--color-text: #cbd0da;
133+
--color-text-light: #bbbfca;
134+
--color-text-light-1: #aaafb9;
135+
--color-text-light-2: #9a9ea9;
136+
--color-text-light-3: #8a8e99;
137137
--color-footer: #2e323e;
138138
--color-timeline: #4c525e;
139-
--color-input-text: #d5dbe6;
139+
--color-input-text: #dfe3ec;
140140
--color-input-background: #232933;
141141
--color-input-toggle-background: #454a57;
142142
--color-input-border: #454a57;
@@ -159,7 +159,7 @@
159159
--color-secondary-bg: #2a2e3a;
160160
--color-text-focus: #fff;
161161
--color-expand-button: #3c404d;
162-
--color-placeholder-text: #6a737d;
162+
--color-placeholder-text: #8a8e99;
163163
--color-editor-line-highlight: var(--color-primary-light-5);
164164
--color-project-board-bg: var(--color-secondary-light-2);
165165
--color-caret: var(--color-text); /* should ideally be --color-text-dark, see #15651 */

0 commit comments

Comments
 (0)