From d8d00666d35bec88970508a3f3d9093cf6305dd7 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Fri, 20 Jun 2025 16:43:11 +0200 Subject: [PATCH] chore: remove radicle-tools The `radicle-tools` binaries were specialised binaries for early development of the `heartwood` set of crates. Choose to remove the crate so that it no longer needs to build as part of our workspace. --- Cargo.lock | 11 --- crates/radicle-tools/Cargo.toml | 44 ---------- crates/radicle-tools/src/rad-agent.rs | 60 ------------- crates/radicle-tools/src/rad-cli-demo.rs | 88 ------------------- crates/radicle-tools/src/rad-init.rs | 24 ----- crates/radicle-tools/src/rad-merge.rs | 65 -------------- crates/radicle-tools/src/rad-push.rs | 28 ------ crates/radicle-tools/src/rad-self.rs | 13 --- .../src/rad-set-canonical-refs.rs | 19 ---- 9 files changed, 352 deletions(-) delete mode 100644 crates/radicle-tools/Cargo.toml delete mode 100644 crates/radicle-tools/src/rad-agent.rs delete mode 100644 crates/radicle-tools/src/rad-cli-demo.rs delete mode 100644 crates/radicle-tools/src/rad-init.rs delete mode 100644 crates/radicle-tools/src/rad-merge.rs delete mode 100644 crates/radicle-tools/src/rad-push.rs delete mode 100644 crates/radicle-tools/src/rad-self.rs delete mode 100644 crates/radicle-tools/src/rad-set-canonical-refs.rs diff --git a/Cargo.lock b/Cargo.lock index 7ccabc77..67d9645f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2645,17 +2645,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "radicle-tools" -version = "0.9.0" -dependencies = [ - "anyhow", - "radicle", - "radicle-cli", - "radicle-git-ext", - "radicle-term", -] - [[package]] name = "rand" version = "0.8.5" diff --git a/crates/radicle-tools/Cargo.toml b/crates/radicle-tools/Cargo.toml deleted file mode 100644 index 49f0eff1..00000000 --- a/crates/radicle-tools/Cargo.toml +++ /dev/null @@ -1,44 +0,0 @@ -[package] -name = "radicle-tools" -license.workspace = true -version = "0.9.0" -authors = ["Alexis Sellier "] -edition.workspace = true -rust-version.workspace = true - -[[bin]] -name = "rad-init" -path = "src/rad-init.rs" - -[[bin]] -name = "rad-self" -path = "src/rad-self.rs" - -[[bin]] -name = "rad-merge" -path = "src/rad-merge.rs" - -[[bin]] -name = "rad-set-canonical-refs" -path = "src/rad-set-canonical-refs.rs" - -[[bin]] -name = "rad-push" -path = "src/rad-push.rs" - -[[bin]] -name = "rad-agent" -path = "src/rad-agent.rs" - -[[bin]] -name = "rad-cli-demo" -path = "src/rad-cli-demo.rs" - -[dependencies] -anyhow = { workspace = true } -radicle = { workspace = true } -radicle-cli = { workspace = true } -# N.b. this is required to use macros, even though it's re-exported -# through radicle -radicle-git-ext = { workspace = true, features = ["serde"] } -radicle-term = { workspace = true } \ No newline at end of file diff --git a/crates/radicle-tools/src/rad-agent.rs b/crates/radicle-tools/src/rad-agent.rs deleted file mode 100644 index 317098f6..00000000 --- a/crates/radicle-tools/src/rad-agent.rs +++ /dev/null @@ -1,60 +0,0 @@ -use anyhow::{anyhow, Context as _}; -use radicle::{crypto, crypto::ssh}; -use std::io::prelude::*; -use std::{env, io}; - -fn main() -> anyhow::Result<()> { - let profile = radicle::Profile::load()?; - let mut agent = ssh::agent::Agent::connect()?; - - println!("key: {}", ssh::fmt::key(profile.id())); - println!("hash: {}", ssh::fmt::fingerprint(profile.id())); - - match env::args().nth(1).as_deref() { - Some("add") => { - print!("passphrase: "); - io::stdout().flush()?; - - let mut passphrase = String::new(); - io::stdin().lock().read_line(&mut passphrase)?; - - let passphrase = passphrase.trim().to_owned().into(); - let secret = profile - .keystore - .secret_key(Some(passphrase))? - .ok_or_else(|| anyhow!("Key not found in {:?}", profile.keystore.path()))?; - - agent.register(&secret)?; - println!("ok"); - } - Some("remove") => { - agent.unregister(profile.id())?; - println!("ok"); - } - Some("remove-all") => { - agent.unregister_all()?; - println!("ok"); - } - Some("sign") => { - let mut stdin = Vec::new(); - io::stdin().read_to_end(&mut stdin)?; - - let sig = agent.sign(profile.id(), &stdin).context("Signing failed")?; - let sig = crypto::Signature::from(sig); - - println!("{}", &sig); - } - Some(other) => { - anyhow::bail!("Unknown command `{}`", other); - } - None => { - if agent.signer(profile.public_key).is_ready()? { - println!("ready: yes"); - } else { - println!("ready: no"); - } - } - } - - Ok(()) -} diff --git a/crates/radicle-tools/src/rad-cli-demo.rs b/crates/radicle-tools/src/rad-cli-demo.rs deleted file mode 100644 index 5630f526..00000000 --- a/crates/radicle-tools/src/rad-cli-demo.rs +++ /dev/null @@ -1,88 +0,0 @@ -use std::{thread, time}; - -use radicle_cli::terminal; - -fn main() -> anyhow::Result<()> { - let demo = terminal::io::select( - "Choose something to try out:", - &[ - "confirm", - "pager", - "spinner", - "spinner-drop", - "spinner-error", - "editor", - "prompt", - ], - "Choose wisely!", - )?; - - match *demo { - "confirm" => { - if terminal::confirm("Would you like to proceed?") { - terminal::success!("You said 'yes'"); - } - } - "pager" => { - let mut table = radicle_term::Table::<1, radicle_term::Label>::new( - radicle_term::TableOptions::bordered(), - ); - let rows = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/rad-cli-demo.rs")); - - for row in rows.lines() { - table.push([row.into()]); - } - radicle_term::pager::page(table)?; - } - "editor" => { - let output = terminal::editor::Editor::comment() - .extension("rs") - .initial("// Enter code here.")? - .edit(); - - match output { - Ok(Some(s)) => { - terminal::info!("You entered:"); - terminal::blob(s); - } - Ok(None) => { - terminal::info!("You didn't enter anything."); - } - Err(e) => { - return Err(e.into()); - } - } - } - "spinner" => { - let mut spinner = terminal::spinner("Spinning turbines.."); - thread::sleep(time::Duration::from_secs(1)); - spinner.message("Still spinning.."); - thread::sleep(time::Duration::from_secs(1)); - spinner.message("Almost done.."); - thread::sleep(time::Duration::from_secs(1)); - spinner.message("Done."); - - spinner.finish(); - } - "spinner-drop" => { - let _spinner = terminal::spinner("Spinning turbines.."); - thread::sleep(time::Duration::from_secs(3)); - } - "spinner-error" => { - let spinner = terminal::spinner("Spinning turbines.."); - thread::sleep(time::Duration::from_secs(3)); - spinner.error("broken turbine"); - } - "prompt" => { - let fruit = terminal::io::select( - "Enter your favorite fruit:", - &["apple", "pear", "banana", "strawberry"], - "Choose wisely!", - )?; - terminal::success!("You have chosen '{fruit}'"); - } - _ => {} - } - - Ok(()) -} diff --git a/crates/radicle-tools/src/rad-init.rs b/crates/radicle-tools/src/rad-init.rs deleted file mode 100644 index 3a846e55..00000000 --- a/crates/radicle-tools/src/rad-init.rs +++ /dev/null @@ -1,24 +0,0 @@ -use std::path::Path; - -use radicle::{git, identity::Visibility, Profile}; - -fn main() -> anyhow::Result<()> { - let cwd = Path::new(".").canonicalize()?; - let name = cwd.file_name().unwrap().to_string_lossy().to_string(); - let repo = radicle::git::raw::Repository::open(cwd)?; - let profile = Profile::load()?; - let signer = profile.signer()?; - let (id, _, _) = radicle::rad::init( - &repo, - name.try_into()?, - "", - git::refname!("master"), - Visibility::default(), - &signer, - &profile.storage, - )?; - - println!("ok: {id}"); - - Ok(()) -} diff --git a/crates/radicle-tools/src/rad-merge.rs b/crates/radicle-tools/src/rad-merge.rs deleted file mode 100644 index c909adee..00000000 --- a/crates/radicle-tools/src/rad-merge.rs +++ /dev/null @@ -1,65 +0,0 @@ -use std::collections::HashSet; -use std::env; - -use anyhow::{anyhow, bail}; -use radicle::cob::patch::{PatchId, RevisionId}; -use radicle::git::Oid; -use radicle::storage::ReadStorage; -use radicle_cli::terminal as term; - -fn main() -> anyhow::Result<()> { - let args = env::args().skip(1).collect::>(); - let (pid, rev) = match args.as_slice() { - [pid, rev] => { - let pid: PatchId = pid.parse()?; - let rev: Oid = rev.parse()?; - - (pid, Some(RevisionId::from(rev))) - } - [pid] => { - let pid: PatchId = pid.parse()?; - - (pid, None) - } - _ => bail!("usage: rad-merge []"), - }; - let profile = radicle::Profile::load()?; - let (working, rid) = radicle::rad::cwd()?; - let stored = profile.storage.repository(rid)?; - let mut patches = profile.patches_mut(&stored)?; - let mut patch = patches.get_mut(&pid)?; - - if patch.is_merged() { - anyhow::bail!("fatal: patch {pid} is already merged"); - } - let (revision, r) = if let Some(id) = rev { - let r = patch - .revision(&id) - .ok_or_else(|| anyhow!("revision {id} not found"))?; - (id, r) - } else { - patch.latest() - }; - let head = r.head(); - - let mut revwalk = stored.backend.revwalk()?; - revwalk.push_head()?; - - let commits = revwalk - .map(|r| r.map(Oid::from)) - .collect::, _>>()?; - - if !commits.contains(&head) { - anyhow::bail!("fatal: patch head {head} is not in default branch"); - } - let signer = term::signer(&profile)?; - - patch - .merge(revision, head, &signer)? - .cleanup(&working, &signer)?; - - println!("✓ Patch {pid} merged at commit {head}"); - println!("You may now run `rad sync --announce`."); - - Ok(()) -} diff --git a/crates/radicle-tools/src/rad-push.rs b/crates/radicle-tools/src/rad-push.rs deleted file mode 100644 index 8d686ae8..00000000 --- a/crates/radicle-tools/src/rad-push.rs +++ /dev/null @@ -1,28 +0,0 @@ -use std::path::Path; - -use radicle::{ - node::Handle, - storage::{ReadStorage, SignRepository, WriteRepository}, -}; - -fn main() -> anyhow::Result<()> { - let cwd = Path::new(".").canonicalize()?; - let repo = radicle::git::raw::Repository::open(&cwd)?; - let profile = radicle::Profile::load()?; - let (_, id) = radicle::rad::remote(&repo)?; - - let output = radicle::git::run::<_, _, &str, &str>(&cwd, ["push", "rad"], None)?; - println!("{output}"); - - let signer = profile.signer()?; - let project = profile.storage.repository(id)?; - let sigrefs = project.sign_refs(&signer)?; - let head = project.set_head()?; - - radicle::Node::new(profile.socket()).announce_refs(id)?; - - println!("head: {}", head.new); - println!("ok: {}", sigrefs.signature); - - Ok(()) -} diff --git a/crates/radicle-tools/src/rad-self.rs b/crates/radicle-tools/src/rad-self.rs deleted file mode 100644 index 9b7aae41..00000000 --- a/crates/radicle-tools/src/rad-self.rs +++ /dev/null @@ -1,13 +0,0 @@ -fn main() -> anyhow::Result<()> { - let profile = radicle::Profile::load()?; - - println!("id: {}", profile.id()); - println!("key: {}", radicle::crypto::ssh::fmt::key(profile.id())); - println!( - "fingerprint: {}", - radicle::crypto::ssh::fmt::fingerprint(profile.id()) - ); - println!("home: {}", profile.home().path().display()); - - Ok(()) -} diff --git a/crates/radicle-tools/src/rad-set-canonical-refs.rs b/crates/radicle-tools/src/rad-set-canonical-refs.rs deleted file mode 100644 index f1de5cff..00000000 --- a/crates/radicle-tools/src/rad-set-canonical-refs.rs +++ /dev/null @@ -1,19 +0,0 @@ -use radicle::{ - storage::{WriteRepository, WriteStorage}, - Profile, -}; - -fn main() -> anyhow::Result<()> { - let profile = Profile::load()?; - - let (_, rid) = radicle::rad::cwd()?; - let repo = profile.storage.repository_mut(rid)?; - - let id_oid = repo.set_identity_head()?; - let branch = repo.set_head()?; - - println!("ok: identity: {id_oid}"); - println!("ok: branch: {}", branch.new); - - Ok(()) -}