diff options
author | Runxi Yu <me@runxiyu.org> | 2025-02-20 11:32:52 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-02-20 11:32:52 +0800 |
commit | f947e4d7e72c45e9a4199ed191a4396db2ac3c60 (patch) | |
tree | 3496900b0c11e67f5f38d0cc58b58e58173e3e32 /ssh_utils.go | |
parent | hooks: Clarify the last ACK/NAK being overall (diff) | |
download | forge-f947e4d7e72c45e9a4199ed191a4396db2ac3c60.tar.gz forge-f947e4d7e72c45e9a4199ed191a4396db2ac3c60.tar.zst forge-f947e4d7e72c45e9a4199ed191a4396db2ac3c60.zip |
hooks, ssh: Indicate URL of newly-created MRs
Diffstat (limited to 'ssh_utils.go')
-rw-r--r-- | ssh_utils.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/ssh_utils.go b/ssh_utils.go index 8ad53ab..48b25b9 100644 --- a/ssh_utils.go +++ b/ssh_utils.go @@ -13,19 +13,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_id int, repo_path string, direct_access bool, contrib_requirements string, user_type string, user_id int, err error) { +func get_repo_path_perms_from_ssh_path_pubkey(ctx context.Context, ssh_path string, ssh_pubkey string) (group_name string, repo_name 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 0, "", false, "", "", 0, err + return "", "", 0, "", false, "", "", 0, err } } if segments[0] == ":" { - return 0, "", false, "", "", 0, err_ssh_illegal_endpoint + return "", "", 0, "", false, "", "", 0, err_ssh_illegal_endpoint } separator_index := -1 @@ -41,19 +41,21 @@ func get_repo_path_perms_from_ssh_path_pubkey(ctx context.Context, ssh_path stri switch { case separator_index == -1: - return 0, "", false, "", "", 0, err_ssh_illegal_endpoint + return "", "", 0, "", false, "", "", 0, err_ssh_illegal_endpoint case len(segments) <= separator_index+2: - return 0, "", false, "", "", 0, err_ssh_illegal_endpoint + return "", "", 0, "", false, "", "", 0, err_ssh_illegal_endpoint } - group_name := segments[0] + group_name = segments[0] module_type := segments[separator_index+1] module_name := segments[separator_index+2] + repo_name = module_name switch module_type { case "repos": - return get_path_perm_by_group_repo_key(ctx, group_name, module_name, ssh_pubkey) + _1, _2, _3, _4, _5, _6, _7 := get_path_perm_by_group_repo_key(ctx, group_name, module_name, ssh_pubkey) + return group_name, repo_name, _1, _2, _3, _4, _5, _6, _7 default: - return 0, "", false, "", "", 0, err_ssh_illegal_endpoint + return "", "", 0, "", false, "", "", 0, err_ssh_illegal_endpoint } } |