Skip to content

Commit 0ecd380

Browse files
authored
Merge branch 'main' into refactor-i18n
2 parents a562a58 + 8422b1c commit 0ecd380

File tree

11 files changed

+44
-18
lines changed

11 files changed

+44
-18
lines changed

custom/conf/app.example.ini

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,15 @@ RUN_MODE = ; prod
8282
;; Whether to use the builtin SSH server or not.
8383
;START_SSH_SERVER = false
8484
;;
85-
;; Username to use for the builtin SSH server. If blank, then it is the value of RUN_USER.
86-
;BUILTIN_SSH_SERVER_USER =
85+
;; Username to use for the builtin SSH server.
86+
;BUILTIN_SSH_SERVER_USER = %(RUN_USER)s
8787
;;
8888
;; Domain name to be exposed in clone URL
8989
;SSH_DOMAIN = %(DOMAIN)s
9090
;;
91+
;; SSH username displayed in clone URLs.
92+
;SSH_USER = %(BUILTIN_SSH_SERVER_USER)s
93+
;;
9194
;; The network interface the builtin SSH server should listen on
9295
;SSH_LISTEN_HOST =
9396
;;

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
265265
- `DISABLE_SSH`: **false**: Disable SSH feature when it's not available.
266266
- `START_SSH_SERVER`: **false**: When enabled, use the built-in SSH server.
267267
- `BUILTIN_SSH_SERVER_USER`: **%(RUN_USER)s**: Username to use for the built-in SSH Server.
268+
- `SSH_USER`: **%(BUILTIN_SSH_SERVER_USER)**: SSH username displayed in clone URLs. This is only for people who configure the SSH server themselves; in most cases, you want to leave this blank and modify the `BUILTIN_SSH_SERVER_USER`.
268269
- `SSH_DOMAIN`: **%(DOMAIN)s**: Domain name of this server, used for displayed clone URL.
269270
- `SSH_PORT`: **22**: SSH port displayed in clone URL.
270271
- `SSH_LISTEN_HOST`: **0.0.0.0**: Listen address for the built-in SSH server.

integrations/repo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func TestViewRepo1CloneLinkAuthorized(t *testing.T) {
135135
assert.Equal(t, setting.AppURL+"user2/repo1.git", link)
136136
link, exists = htmlDoc.doc.Find("#repo-clone-ssh").Attr("data-link")
137137
assert.True(t, exists, "The template has changed")
138-
sshURL := fmt.Sprintf("ssh://%s@%s:%d/user2/repo1.git", setting.SSH.BuiltinServerUser, setting.SSH.Domain, setting.SSH.Port)
138+
sshURL := fmt.Sprintf("ssh://%s@%s:%d/user2/repo1.git", setting.SSH.User, setting.SSH.Domain, setting.SSH.Port)
139139
assert.Equal(t, sshURL, link)
140140
}
141141

models/issue_label.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
)
2323

2424
// LabelColorPattern is a regexp witch can validate LabelColor
25-
var LabelColorPattern = regexp.MustCompile("^#[0-9a-fA-F]{6}$")
25+
var LabelColorPattern = regexp.MustCompile("^#?(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{3})$")
2626

