update serv command to recognize group ids in urls

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧
2026-04-02 20:00:59 -04:00
parent 29a68da062
commit 27cdd77a59
2 changed files with 20 additions and 6 deletions
+13 -4
View File
@@ -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