mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-06 14:36:43 +02:00
update serv command to recognize group ids in urls
This commit is contained in:
+13
-4
@@ -201,8 +201,17 @@ func runServ(ctx context.Context, c *cli.Command) error {
|
||||
|
||||
repoPath := strings.TrimPrefix(sshCmdArgs[1], "/")
|
||||
repoPathFields := strings.SplitN(repoPath, "/", 2)
|
||||
rawGroup, _, _ := strings.Cut(repoPathFields[1], "/")
|
||||
var groupID int64
|
||||
if len(repoPathFields) != 2 {
|
||||
return fail(ctx, "Invalid repository path", "Invalid repository path: %v", repoPath)
|
||||
if len(repoPathFields) == 3 {
|
||||
groupID, err = strconv.ParseInt(rawGroup, 10, 64)
|
||||
if err != nil {
|
||||
return fail(ctx, "Invalid repository path", "Invalid repository path: %v", repoPath)
|
||||
}
|
||||
} else {
|
||||
return fail(ctx, "Invalid repository path", "Invalid repository path: %v", repoPath)
|
||||
}
|
||||
}
|
||||
|
||||
username := repoPathFields[0]
|
||||
@@ -249,16 +258,16 @@ func runServ(ctx context.Context, c *cli.Command) error {
|
||||
|
||||
requestedMode := getAccessMode(verb, lfsVerb)
|
||||
|
||||
results, extra := private.ServCommand(ctx, keyID, username, reponame, requestedMode, verb, lfsVerb)
|
||||
results, extra := private.ServCommand(ctx, keyID, username, reponame, groupID, requestedMode, verb, lfsVerb)
|
||||
if extra.HasError() {
|
||||
return fail(ctx, extra.UserMsg, "ServCommand failed: %s", extra.Error)
|
||||
}
|
||||
|
||||
// because the original repoPath maybe redirected, we need to use the returned actual repository information
|
||||
if results.IsWiki {
|
||||
repoPath = repo_model.RelativeWikiPath(results.OwnerName, results.RepoName)
|
||||
repoPath = repo_model.RelativeWikiPath(results.OwnerName, results.RepoName, groupID)
|
||||
} else {
|
||||
repoPath = repo_model.RelativePath(results.OwnerName, results.RepoName)
|
||||
repoPath = repo_model.RelativePath(results.OwnerName, results.RepoName, groupID)
|
||||
}
|
||||
|
||||
// LFS SSH protocol
|
||||
|
||||
Reference in New Issue
Block a user