cli: Improve rad remote add

By default, this command now:
* Follows the peer if not already followed
* Syncs refs of the peer, if it wasn't followed before
* Fetches refs into working copy

This functionality can be disabled via `--no-sync` and `--no-fetch`.
This commit is contained in:
cloudhead
2024-01-08 17:28:01 +01:00
parent 3a3820b06d
commit e4f06e9c9d
15 changed files with 130 additions and 85 deletions
+4 -4
View File
@@ -7,8 +7,9 @@ use radicle::Node;
use crate::terminal as term;
pub fn sync(rid: Id, node: &mut Node) -> anyhow::Result<()> {
match sync_(rid, node) {
/// Announce changes to the network.
pub fn announce(rid: Id, node: &mut Node) -> anyhow::Result<()> {
match announce_(rid, node) {
Ok(()) => Ok(()),
Err(e) if e.is_connection_err() => {
term::hint("Node is stopped. To announce changes to the network, start it with `rad node start`.");
@@ -18,8 +19,7 @@ pub fn sync(rid: Id, node: &mut Node) -> anyhow::Result<()> {
}
}
/// Sync with the network.
fn sync_(rid: Id, node: &mut Node) -> Result<(), radicle::node::Error> {
fn announce_(rid: Id, node: &mut Node) -> Result<(), radicle::node::Error> {
let seeds = node.seeds(rid)?;
let connected = seeds.connected().map(|s| s.nid).collect::<Vec<_>>();