From 80492711b4588c10dffa93a57fd9926dc337bbae Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Wed, 05 Mar 2025 10:05:04 +0800 Subject: [PATCH] *: Typing fixes --- git_hooks_deploy.go | 1 - git_hooks_handle.go | 2 +- http_handle_repo_commit.go | 2 +- http_handle_repo_contrib_one.go | 9 +++++---- http_server.go | 2 +- resources.go | 3 ++- users.go | 4 +++- diff --git a/git_hooks_deploy.go b/git_hooks_deploy.go index 6acb54f6ab8a312f15d5f7a88c6002424b792cd4..b70ccfe72c729d6a7fe85658d5a2b9a2aa0d9056 100644 --- a/git_hooks_deploy.go +++ b/git_hooks_deploy.go @@ -4,7 +4,6 @@ package main import ( - "errors" "io" "io/fs" "os" diff --git a/git_hooks_handle.go b/git_hooks_handle.go index 9b0f966a000a0d7bf1713081dfc88e911877c047..f2359a2300f107ab27e002fbc7e2f3216d0fc547 100644 --- a/git_hooks_handle.go +++ b/git_hooks_handle.go @@ -82,7 +82,7 @@ } ssh_stderr = pack_to_hook.session.Stderr() - ssh_stderr.Write([]byte{'\n'}) + _, _ = ssh_stderr.Write([]byte{'\n'}) hook_return_value = func() byte { var argc64 uint64 diff --git a/http_handle_repo_commit.go b/http_handle_repo_commit.go index 094a8621d9469412fb0066c33345396dde1c18d0..8f2204e2ea7f3dcbbace4eda63bbaf7a326acf12 100644 --- a/http_handle_repo_commit.go +++ b/http_handle_repo_commit.go @@ -103,7 +103,7 @@ mode: misc.First_or_panic(filemode.New("100644")), path: "", } -func make_usable_file_patches(patch diff.Patch) (usable_file_patches []usable_file_patch) { +func make_usable_file_patches(patch diff.Patch) (usable_file_patches []usable_file_patch_t) { // TODO: Remove unnecessary context // TODO: Prepend "+"/"-"/" " instead of solely distinguishing based on color diff --git a/http_handle_repo_contrib_one.go b/http_handle_repo_contrib_one.go index 91acfeafdbd66fe59d6e0e1e2c9469dc8e0ca053..9810d5dbbeda7ef138677df07a6736a17b401871 100644 --- a/http_handle_repo_contrib_one.go +++ b/http_handle_repo_contrib_one.go @@ -55,11 +55,12 @@ destination_branch = "HEAD" destination_branch_hash, err = get_ref_hash_from_type_and_name(repo, "", "") } else { destination_branch_hash, err = get_ref_hash_from_type_and_name(repo, "branch", destination_branch) - if err != nil { - http.Error(w, "Error getting destination branch hash: "+err.Error(), http.StatusInternalServerError) - return - } + } + if err != nil { + http.Error(w, "Error getting destination branch hash: "+err.Error(), http.StatusInternalServerError) + return } + destination_commit, err := repo.CommitObject(destination_branch_hash) if err != nil { http.Error(w, "Error getting destination commit: "+err.Error(), http.StatusInternalServerError) diff --git a/http_server.go b/http_server.go index 849afd95d1f56772a323d5a20633d9d423264920..0acb9a773a4fa6395573d162d38db83a56326634 100644 --- a/http_server.go +++ b/http_server.go @@ -22,8 +22,8 @@ var segments []string var err error var non_empty_last_segments_len int - var params map[string]any var separator_index int + params := make(map[string]any) if segments, _, err = parse_request_uri(r.RequestURI); err != nil { http.Error(w, err.Error(), http.StatusBadRequest) diff --git a/resources.go b/resources.go index a65e8b76161daf8b42e03d49680874f298797b9a..6c3cece40de1eaeb9cf2c8aa9ba5a1c3ac17f8fa 100644 --- a/resources.go +++ b/resources.go @@ -44,7 +44,8 @@ var static_handler http.Handler func init() { - if static_fs, err := fs.Sub(resources_fs, "static"); err != nil { + static_fs, err := fs.Sub(resources_fs, "static") + if err != nil { panic(err) } static_handler = http.StripPrefix("/:/static/", http.FileServer(http.FS(static_fs))) diff --git a/users.go b/users.go index 740f94f229f287e86bf39004cb1e9400a0af1cba..4c2f9a621919f054a8c10f8f57a4a80afb490623 100644 --- a/users.go +++ b/users.go @@ -15,7 +15,9 @@ if tx, err = database.Begin(ctx); err != nil { return } - defer tx.Rollback(ctx) + defer func() { + _ = tx.Rollback(ctx) + }() if err = tx.QueryRow(ctx, `INSERT INTO users (type) VALUES ('pubkey_only') RETURNING id`).Scan(&user_id); err != nil { return -- 2.48.1