mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-21 02:20:43 +08:00
This change improves the `rad clone` command in a few different ways. The first improvement is to check if the repository already exists before fetching. If it does exist, then there is no need for the fetch to be performed, and can move straight to the checkout. If the repository does not exist, then the fetch is performed, as per usual. However, it uses a replication factor of 1, so that the fetch finishes as soon as it has the repository in local storage. The change also improves the output when failures occur while attempting to perform the checkout phase. It will print the failure that occurred and provide a hint message in each case to help debug the failure, or push the caller in the direction of performing the correct action. This required some changes in `test/commands.rs` setup. Some tests were using the `rad-clone.md` to setup a clone, which would have different output if the repository did not need to be fetched. In those cases, the `rad` method for performing the clone is used instead.
2.7 KiB
2.7 KiB
Given a private repo rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu belonging to Alice,
Bob tries to fetch it, and even though he's connected to Alice, it fails.
$ rad ls
$ rad clone rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu --seed z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi --timeout 1
✓ Seeding policy updated for rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu with scope 'all'
Fetching rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu from the network, found 1 potential seed(s).
✗ Target not met: could not fetch from [z6MknSL…StBU8Vi], and required 1 more seed(s)
! Warning: Failed to fetch from 1 seed(s).
! Warning: z6MknSL…StBU8Vi: failed to perform fetch handshake
✗ Error: no seeds found for rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu
She allows Bob to view the repository. And when she syncs, one node (Bob) gets the refs.
$ rad id update --title "Allow Bob" --description "" --allow did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk -q
...
$ rad sync --announce --timeout 3
✓ Synced with 1 node(s)
Bob can now fetch the private repo without specifying a seed, because he knows that Alice has the repo after she announced her refs:
$ rad sync rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu --fetch
Fetching rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu from the network, found 1 potential seed(s).
✓ Target met: 1 seed(s)
🌱 Fetched from z6MknSL…StBU8Vi
$ rad ls --private --all
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Name RID Visibility Head Description │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ heartwood rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu private f2de534 radicle heartwood protocol & stack │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Note that since we don't have our own fork of this repo, omitting the --all flag shows nothing:
$ rad ls --private
Nothing to show.