tweaks
e90a316 · gmorell · 2026-05-22 16:49
Files changed
modified
lib/git_gud_web/controllers/runner_controller.ex
+9
−2
@@ -187,7 +187,7 @@ defmodule GitGudWeb.RunnerController do
| 187 | 187 | "ref" => run.head_ref || "", |
| 188 | 188 | "sha" => if(run.head_sha, do: GitGud.Git.to_hex(run.head_sha), else: ""), |
| 189 | 189 | "repository" => repo.name, |
| 190 | − "run_number" => Integer.to_string(run.number), | |
| 190 | + "run_number" => maybe_int_to_string(run.number), | |
| 191 | 191 | "workflow" => run.workflow_name || run.workflow_path, |
| 192 | 192 | "job" => job.job_id, |
| 193 | 193 | # forgejo-runner reads `token` and uses it as GITHUB_TOKEN for |
@@ -203,15 +203,22 @@ defmodule GitGudWeb.RunnerController do
| 203 | 203 | |> wrap_as_struct() |
| 204 | 204 | end |
| 205 | 205 | |
| 206 | + defp maybe_int_to_string(n) when is_integer(n), do: Integer.to_string(n) | |
| 207 | + defp maybe_int_to_string(_), do: "" | |
| 208 | + | |
| 206 | 209 | defp wrap_as_struct(map) when is_map(map) do |
| 207 | 210 | %Google.Protobuf.Struct{ |
| 208 | 211 | fields: |
| 209 | 212 | Map.new(map, fn {k, v} -> |
| 210 | − {k, %Google.Protobuf.Value{kind: {:string_value, v}}} | |
| 213 | + {k, %Google.Protobuf.Value{kind: {:string_value, to_string_or_empty(v)}}} | |
| 211 | 214 | end) |
| 212 | 215 | } |
| 213 | 216 | end |
| 214 | 217 | |
| 218 | + defp to_string_or_empty(nil), do: "" | |
| 219 | + defp to_string_or_empty(v) when is_binary(v), do: v | |
| 220 | + defp to_string_or_empty(v), do: to_string(v) | |
| 221 | + | |
| 215 | 222 | # ── update_task ────────────────────────────────────────────────────── |
| 216 | 223 | |
| 217 | 224 | def update_task(conn, _params) do |
Parents: db274ab