diff options
author | Runxi Yu <me@runxiyu.org> | 2025-03-05 10:05:04 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-03-05 10:05:04 +0800 |
commit | 80492711b4588c10dffa93a57fd9926dc337bbae (patch) | |
tree | 93b6240452b0c274d2f50cb396ae8e441b3ff6ea | |
parent | *: Replacing more := with var (diff) | |
download | forge-80492711b4588c10dffa93a57fd9926dc337bbae.tar.gz forge-80492711b4588c10dffa93a57fd9926dc337bbae.tar.zst forge-80492711b4588c10dffa93a57fd9926dc337bbae.zip |
*: Typing fixes
-rw-r--r-- | git_hooks_deploy.go | 1 | ||||
-rw-r--r-- | git_hooks_handle.go | 2 | ||||
-rw-r--r-- | http_handle_repo_commit.go | 2 | ||||
-rw-r--r-- | http_handle_repo_contrib_one.go | 9 | ||||
-rw-r--r-- | http_server.go | 2 | ||||
-rw-r--r-- | resources.go | 3 | ||||
-rw-r--r-- | users.go | 4 |
7 files changed, 13 insertions, 10 deletions
diff --git a/git_hooks_deploy.go b/git_hooks_deploy.go index 6acb54f..b70ccfe 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 9b0f966..f2359a2 100644 --- a/git_hooks_handle.go +++ b/git_hooks_handle.go @@ -82,7 +82,7 @@ func hooks_handle_connection(conn net.Conn) { 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 094a862..8f2204e 100644 --- a/http_handle_repo_commit.go +++ b/http_handle_repo_commit.go @@ -103,7 +103,7 @@ var fake_diff_file_null = fake_diff_file{ 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 91acfea..9810d5d 100644 --- a/http_handle_repo_contrib_one.go +++ b/http_handle_repo_contrib_one.go @@ -55,11 +55,12 @@ func handle_repo_contrib_one(w http.ResponseWriter, r *http.Request, params map[ 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 849afd9..0acb9a7 100644 --- a/http_server.go +++ b/http_server.go @@ -22,8 +22,8 @@ func (router *http_router_t) ServeHTTP(w http.ResponseWriter, r *http.Request) { 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 a65e8b7..6c3cece 100644 --- a/resources.go +++ b/resources.go @@ -44,7 +44,8 @@ func load_templates() (err error) { 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))) @@ -15,7 +15,9 @@ func add_user_ssh(ctx context.Context, pubkey string) (user_id int, err error) { 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 |