From d1a1358c447175bdfd2c44f0baf2f53201ed096a Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Tue, 18 Mar 2025 20:12:32 +0800 Subject: [PATCH] gofumpt --- acl.go | 2 +- http_handle_repo_index.go | 10 ++++++---- ssh_handle_receive_pack.go | 2 +- ssh_handle_upload_pack.go | 2 +- ssh_utils.go | 2 +- diff --git a/acl.go b/acl.go index 597760a69c3335d01fb26368d38f637ce4bbefba..d2e8190e1542fa8390c1dbe5080fd7565e3fde2e 100644 --- a/acl.go +++ b/acl.go @@ -11,7 +11,7 @@ ) // get_path_perm_by_group_repo_key returns the filesystem path and direct // access permission for a given repo and a provided ssh public key. -func get_path_perm_by_group_repo_key(ctx context.Context, group_path []string, repo_name, ssh_pubkey string) (repo_id int, filesystem_path string, access bool, contrib_requirements string, user_type string, user_id int, err error) { +func get_path_perm_by_group_repo_key(ctx context.Context, group_path []string, repo_name, ssh_pubkey string) (repo_id int, filesystem_path string, access bool, contrib_requirements, user_type string, user_id int, err error) { err = database.QueryRow(ctx, ` WITH RECURSIVE group_path_cte AS ( -- Start: match the first name in the path where parent_group IS NULL diff --git a/http_handle_repo_index.go b/http_handle_repo_index.go index e4a9f5d6f0d23b75e3522eeb0048d093d1b9ea6c..da06500f1d3e69b4f67b5a23a67aceaacd989686 100644 --- a/http_handle_repo_index.go +++ b/http_handle_repo_index.go @@ -9,8 +9,8 @@ "strings" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" - "github.com/go-git/go-git/v5/plumbing/storer" "github.com/go-git/go-git/v5/plumbing/object" + "github.com/go-git/go-git/v5/plumbing/storer" ) func handle_repo_index(w http.ResponseWriter, r *http.Request, params map[string]any) { @@ -38,12 +38,14 @@ goto no_ref } branches_, err = repo.Branches() - if err != nil {} - err = branches_.ForEach(func (branch *plumbing.Reference) error { + if err != nil { + } + err = branches_.ForEach(func(branch *plumbing.Reference) error { branches = append(branches, branch.Name().Short()) return nil }) - if err != nil {} + if err != nil { + } params["branches"] = branches if recent_commits, err = get_recent_commits(repo, ref_hash, 3); err != nil { diff --git a/ssh_handle_receive_pack.go b/ssh_handle_receive_pack.go index b77b717f085028f9797f1ea7d0351396d98a3021..3f7c1f1404941ca5ad4428bf0f639862aca11734 100644 --- a/ssh_handle_receive_pack.go +++ b/ssh_handle_receive_pack.go @@ -31,7 +31,7 @@ var pack_to_hook_by_cookie = cmap.Map[string, pack_to_hook_t]{} // ssh_handle_receive_pack handles attempts to push to repos. -func ssh_handle_receive_pack(session glider_ssh.Session, pubkey string, repo_identifier string) (err error) { +func ssh_handle_receive_pack(session glider_ssh.Session, pubkey, repo_identifier string) (err error) { group_path, repo_name, repo_id, repo_path, direct_access, contrib_requirements, user_type, user_id, err := get_repo_path_perms_from_ssh_path_pubkey(session.Context(), repo_identifier, pubkey) if err != nil { return err diff --git a/ssh_handle_upload_pack.go b/ssh_handle_upload_pack.go index fbbdfda0e0f8eacaa11cbcaaa0288959eb4d9341..0aa2f17154b49d3e4b96d2daa0ecfb92834f8f60 100644 --- a/ssh_handle_upload_pack.go +++ b/ssh_handle_upload_pack.go @@ -13,7 +13,7 @@ ) // ssh_handle_upload_pack handles clones/fetches. It just uses git-upload-pack // and has no ACL checks. -func ssh_handle_upload_pack(session glider_ssh.Session, pubkey string, repo_identifier string) (err error) { +func ssh_handle_upload_pack(session glider_ssh.Session, pubkey, repo_identifier string) (err error) { var repo_path string if _, _, _, repo_path, _, _, _, _, err = get_repo_path_perms_from_ssh_path_pubkey(session.Context(), repo_identifier, pubkey); err != nil { return err diff --git a/ssh_utils.go b/ssh_utils.go index d40facf1ebb73982c51498c10fff14918fcd836d..ac0781e4d7ff9b5a720bf80c7e9ed4b5d0e77be9 100644 --- a/ssh_utils.go +++ b/ssh_utils.go @@ -16,7 +16,7 @@ ) 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) (group_path []string, repo_name 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, ssh_pubkey string) (group_path []string, repo_name string, repo_id int, repo_path string, direct_access bool, contrib_requirements, user_type string, user_id int, err error) { var segments []string var separator_index int var module_type, module_name string -- 2.48.1