1
1
mirror of https://github.com/go-gitea/gitea synced 2024-12-24 09:34:26 +00:00

Fix push to create with capitalize repo name (#29090) (#29206)

Fix #29073
Backport #29090

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
This commit is contained in:
Lunny Xiao 2024-02-17 20:06:55 +08:00 committed by GitHub
parent fea6bd130e
commit 933cc4da64
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -216,16 +216,18 @@ func runServ(c *cli.Context) error {
} }
} }
// LowerCase and trim the repoPath as that's how they are stored.
repoPath = strings.ToLower(strings.TrimSpace(repoPath))
rr := strings.SplitN(repoPath, "/", 2) rr := strings.SplitN(repoPath, "/", 2)
if len(rr) != 2 { if len(rr) != 2 {
return fail(ctx, "Invalid repository path", "Invalid repository path: %v", repoPath) return fail(ctx, "Invalid repository path", "Invalid repository path: %v", repoPath)
} }
username := strings.ToLower(rr[0]) username := rr[0]
reponame := strings.ToLower(strings.TrimSuffix(rr[1], ".git")) reponame := strings.TrimSuffix(rr[1], ".git")
// LowerCase and trim the repoPath as that's how they are stored.
// This should be done after splitting the repoPath into username and reponame
// so that username and reponame are not affected.
repoPath = strings.ToLower(strings.TrimSpace(repoPath))
if alphaDashDotPattern.MatchString(reponame) { if alphaDashDotPattern.MatchString(reponame) {
return fail(ctx, "Invalid repo name", "Invalid repo name: %s", reponame) return fail(ctx, "Invalid repo name", "Invalid repo name: %s", reponame)