Skip to content

Commit d40c46c

Browse files
committed
Use the exist function
1 parent cb05ffb commit d40c46c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

cmd/serv.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
asymkey_model "code.gitea.io/gitea/models/asymkey"
1919
git_model "code.gitea.io/gitea/models/git"
2020
"code.gitea.io/gitea/models/perm"
21-
"code.gitea.io/gitea/models/repo"
21+
repo_model "code.gitea.io/gitea/models/repo"
2222
"code.gitea.io/gitea/modules/git"
2323
"code.gitea.io/gitea/modules/git/gitcmd"
2424
"code.gitea.io/gitea/modules/json"
@@ -29,7 +29,6 @@ import (
2929
"code.gitea.io/gitea/modules/process"
3030
repo_module "code.gitea.io/gitea/modules/repository"
3131
"code.gitea.io/gitea/modules/setting"
32-
"code.gitea.io/gitea/modules/util"
3332
"code.gitea.io/gitea/services/lfs"
3433

3534
"github.com/kballard/go-shellquote"
@@ -208,7 +207,7 @@ func runServ(ctx context.Context, c *cli.Command) error {
208207
username := repoPathFields[0]
209208
reponame := strings.TrimSuffix(repoPathFields[1], ".git") // “the-repo-name" or "the-repo-name.wiki"
210209

211-
if !repo.IsValidSSHAccessRepoName(reponame) {
210+
if !repo_model.IsValidSSHAccessRepoName(reponame) {
212211
return fail(ctx, "Invalid repo name", "Invalid repo name: %s", reponame)
213212
}
214213

@@ -254,10 +253,12 @@ func runServ(ctx context.Context, c *cli.Command) error {
254253
return fail(ctx, extra.UserMsg, "ServCommand failed: %s", extra.Error)
255254
}
256255

257-
// LowerCase and trim the repoPath as that's how they are stored.
258-
// This should be done after splitting the repoPath into username and reponame
259-
// so that username and reponame are not affected.
260-
repoPath = strings.ToLower(results.OwnerName + "/" + results.RepoName + util.Iif(results.IsWiki, ".wiki", "") + ".git")
256+
// because the original repoPath maybe redirected, we need to use the returned actual repository information
257+
if results.IsWiki {
258+
repoPath = repo_model.RelativeWikiPath(results.OwnerName, results.RepoName)
259+
} else {
260+
repoPath = repo_model.RelativePath(results.OwnerName, results.RepoName)
261+
}
261262

262263
// LFS SSH protocol
263264
if verb == git.CmdVerbLfsTransfer {

0 commit comments

Comments
 (0)