Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Cleanup patch, checkout and clone output
Alexis Sellier committed 3 years ago
commit 9db63a88019a26d088949c4c27a37725f0ad20f3
parent c8e548fb1d3e0dfffb66427235e62605873a4388
8 files changed +13 -36
modified radicle-cli/examples/rad-checkout.md
@@ -3,13 +3,7 @@ existing project.

```
$ rad checkout rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji
-

-
Initializing local checkout for 🌱 rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji (heartwood)
-

-
✓ Performing checkout...
-

-
🌱 Project checkout successful under ./heartwood
-

+
✓ Repository checkout successful under ./heartwood
```

Let's have a look at what the command did. Navigate to the working copy:
modified radicle-cli/examples/rad-clone.md
@@ -9,9 +9,7 @@ $ rad clone rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji
✓ Creating checkout in ./heartwood..
✓ Remote z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi created
✓ Remote-tracking branch z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi/master created for z6MknSL…StBU8Vi
-

-
🌱 Project successfully cloned under [..]/heartwood/
-

+
✓ Repository successfully cloned under [..]/heartwood/
```

We can now have a look at the new working copy that was created from the cloned
modified radicle-cli/examples/rad-patch.md
@@ -26,7 +26,6 @@ Once the code is ready, we open (or create) a patch with our changes for the pro

```
$ rad patch open --message "Define power requirements" --message "See details."
-

master <- z6MknSL…StBU8Vi/flux-capacitor-power (3e674d1)
1 commit(s) ahead, 0 commit(s) behind

@@ -36,7 +35,6 @@ master <- z6MknSL…StBU8Vi/flux-capacitor-power (3e674d1)

To publish your patch to the network, run:
    rad push
-

```

It will now be listed as one of the project's open patches.
modified radicle-cli/examples/workflow/2-cloning.md
@@ -9,9 +9,7 @@ $ rad clone rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji
✓ Creating checkout in ./heartwood..
✓ Remote z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi created
✓ Remote-tracking branch z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi/master created for z6MknSL…StBU8Vi
-

-
🌱 Project successfully cloned under [..]/heartwood/
-

+
✓ Repository successfully cloned under [..]/heartwood/
```

We can now have a look at the new working copy that was created from the cloned
modified radicle-cli/examples/workflow/4-patching-contributor.md
@@ -26,7 +26,6 @@ Once the code is ready, we open a patch with our changes.

```
$ rad patch open --message "Define power requirements" --message "See details."
-

master <- z6Mkt67…v4N1tRk/flux-capacitor-power (3e674d1)
1 commit(s) ahead, 0 commit(s) behind

@@ -36,7 +35,6 @@ master <- z6Mkt67…v4N1tRk/flux-capacitor-power (3e674d1)

To publish your patch to the network, run:
    rad push
-

```

It will now be listed as one of the project's open patches.
modified radicle-cli/src/commands/checkout.rs
@@ -70,17 +70,12 @@ impl Args for Options {

pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
    let profile = ctx.profile()?;
-
    let path = execute(options, &profile)?;
-

-
    term::headline(format!(
-
        "🌱 Project checkout successful under ./{}",
-
        term::format::highlight(path.file_name().unwrap_or_default().to_string_lossy())
-
    ));
+
    execute(options, &profile)?;

    Ok(())
}

-
pub fn execute(options: Options, profile: &Profile) -> anyhow::Result<PathBuf> {
+
fn execute(options: Options, profile: &Profile) -> anyhow::Result<PathBuf> {
    let id = options.id;
    let storage = &profile.storage;
    let remote = options.remote.unwrap_or(profile.did());
@@ -97,13 +92,7 @@ pub fn execute(options: Options, profile: &Profile) -> anyhow::Result<PathBuf> {
        anyhow::bail!("the local path {:?} already exists", path.as_path());
    }

-
    term::headline(format!(
-
        "Initializing local checkout for 🌱 {} ({})",
-
        term::format::highlight(options.id),
-
        payload.name(),
-
    ));
-

-
    let spinner = term::spinner("Performing checkout...");
+
    let mut spinner = term::spinner("Performing checkout...");
    let repo = match radicle::rad::checkout(options.id, &remote, path.clone(), &storage) {
        Ok(repo) => repo,
        Err(err) => {
@@ -113,6 +102,10 @@ pub fn execute(options: Options, profile: &Profile) -> anyhow::Result<PathBuf> {
            return Err(err.into());
        }
    };
+
    spinner.message(format!(
+
        "Repository checkout successful under ./{}",
+
        term::format::highlight(path.file_name().unwrap_or_default().to_string_lossy())
+
    ));
    spinner.finish();

    let remotes = doc
modified radicle-cli/src/commands/clone.rs
@@ -129,10 +129,10 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
        &delegates,
    )?;

-
    term::headline(format!(
-
        "🌱 Project successfully cloned under {}",
+
    term::success!(
+
        "Repository successfully cloned under {}",
        term::format::highlight(Path::new(".").join(path).display())
-
    ));
+
    );

    Ok(())
}
modified radicle-cli/src/commands/patch/create.rs
@@ -58,7 +58,6 @@ fn show_patch_commit_info(
    let base_oid = workdir.merge_base(*target_oid, *head_oid)?;
    let commits = patch_commits(workdir, &base_oid, &head_oid)?;

-
    term::blank();
    term::info!(
        "{} <- {}/{} ({})",
        term::format::highlight(target_ref),
@@ -134,7 +133,6 @@ pub fn run(
    } else {
        term::info!("To publish your patch to the network, run:");
        term::indented(term::format::secondary("rad push"));
-
        term::blank();
    }

    Ok(())