From 7fb71b36ad50153f6e05d066284688d1128a7a21 Mon Sep 17 00:00:00 2001 From: Runxi Yu <me@runxiyu.org> Date: Wed, 19 Feb 2025 21:19:15 +0800 Subject: ssh/recv, hooks: Create MRs on push, reject pushes to others' MRs --- ssh_utils.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ssh_utils.go') diff --git a/ssh_utils.go b/ssh_utils.go index fb8f920..7f3188f 100644 --- a/ssh_utils.go +++ b/ssh_utils.go @@ -9,19 +9,19 @@ import ( var err_ssh_illegal_endpoint = errors.New("illegal endpoint during SSH access") -func get_repo_path_perms_from_ssh_path_pubkey(ctx context.Context, ssh_path string, ssh_pubkey string) (repo_path string, direct_access bool, contrib_requirements string, user_type string, err error) { +func get_repo_path_perms_from_ssh_path_pubkey(ctx context.Context, ssh_path string, ssh_pubkey string) (repo_id int, repo_path string, direct_access bool, contrib_requirements string, user_type string, user_id int, err error) { segments := strings.Split(strings.TrimPrefix(ssh_path, "/"), "/") for i, segment := range segments { var err error segments[i], err = url.PathUnescape(segment) if err != nil { - return "", false, "", "", err + return 0, "", false, "", "", 0, err } } if segments[0] == ":" { - return "", false, "", "", err_ssh_illegal_endpoint + return 0, "", false, "", "", 0, err_ssh_illegal_endpoint } separator_index := -1 @@ -37,9 +37,9 @@ func get_repo_path_perms_from_ssh_path_pubkey(ctx context.Context, ssh_path stri switch { case separator_index == -1: - return "", false, "", "", err_ssh_illegal_endpoint + return 0, "", false, "", "", 0, err_ssh_illegal_endpoint case len(segments) <= separator_index+2: - return "", false, "", "", err_ssh_illegal_endpoint + return 0, "", false, "", "", 0, err_ssh_illegal_endpoint } group_name := segments[0] @@ -49,6 +49,6 @@ func get_repo_path_perms_from_ssh_path_pubkey(ctx context.Context, ssh_path stri case "repos": return get_path_perm_by_group_repo_key(ctx, group_name, module_name, ssh_pubkey) default: - return "", false, "", "", err_ssh_illegal_endpoint + return 0, "", false, "", "", 0, err_ssh_illegal_endpoint } } -- cgit v1.2.3