2727
// Label represents a label of repository for issues.
2828
type Label struct {
@@ -258,6 +258,23 @@ func NewLabel(label *Label) error {
258258
if !LabelColorPattern.MatchString(label.Color) {
259259
return fmt.Errorf("bad color code: %s", label.Color)
260260
}
261+
262+
// normalize case
263+
label.Color = strings.ToLower(label.Color)
264+
265+
// add leading hash
266+
if label.Color[0] != '#' {
267+
label.Color = "#" + label.Color
268+
}
269+
270+
// convert 3-character shorthand into 6-character version
271+
if len(label.Color) == 4 {
272+
r := label.Color[1]
273+
g := label.Color[2]
274+
b := label.Color[3]
275+
label.Color = fmt.Sprintf("#%c%c%c%c%c%c", r, r, g, g, b, b)
276+
}
277+
261278
return newLabel(db.GetEngine(db.DefaultContext), label)
262279
}
263280

models/issue_label_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@ func TestNewLabels(t *testing.T) {
3838
assert.NoError(t, unittest.PrepareTestDatabase())
3939
labels := []*Label{
4040
{RepoID: 2, Name: "labelName2", Color: "#123456"},
41-
{RepoID: 3, Name: "labelName3", Color: "#23456F"},
41+
{RepoID: 3, Name: "labelName3", Color: "#123"},
42+
{RepoID: 4, Name: "labelName4", Color: "ABCDEF"},
43+
{RepoID: 5, Name: "labelName5", Color: "DEF"},
4244
}
4345
assert.Error(t, NewLabel(&Label{RepoID: 3, Name: "invalid Color", Color: ""}))
44-
assert.Error(t, NewLabel(&Label{RepoID: 3, Name: "invalid Color", Color: "123456"}))
46+
assert.Error(t, NewLabel(&Label{RepoID: 3, Name: "invalid Color", Color: "#45G"}))
4547
assert.Error(t, NewLabel(&Label{RepoID: 3, Name: "invalid Color", Color: "#12345G"}))
48+
assert.Error(t, NewLabel(&Label{RepoID: 3, Name: "invalid Color", Color: "45G"}))
49+
assert.Error(t, NewLabel(&Label{RepoID: 3, Name: "invalid Color", Color: "12345G"}))
4650
for _, label := range labels {
4751
unittest.AssertNotExistsBean(t, label)
4852
}

models/repo/repo.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,7 @@ func (repo *Repository) cloneLink(isWiki bool) *CloneLink {
540540
repoName += ".wiki"
541541
}
542542

543-
sshUser := setting.RunUser
544-
if setting.SSH.StartBuiltinServer {
545-
sshUser = setting.SSH.BuiltinServerUser
546-
}
543+
sshUser := setting.SSH.User
547544

548545
cl := new(CloneLink)
549546

models/repo/wiki_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestRepository_WikiCloneLink(t *testing.T) {
1919

2020
repo := unittest.AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
2121
cloneLink := repo.WikiCloneLink()
22-
assert.Equal(t, "ssh://runuser@try.gitea.io:3000/user2/repo1.wiki.git", cloneLink.SSH)
22+
assert.Equal(t, "ssh://sshuser@try.gitea.io:3000/user2/repo1.wiki.git", cloneLink.SSH)
2323
assert.Equal(t, "https://try.gitea.io/user2/repo1.wiki.git", cloneLink.HTTPS)
2424
}
2525

models/unittest/testdb.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ func MainTest(m *testing.M, pathToGiteaRoot string, fixtureFiles ...string) {
6464

6565
setting.AppURL = "https://try.gitea.io/"
6666
setting.RunUser = "runuser"
67+
setting.SSH.User = "sshuser"
68+
setting.SSH.BuiltinServerUser = "builtinuser"
6769
setting.SSH.Port = 3000
6870
setting.SSH.Domain = "try.gitea.io"
6971
setting.Database.UseSQLite3 = true

modules/setting/setting.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ var (
131131
BuiltinServerUser string `ini:"BUILTIN_SSH_SERVER_USER"`
132132
Domain string `ini:"SSH_DOMAIN"`
133133
Port int `ini:"SSH_PORT"`
134+
User string `ini:"SSH_USER"`
134135
ListenHost string `ini:"SSH_LISTEN_HOST"`
135136
ListenPort int `ini:"SSH_LISTEN_PORT"`
136137
RootPath string `ini:"SSH_ROOT_PATH"`
@@ -970,6 +971,7 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
970971
}
971972

972973
SSH.BuiltinServerUser = Cfg.Section("server").Key("BUILTIN_SSH_SERVER_USER").MustString(RunUser)
974+
SSH.User = Cfg.Section("server").Key("SSH_USER").MustString(SSH.BuiltinServerUser)
973975

974976
newRepository()
975977

options/locale/locale_zh-CN.ini

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -957,14 +957,14 @@ migrate.migrating=正在从 <b>%s</b> 迁移...
957957
migrate.migrating_failed=从 <b>%s</b> 迁移失败。
958958
migrate.migrating_failed.error=错误:%s
959959
migrate.migrating_failed_no_addr=迁移失败。
960-
migrate.github.description=从 github.com 或其他 GitHub 实例迁移数据
960+
migrate.github.description=从 github.com 或其他 GitHub 实例迁移数据
961961
migrate.git.description=从任意 Git 服务迁移仓库。
962-
migrate.gitlab.description=从 gitlab.com 或其他 GitLab 实例迁移数据
963-
migrate.gitea.description=从 gitea.com 或其他 Gitea 实例迁移数据
962+
migrate.gitlab.description=从 gitlab.com 或其他 GitLab 实例迁移数据
963+
migrate.gitea.description=从 gitea.com 或其他 Gitea 实例迁移数据
964964
migrate.gogs.description=从 notabug.org 或其他 Gogs 实例迁移数据。
965-
migrate.onedev.description=从 code.onedev.io 或其他 OneDev 实例迁移数据
966-
migrate.codebase.description=从 codebasehq.com 迁移数据
967-
migrate.gitbucket.description=从 GitBucket 实例迁移数据
965+
migrate.onedev.description=从 code.onedev.io 或其他 OneDev 实例迁移数据
966+
migrate.codebase.description=从 codebasehq.com 迁移数据
967+
migrate.gitbucket.description=从 GitBucket 实例迁移数据
968968
migrate.migrating_git=迁移Git数据
969969
migrate.migrating_topics=迁移主题
970970
migrate.migrating_milestones=迁移里程碑

0 commit comments

Comments
 (0)