cli: Get fetch after track working
When tracking a repository with the `--fetch` option, we run a fetch once the tracking is done. When tracking nodes, we don't accept the `--fetch` flag, as there may not be a repository to fetch.
This commit is contained in:
parent
8d1bf9e997
commit
7a08a1d459
|
|
@ -9,13 +9,13 @@ storage. In this scenario, we know that the project is
|
|||
have to track the project.
|
||||
|
||||
```
|
||||
$ rad track rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji
|
||||
$ rad track rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --no-fetch
|
||||
✓ Tracking policy updated for rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji with scope 'trusted'
|
||||
! Warning: fetch after track is not yet supported
|
||||
```
|
||||
|
||||
Now that the project is tracked we can fetch it and we will have it in
|
||||
our local storage.
|
||||
our local storage. Note that the `track` command can also be told to fetch
|
||||
by passing the `--fetch` option.
|
||||
|
||||
```
|
||||
$ rad sync --fetch rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ those commands we'll first track a peer so that we have something to
|
|||
see.
|
||||
|
||||
```
|
||||
$ rad track did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --alias Bob --no-fetch
|
||||
$ rad track did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --alias Bob
|
||||
✓ Tracking policy updated for z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk (Bob)
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ To configure our node's tracking policy, we can use the `rad track` command.
|
|||
For example, let's track a remote node we know about, and alias it to "eve":
|
||||
|
||||
```
|
||||
$ rad track did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --alias eve --no-fetch
|
||||
$ rad track did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --alias eve
|
||||
✓ Tracking policy updated for z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk (eve)
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ Changes have been proposed by another person (or peer) via a radicle patch. To
|
|||
```
|
||||
$ rad track did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --alias bob
|
||||
✓ Tracking policy updated for z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk (bob)
|
||||
! Warning: fetch after track is not yet supported
|
||||
$ rad sync --fetch
|
||||
✓ Fetching rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji from z6Mkt67…v4N1tRk..
|
||||
✓ Fetched repository from 1 seed(s)
|
||||
|
|
@ -15,7 +14,8 @@ Additionally, we need to add a new 'git remote' to our working copy for the
|
|||
peer. Upcoming versions of radicle will not require this step.
|
||||
|
||||
```
|
||||
$ git remote add bob rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
|
||||
$ rad remote add z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --name bob
|
||||
✓ Remote bob added with rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
|
||||
$ git fetch bob
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use radicle::node::tracking::{Alias, Scope};
|
|||
use radicle::node::{Handle, NodeId};
|
||||
use radicle::{prelude::*, Node};
|
||||
|
||||
use crate::commands::rad_sync as sync;
|
||||
use crate::terminal as term;
|
||||
use crate::terminal::args::{Args, Error, Help};
|
||||
|
||||
|
|
@ -16,7 +17,7 @@ pub const HELP: Help = Help {
|
|||
usage: r#"
|
||||
Usage
|
||||
|
||||
rad track <nid> [--[no-]fetch] [--alias <name>] [<option>...]
|
||||
rad track <nid> [--alias <name>] [<option>...]
|
||||
rad track <rid> [--[no-]fetch] [--scope <scope>] [<option>...]
|
||||
|
||||
The `track` command takes either an NID or an RID. Based on the argument, it will
|
||||
|
|
@ -30,7 +31,7 @@ Usage
|
|||
Options
|
||||
|
||||
--alias <name> Associate an alias to a tracked node
|
||||
--fetch Fetch refs after tracking
|
||||
--[no-]fetch Fetch refs after tracking
|
||||
--scope <scope> Node (remote) tracking scope for a repository
|
||||
--verbose, -v Verbose output
|
||||
--help Print help
|
||||
|
|
@ -94,7 +95,8 @@ impl Args for Options {
|
|||
.ok_or_else(|| anyhow!("scope specified is not UTF-8"))?
|
||||
.parse()?;
|
||||
}
|
||||
(Long("no-fetch"), _) => fetch = false,
|
||||
(Long("fetch"), Some(Operation::TrackRepo { .. })) => fetch = true,
|
||||
(Long("no-fetch"), Some(Operation::TrackRepo { .. })) => fetch = false,
|
||||
(Long("verbose") | Short('v'), _) => verbose = true,
|
||||
(Long("help"), _) => {
|
||||
return Err(Error::Help.into());
|
||||
|
|
@ -121,15 +123,17 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
|||
let mut node = radicle::Node::new(profile.socket());
|
||||
|
||||
match options.op {
|
||||
Operation::TrackNode { nid, alias } => track_node(nid, alias, &mut node),
|
||||
Operation::TrackRepo { rid, scope } => track_repo(rid, scope, &mut node),
|
||||
}?;
|
||||
Operation::TrackNode { nid, alias } => {
|
||||
track_node(nid, alias, &mut node)?;
|
||||
}
|
||||
Operation::TrackRepo { rid, scope } => {
|
||||
track_repo(rid, scope, &mut node)?;
|
||||
|
||||
if options.fetch {
|
||||
// TODO: Run a proper fetch here.
|
||||
term::warning("fetch after track is not yet supported");
|
||||
if options.fetch {
|
||||
sync::fetch(rid, profile, &mut node, None)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue