Skip to content

Commit bc8cef7

Browse files
authored
Merge branch 'main' into get-last-commit-parent-tracking
2 parents 55455c3 + c1ff59c commit bc8cef7

File tree

8 files changed

+54
-7
lines changed

8 files changed

+54
-7
lines changed

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ EXTRA_GOFLAGS ?=
6464
MAKE_VERSION := $(shell $(MAKE) -v | head -n 1)
6565
MAKE_EVIDENCE_DIR := .make_evidence
6666

67-
ifneq ($(RACE_ENABLED),)
68-
GOTESTFLAGS ?= -race
67+
ifeq ($(RACE_ENABLED),true)
68+
GOFLAGS += -race
69+
GOTESTFLAGS += -race
6970
endif
7071

7172
STORED_VERSION_FILE := VERSION
@@ -380,7 +381,7 @@ test-check:
380381
.PHONY: test\#%
381382
test\#%:
382383
@echo "Running go test with -tags '$(TEST_TAGS)'..."
383-
@$(GO) test -mod=vendor -tags='$(TEST_TAGS)' -run $(subst .,/,$*) $(GO_PACKAGES)
384+
@$(GO) test -mod=vendor $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -run $(subst .,/,$*) $(GO_PACKAGES)
384385

385386
.PHONY: coverage
386387
coverage:

docker/root/etc/s6/openssh/setup

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ if [ -d /etc/ssh ]; then
4747
SSH_RSA_CERT="${SSH_RSA_CERT:+"HostCertificate "}${SSH_RSA_CERT}" \
4848
SSH_ECDSA_CERT="${SSH_ECDSA_CERT:+"HostCertificate "}${SSH_ECDSA_CERT}" \
4949
SSH_DSA_CERT="${SSH_DSA_CERT:+"HostCertificate "}${SSH_DSA_CERT}" \
50+
SSH_MAX_STARTUPS="${SSH_MAX_STARTUPS:+"MaxStartups "}${SSH_MAX_STARTUPS}" \
51+
SSH_MAX_SESSIONS="${SSH_MAX_SESSIONS:+"MaxSessions "}${SSH_MAX_SESSIONS}" \
5052
envsubst < /etc/templates/sshd_config > /etc/ssh/sshd_config
5153

5254
chmod 0644 /etc/ssh/sshd_config

docker/root/etc/templates/sshd_config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ AddressFamily any
55
ListenAddress 0.0.0.0
66
ListenAddress ::
77

8-
MaxStartups ${SSH_MAX_STARTUPS}
9-
MaxSessions ${SSH_MAX_SESSIONS}
8+
${SSH_MAX_STARTUPS}
9+
${SSH_MAX_SESSIONS}
1010

1111
LogLevel INFO
1212

models/repo.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,26 @@ func UpdateRepository(repo *Repository, visibilityChanged bool) (err error) {
13501350
return sess.Commit()
13511351
}
13521352

1353+
// UpdateRepositoryOwnerNames updates repository owner_names (this should only be used when the ownerName has changed case)
1354+
func UpdateRepositoryOwnerNames(ownerID int64, ownerName string) error {
1355+
if ownerID == 0 {
1356+
return nil
1357+
}
1358+
sess := x.NewSession()
1359+
defer sess.Close()
1360+
if err := sess.Begin(); err != nil {
1361+
return err
1362+
}
1363+
1364+
if _, err := sess.Where("owner_id = ?", ownerID).Cols("owner_name").Update(&Repository{
1365+
OwnerName: ownerName,
1366+
}); err != nil {
1367+
return err
1368+
}
1369+
1370+
return sess.Commit()
1371+
}
1372+
13531373
// UpdateRepositoryUpdatedTime updates a repository's updated time
13541374
func UpdateRepositoryUpdatedTime(repoID int64, updateTime time.Time) error {
13551375
_, err := x.Exec("UPDATE repository SET updated_unix = ? WHERE id = ?", updateTime.Unix(), repoID)

routers/install.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"code.gitea.io/gitea/modules/log"
2222
"code.gitea.io/gitea/modules/setting"
2323
"code.gitea.io/gitea/modules/templates"
24+
"code.gitea.io/gitea/modules/translation"
2425
"code.gitea.io/gitea/modules/user"
2526
"code.gitea.io/gitea/modules/util"
2627
"code.gitea.io/gitea/modules/web"
@@ -61,6 +62,8 @@ func InstallInit(next http.Handler) http.Handler {
6162
"DbOptions": setting.SupportedDatabases,
6263
"i18n": locale,
6364
"Language": locale.Language(),
65+
"Lang": locale.Language(),
66+
"AllLangs": translation.AllLangs(),
6467
"CurrentURL": setting.AppSubURL + req.URL.RequestURI(),
6568
"PageStartTime": startTime,
6669
"TmplLoadTimes": func() string {
@@ -69,6 +72,12 @@ func InstallInit(next http.Handler) http.Handler {
6972
"PasswordHashAlgorithms": models.AvailableHashAlgorithms,
7073
},
7174
}
75+
for _, lang := range translation.AllLangs() {
76+
if lang.Lang == locale.Language() {
77+
ctx.Data["LangName"] = lang.Name
78+
break
79+
}
80+
}
7281
ctx.Req = context.WithContext(req, &ctx)
7382
next.ServeHTTP(resp, ctx.Req)
7483
})

