From fe1fdb9f9cecbfc992312bd69419c129c1d61ba5 Mon Sep 17 00:00:00 2001 From: billisdead Date: Tue, 23 Jun 2026 14:12:09 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20Gitea=20push=20404=20=E2=80=94=20add=20b?= =?UTF-8?q?ranch:main=20payload,=20handle=20409=20empty=20repo,=20clearer?= =?UTF-8?q?=20settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - lib/git.ts: add branch:"main" to Gitea POST payload (required when repo has no branch yet or is freshly initialized); treat 409 on GET same as 404 (empty repo has no tree, Gitea returns 409 Conflict — proceed to create first file) - lib/git.ts: improve 404 error hint with actionable checklist (URL format, owner/repo names, token scope, repo existence) - settings.tsx: add Gitea info card clarifying URL format (no /api/v1), token format (raw value only, no "Bearer" prefix), repo initialization requirement Co-Authored-By: Claude Sonnet 4.6 --- app/settings.tsx | 23 +++++++++++++++++++++-- lib/git.ts | 12 ++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/app/settings.tsx b/app/settings.tsx index 9977f1e..c8bc948 100644 --- a/app/settings.tsx +++ b/app/settings.tsx @@ -402,6 +402,25 @@ export default function SettingsScreen() { {gitProvider === "gitea" && ( <> + + + Instance URL + {" — base URL only, no trailing slash, no /api/v1.\n"} + Token + {" — Gitea PAT with write:repository scope. Paste the token value only (no \"Bearer\" prefix).\n"} + Repository + {" — must have at least one commit (initialize it with a README if empty)."} + + = { message: `incident: ${incident.title}`, content: base64Content, + branch: "main", }; if (sha) payload.sha = sha; @@ -94,7 +98,11 @@ async function pushGitea( if (!res.ok) { const body = await res.text(); - return { success: false, error: `HTTP ${res.status}: ${body.slice(0, 300)}` }; + let hint = ""; + if (res.status === 404) { + hint = "\n\nCheck: instance URL (no /api/v1), owner and repo names are exact, token has write:repository scope, and the repo exists on Gitea."; + } + return { success: false, error: `HTTP ${res.status}: ${body.slice(0, 300)}${hint}` }; } const data = await res.json() as { content?: { html_url?: string } }; return { success: true, url: data.content?.html_url };