Skip to content

Commit

Permalink
Fix push to create with capitalize repo name (go-gitea#29090) (go-git…
Browse files Browse the repository at this point in the history
…ea#29206)

Fix go-gitea#29073
Backport go-gitea#29090

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
  • Loading branch information
lunny and KN4CK3R authored Feb 17, 2024
1 parent fea6bd1 commit 933cc4d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cmd/serv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
if len(rr) != 2 {
return fail(ctx, "Invalid repository path", "Invalid repository path: %v", repoPath)
}

username := strings.ToLower(rr[0])
reponame := strings.ToLower(strings.TrimSuffix(rr[1], ".git"))
username := rr[0]
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) {
return fail(ctx, "Invalid repo name", "Invalid repo name: %s", reponame)
Expand Down

0 comments on commit 933cc4d

Please sign in to comment.