routers/org/setting.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func SettingsPost(ctx *context.Context) {
5252
}
5353

5454
org := ctx.Org.Organization
55+
nameChanged := org.Name != form.Name
5556

5657
// Check if organization name has been changed.
5758
if org.LowerName != strings.ToLower(form.Name) {
@@ -75,7 +76,9 @@ func SettingsPost(ctx *context.Context) {
7576
// reset ctx.org.OrgLink with new name
7677
ctx.Org.OrgLink = setting.AppSubURL + "/org/" + form.Name
7778
log.Trace("Organization name changed: %s -> %s", org.Name, form.Name)
79+
nameChanged = false
7880
}
81+
7982
// In case it's just a case change.
8083
org.Name = form.Name
8184
org.LowerName = strings.ToLower(form.Name)
@@ -105,11 +108,17 @@ func SettingsPost(ctx *context.Context) {
105108
return
106109
}
107110
for _, repo := range org.Repos {
111+
repo.OwnerName = org.Name
108112
if err := models.UpdateRepository(repo, true); err != nil {
109113
ctx.ServerError("UpdateRepository", err)
110114
return
111115
}
112116
}
117+
} else if nameChanged {
118+
if err := models.UpdateRepositoryOwnerNames(org.ID, org.Name); err != nil {
119+
ctx.ServerError("UpdateRepository", err)
120+
return
121+
}
113122
}
114123

115124
log.Trace("Organization setting updated: %s", org.Name)

routers/routes/install.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func InstallRoutes() *web.Route {
103103
r.Get("/", routers.Install)
104104
r.Post("/", web.Bind(forms.InstallForm{}), routers.InstallPost)
105105
r.NotFound(func(w http.ResponseWriter, req *http.Request) {
106-
http.Redirect(w, req, setting.AppURL, 302)
106+
http.Redirect(w, req, setting.AppURL, http.StatusFound)
107107
})
108108
return r
109109
}

routers/user/setting/profile.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,13 @@ func HandleUsernameChange(ctx *context.Context, user *models.User, newName strin
6868
}
6969
return err
7070
}
71-
log.Trace("User name changed: %s -> %s", user.Name, newName)
71+
} else {
72+
if err := models.UpdateRepositoryOwnerNames(user.ID, newName); err != nil {
73+
ctx.ServerError("UpdateRepository", err)
74+
return err
75+
}
7276
}
77+
log.Trace("User name changed: %s -> %s", user.Name, newName)
7378
return nil
7479
}
7580

@@ -85,6 +90,7 @@ func ProfilePost(ctx *context.Context) {
8590
}
8691

8792
if len(form.Name) != 0 && ctx.User.Name != form.Name {
93+
log.Debug("Changing name for %s to %s", ctx.User.Name, form.Name)
8894
if err := HandleUsernameChange(ctx, ctx.User, form.Name); err != nil {
8995
ctx.Redirect(setting.AppSubURL + "/user/settings")
9096
return

0 commit comments

Comments
 (0)