From 36808234a630ff2729977d1102fecd94f472537f Mon Sep 17 00:00:00 2001 From: cloudhead Date: Thu, 4 Apr 2024 14:13:34 +0200 Subject: [PATCH] cli: Don't allow announcing without a fork --- radicle-cli/src/commands/sync.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/radicle-cli/src/commands/sync.rs b/radicle-cli/src/commands/sync.rs index 9882d2c8..702b9580 100644 --- a/radicle-cli/src/commands/sync.rs +++ b/radicle-cli/src/commands/sync.rs @@ -11,7 +11,7 @@ use radicle::node::AliasStore; use radicle::node::Seed; use radicle::node::{FetchResult, FetchResults, Handle as _, Node, SyncStatus}; use radicle::prelude::{NodeId, Profile, RepoId}; -use radicle::storage::ReadStorage; +use radicle::storage::{ReadStorage, RemoteRepository}; use radicle_term::Element; use crate::node::SyncReporting; @@ -388,6 +388,16 @@ fn announce_refs( "nothing to announce, repository {rid} is not available locally" )); }; + if let Err(e) = repo.remote(&profile.public_key) { + if e.is_not_found() { + term::print(term::format::italic( + "Nothing to announce, you don't have a fork of this repository.", + )); + return Ok(()); + } else { + return Err(anyhow!("failed to load local fork of {rid}: {e}")); + } + } crate::node::announce( &repo,