Create the Gitea repository from the app, not a template hook
Repository creation was delegated entirely to a cookiecutter template's post-gen hook. That only ever covered projects made through New project, and when it went wrong it went wrong inside someone else's Python, where all this app could report was that a hook exited non-zero. The app now talks to Gitea itself. Settings > Git remote... gains a "Create and attach" button: it POSTs to /api/v1/user/repos with the configured server, user and token, then points origin at the clone URL that comes back. A name that is already taken is fetched and attached to rather than raised as an error, so retrying after a failure works. The call runs on a worker thread with the existing channel-and-poll pattern, so the UI does not block on the network. Errors are mapped by status code, because a rejected token, a URL that is not a Gitea API and a name the server refuses each need a different fix. Uses ureq's send_string rather than send_json, whose feature this build does not enable; no new dependency, and ldd still shows only libc/libgcc/libm. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GBWj9TphFMCoh7VHaSRnvQ
This commit is contained in:
+7
-5
@@ -506,7 +506,7 @@ impl App {
|
||||
}
|
||||
|
||||
ui.add_space(6.0);
|
||||
ui.label(egui::RichText::new("Gitea (used by the template's hook)").strong());
|
||||
ui.label(egui::RichText::new("Gitea").strong());
|
||||
egui::Grid::new("gitea_grid")
|
||||
.num_columns(2)
|
||||
.spacing([10.0, 8.0])
|
||||
@@ -539,10 +539,12 @@ impl App {
|
||||
});
|
||||
ui.label(
|
||||
egui::RichText::new(
|
||||
"Passed to the hook as GITEA_URL / GITEA_USER / GITEA_TOKEN. \
|
||||
Leave blank and the hook skips publishing — the project is \
|
||||
still created. The token is stored in this app's config file \
|
||||
in plain text.",
|
||||
"Used two ways: the app creates repositories with them from \
|
||||
Settings ▸ Git remote, and passes them to a template's hooks \
|
||||
as GITEA_URL / GITEA_USER / GITEA_TOKEN. Leave them blank and \
|
||||
both simply skip — the project is still created. The token \
|
||||
needs write access to repositories, and is stored in this \
|
||||
app's config file in plain text.",
|
||||
)
|
||||
.small()
|
||||
.weak(),
|
||||
|
||||
Reference in New Issue
Block a user