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:
landon
2026-09-09 18:13:21 -05:00
parent 91718f7487
commit c4391155cd
7 changed files with 561 additions and 16 deletions
+11
View File
@@ -209,6 +209,13 @@ pub struct App {
remote_input: String,
/// Whether the git-remote dialog is up.
show_git_remote: bool,
/// Name to give the repository the Gitea section would create.
gitea_repo_name: String,
/// Result channel for the in-flight Gitea call, if there is one. Its
/// presence is also what greys the button out, so only one can run.
gitea_rx: Option<std::sync::mpsc::Receiver<Result<crate::gitea::Repo, String>>>,
/// What the Gitea section is saying about the last (or running) attempt.
gitea_status: String,
status: String,
show_log: bool,
git_log: String,
@@ -379,6 +386,9 @@ impl App {
confirm_delete: false,
remote_input: String::new(),
show_git_remote: false,
gitea_repo_name: String::new(),
gitea_rx: None,
gitea_status: String::new(),
status: String::new(),
show_log: false,
git_log: String::new(),
@@ -545,6 +555,7 @@ impl eframe::App for App {
if self.show_git_remote {
self.git_remote_window(ctx);
}
self.poll_gitea_create();
if self.show_new_project {
self.new_project_window(ctx);