diff --git a/radicle-cli/examples/rad-init-announce-refs.md b/radicle-cli/examples/rad-init-announce-refs.md new file mode 100644 index 00000000..da387c24 --- /dev/null +++ b/radicle-cli/examples/rad-init-announce-refs.md @@ -0,0 +1,24 @@ + +To create your first radicle project, navigate to a git repository, and run +the `init` command: + +``` +$ rad init --name heartwood --description "Radicle Heartwood Protocol & Stack" --no-confirm + +Initializing local 🌱 project in . + +ok Project heartwood created +{ + "name": "heartwood", + "description": "Radicle Heartwood Protocol & Stack", + "defaultBranch": "master" +} +ok Announcing refs.. + +Your project id is rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji. You can show it any time by running: + rad . + +To publish your project to the network, run: + rad push + +``` diff --git a/radicle-cli/examples/rad-init.md b/radicle-cli/examples/rad-init.md index 3cbfb7de..31343d1a 100644 --- a/radicle-cli/examples/rad-init.md +++ b/radicle-cli/examples/rad-init.md @@ -14,7 +14,6 @@ ok Project heartwood created "defaultBranch": "master" } - Your project id is rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji. You can show it any time by running: rad . diff --git a/radicle-cli/src/commands/init.rs b/radicle-cli/src/commands/init.rs index 929b9097..87206495 100644 --- a/radicle-cli/src/commands/init.rs +++ b/radicle-cli/src/commands/init.rs @@ -212,10 +212,7 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()> )); spinner.finish(); - if interactive.no() { - term::blob(json::to_string_pretty(&proj)?); - term::blank(); - } + term::blob(json::to_string_pretty(&proj)?); if options.set_upstream || git::branch_remote(&repo, proj.default_branch()).is_err() { // Setup eg. `master` -> `rad/master` diff --git a/radicle-cli/tests/commands.rs b/radicle-cli/tests/commands.rs index 34a65f14..73838fea 100644 --- a/radicle-cli/tests/commands.rs +++ b/radicle-cli/tests/commands.rs @@ -172,3 +172,40 @@ fn rad_clone() { test("examples/rad-clone.md", working, Some(&bob.home), []).unwrap(); } + +#[test] +fn rad_init_announce_refs() { + logger::init(log::Level::Debug); + + let mut environment = Environment::new(); + let alice = environment.node("alice"); + let bob = environment.node("bob"); + let working = environment.tmp().join("working"); + + let alice = alice.spawn(Config::default()); + let mut bob = bob.spawn(Config::default()); + + bob.connect(&alice); + + fixtures::repository(working.join("alice")); + + // Alice initializes a repo after her node has started, and after bob has connected to it. + test( + "examples/rad-init-announce-refs.md", + &working.join("alice"), + Some(&alice.home), + [], + ) + .unwrap(); + + // Wait for bob to get any updates to the routing table. + bob.converge([&alice]); + + test( + "examples/rad-clone.md", + working.join("bob"), + Some(&bob.home), + [], + ) + .unwrap(); +} diff --git a/radicle-cli/tests/framework/mod.rs b/radicle-cli/tests/framework/mod.rs index 7c6f6300..be2487aa 100644 --- a/radicle-cli/tests/framework/mod.rs +++ b/radicle-cli/tests/framework/mod.rs @@ -166,9 +166,6 @@ impl TestFormula { }; log::debug!(target: "test", "Running `{}` in `{}`..", cmd.display(), self.cwd.display()); - if !cmd.exists() { - log::error!(target: "test", "Command {} does not exist..", cmd.display()); - } if !self.cwd.exists() { log::error!(target: "test", "Directory {} does not exist..", self.cwd.display()); } @@ -187,6 +184,9 @@ impl TestFormula { assert.stdout_matches(&assertion.expected).success(); } Err(err) => { + if err.kind() == io::ErrorKind::NotFound { + log::error!(target: "test", "Command `{}` does not exist..", cmd.display()); + } return Err(io::Error::new( err.kind(), format!("{err}: `{}`", cmd.display()), diff --git a/radicle-node/src/service.rs b/radicle-node/src/service.rs index 3ca20a72..ef75bd05 100644 --- a/radicle-node/src/service.rs +++ b/radicle-node/src/service.rs @@ -1001,6 +1001,11 @@ where let peers = self.sessions.negotiated().map(|(_, p)| p); let timestamp = self.clock.as_secs(); + // Make sure our local routing table is up to date with new repositories. + if let Err(e) = self.routing.insert(id, self.node_id(), timestamp) { + log::error!(target: "service", "Failed to update routing table with repository {id}: {e}"); + } + if remote.refs.len() > Refs::max() { error!( target: "service",