diff --git a/radicle-cli/examples/rad-clone-all.md b/radicle-cli/examples/rad-clone-all.md index 8c1e18b9..9862278d 100644 --- a/radicle-cli/examples/rad-clone-all.md +++ b/radicle-cli/examples/rad-clone-all.md @@ -60,6 +60,7 @@ We can then setup a git remote for `bob`: ``` $ rad remote add z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --name bob ✓ Remote bob added +✓ Remote-tracking branch bob/master created for z6Mkt67…v4N1tRk ``` And fetch his refs: diff --git a/radicle-cli/examples/rad-remote.md b/radicle-cli/examples/rad-remote.md index 7aafbc13..3f5a4bd1 100644 --- a/radicle-cli/examples/rad-remote.md +++ b/radicle-cli/examples/rad-remote.md @@ -3,6 +3,7 @@ Now, let's add a bob as a new remote: ``` $ rad remote add did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --name bob ✓ Remote bob added +✓ Remote-tracking branch bob/master created for z6Mkt67…v4N1tRk ``` Now, we can see that there is a new remote in the list of remotes: @@ -17,11 +18,29 @@ rad z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi (push) You can see both `bob` and `rad` as remotes. The `rad` remote is our personal remote of the project. +For the remote-tracking branch to work, we fetch bob: + +``` (stderr) +$ git fetch bob +From rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk + * [new branch] master -> bob/master +``` + +We can now see the remote-tracking branch that was setup: + +``` +$ git branch -r -v + bob/master f2de534 Second commit + rad/master f2de534 Second commit +``` + When we're finished with the `bob` remote, we can remove it: ``` $ rad remote rm bob ✓ Remote `bob` removed +$ git branch -r -v + rad/master f2de534 Second commit ``` Now, add another time `bob` but without specify the `name`, so we should be @@ -30,4 +49,5 @@ able to fetch the node alias from our db! ``` $ rad remote add did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk ✓ Remote bob added +✓ Remote-tracking branch bob/master created for z6Mkt67…v4N1tRk ``` diff --git a/radicle-cli/examples/workflow/5-patching-maintainer.md b/radicle-cli/examples/workflow/5-patching-maintainer.md index e9f88ddb..e0603238 100644 --- a/radicle-cli/examples/workflow/5-patching-maintainer.md +++ b/radicle-cli/examples/workflow/5-patching-maintainer.md @@ -16,6 +16,7 @@ peer. Upcoming versions of radicle will not require this step. ``` $ rad remote add z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --name bob ✓ Remote bob added +✓ Remote-tracking branch bob/master created for z6Mkt67…v4N1tRk ``` ``` (stderr) diff --git a/radicle-cli/src/commands/remote.rs b/radicle-cli/src/commands/remote.rs index b294e7c7..bc9f3d77 100644 --- a/radicle-cli/src/commands/remote.rs +++ b/radicle-cli/src/commands/remote.rs @@ -12,6 +12,7 @@ use anyhow::anyhow; use radicle::git::RefString; use radicle::prelude::NodeId; +use radicle::storage::ReadStorage; use crate::terminal::args; use crate::terminal::{Args, Context, Help}; @@ -119,8 +120,12 @@ pub fn run(options: Options, ctx: impl Context) -> anyhow::Result<()> { let profile = ctx.profile()?; match options.op { - // TODO: Support remote-tracking. - Operation::Add { ref id, name } => self::add::run(rid, id, name, None, &profile, &working)?, + Operation::Add { ref id, name } => { + let proj = profile.storage.repository(rid)?.project()?; + let branch = proj.default_branch(); + + self::add::run(rid, id, name, Some(branch.clone()), &profile, &working)? + } Operation::Rm { ref name } => self::rm::run(name, &working)?, Operation::List => self::list::run(&working)?, }; diff --git a/radicle-cli/tests/commands.rs b/radicle-cli/tests/commands.rs index a3cb2e94..adbd3051 100644 --- a/radicle-cli/tests/commands.rs +++ b/radicle-cli/tests/commands.rs @@ -832,6 +832,7 @@ fn rad_remote() { let bob = environment.node("bob"); let working = environment.tmp().join("working"); let home = alice.home.clone(); + let rid = Id::from_str("z42hL2jL4XNk6K8oHQaSWfMgCL7ji").unwrap(); // Setup a test repository. fixtures::repository(working.join("alice")); @@ -844,11 +845,19 @@ fn rad_remote() { .unwrap(); let mut alice = alice.spawn(Config::default()); + let mut bob = bob.spawn(Config::default()); alice .handle .track_node(bob.id, Some("bob".to_owned())) .unwrap(); + bob.connect(&alice); + bob.routes_to(&[(rid, alice.id)]); + bob.rad("clone", &[rid.to_string().as_str()], &working) + .unwrap(); + + alice.has_inventory_of(&rid, &bob.id); + test( "examples/rad-remote.md", working.join("alice"),