git clone https://garage44.eu/jeroen/midas.gitcartopolis-agent · 2026-11-28T19:18:31Z
fix(hubsetup): a hub with no Forgejo installs its own builds again Since garage44.eu's forge moved to the hub (12:46 today), hub.conf has forgejo_ssh and forgejo_api blank. The self-update installs a published build by running its hub setup with no flags, and setup took the blank Forgejo fields for a first run and refused: every midas deploy since 78f2a9c was published and never installed (journal of midas-self-update.service, 16:42 and 16:46). Setup now asks only for where the hub listens and what it serves; the Forgejo address and API are checked only when given.
src/hubsetup.rs | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/src/hubsetup.rs b/src/hubsetup.rs
index 0e8d3fc..be61e55 100644
--- a/src/hubsetup.rs
+++ b/src/hubsetup.rs
@@ -76,14 +76,19 @@ pub fn merge(stored: Option<HubConf>, a: Args) -> Result<HubConf> {
if let Some(v) = a.forgejo_api { c.forgejo_api = v; }
if !a.repos.is_empty() { c.repos = a.repos; }
if !a.agent_keys.is_empty() { c.agent_keys = a.agent_keys; }
- if c.listen.is_empty() || c.forgejo_ssh.is_empty() || c.forgejo_api.is_empty() || c.repos.is_empty() {
- bail!("the first time, say where the hub listens and what it mirrors:\n \
- sudo midas hub setup --listen ADDRESS:PORT --forgejo ssh://git@HOST:PORT \\\n \
- --forgejo-api https://HOST/api/v1 --repo OWNER/NAME --agent-key \"ssh-ed25519 …\"");
+ // Forgejo is optional: a hub that hosts its repositories itself has both
+ // blank (the self-update runs this with no flags, and refused every build
+ // after garage44.eu's forge moved to the hub).
+ if c.listen.is_empty() || c.repos.is_empty() {
+ bail!("the first time, say where the hub listens and what it serves:\n \
+ sudo midas hub setup --listen ADDRESS:PORT --repo OWNER/NAME --agent-key \"ssh-ed25519 …\"\n \
+ (and --forgejo ssh://git@HOST:PORT --forgejo-api https://HOST/api/v1 to mirror a Forgejo)");
}
c.listen.parse::<std::net::SocketAddrV4>().map_err(|_| anyhow!("--listen is ADDRESS:PORT, not {:?}", c.listen))?;
- if !c.forgejo_ssh.starts_with("ssh://") { bail!("--forgejo is ssh://user@host:port"); }
- if !c.forgejo_api.starts_with("https://") && !c.forgejo_api.starts_with("http://") { bail!("--forgejo-api is a URL"); }
+ if !c.forgejo_ssh.is_empty() && !c.forgejo_ssh.starts_with("ssh://") { bail!("--forgejo is ssh://user@host:port"); }
+ if !c.forgejo_api.is_empty() && !c.forgejo_api.starts_with("https://") && !c.forgejo_api.starts_with("http://") {
+ bail!("--forgejo-api is a URL");
+ }
for r in &c.repos {
crate::mirror::repo_name(r)?;
}
@@ -460,4 +465,14 @@ mod tests {
assert_eq!(c.agent_keys, vec![k.rsplit_once(' ').unwrap().0.to_string()]);
assert_eq!(c.repos, vec!["owner/project"], "a re-run keeps what it was not told");
}
+
+ #[test]
+ fn a_hub_that_hosts_its_repositories_needs_no_forgejo() {
+ let own = Args { forgejo_ssh: None, forgejo_api: None, ..first() };
+ let c = merge(None, own).unwrap();
+ assert!(c.forgejo_ssh.is_empty() && c.forgejo_api.is_empty());
+ // The self-update re-runs setup with no flags at all.
+ assert!(merge(Some(c), Args::default()).is_ok(), "the self-update installs a build on a hub without Forgejo");
+ assert!(merge(None, Args { forgejo_ssh: Some("git.example".into()), ..first() }).is_err(), "one given is still checked");
+ }
}