cli: Don't use 'signer' where not necessary

In the 'clone' command, a 'signer' is instanciated just to get the
public key.  In the 'job' command, a 'signer' is instanciated early,
even when the subcommand doesn't use it.

That's unnecessary, and infers the potential use of RAD_PASSPHRASE.
In those cases, avoid instanciating a 'signer'.
This commit is contained in:
Richard Levitte 2025-02-12 21:39:32 +01:00 committed by Fintan Halpenny
parent 538648c542
commit 9abedf449b
No known key found for this signature in database
GPG Key ID: C93C17467280C75B
2 changed files with 7 additions and 7 deletions

View File

@ -133,7 +133,6 @@ impl Args for Options {
pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
let profile = ctx.profile()?;
let signer = term::signer(&profile)?;
let mut node = radicle::Node::new(profile.socket());
if !node.is_running() {
@ -148,7 +147,6 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
options.scope,
options.sync.with_profile(&profile),
&mut node,
&signer,
&profile,
)?;
let delegates = doc
@ -229,16 +227,15 @@ pub enum CloneError {
Fetch(#[from] sync::FetchError),
}
pub fn clone<G: Signer>(
pub fn clone(
id: RepoId,
directory: Option<PathBuf>,
scope: Scope,
settings: SyncSettings,
node: &mut Node,
signer: &G,
profile: &Profile,
) -> Result<(raw::Repository, storage::git::Repository, Doc, Project), CloneError> {
let me = *signer.public_key();
let me = profile.id();
// Seed repository.
if node.seed(id, scope)? {
@ -283,7 +280,7 @@ pub fn clone<G: Signer>(
"Creating checkout in ./{}..",
term::format::tertiary(path.display())
));
let working = rad::checkout(id, &me, path, &profile.storage)?;
let working = rad::checkout(id, me, path, &profile.storage)?;
spinner.finish();

View File

@ -205,7 +205,6 @@ impl Args for Options {
pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
let profile = ctx.profile()?;
let signer = term::signer(&profile)?;
let (_, rid) = radicle::rad::cwd()?;
let repo = profile.storage.repository_mut(rid)?;
let announce = options.announce
@ -222,6 +221,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
match options.op {
Operation::Trigger { commit } => {
let signer = term::signer(&profile)?;
trigger(&commit, &mut ci_store, &repo, &signer, options.quiet)?;
}
Operation::Start {
@ -229,6 +229,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
run_id,
info_url,
} => {
let signer = term::signer(&profile)?;
start(&job_id, &run_id, info_url, &mut ci_store, &repo, &signer)?;
}
Operation::List => {
@ -238,9 +239,11 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
show(&job_id, &ci_store, &repo)?;
}
Operation::Finish { job_id, reason } => {
let signer = term::signer(&profile)?;
finish(&job_id, reason, &mut ci_store, &repo, &signer)?;
}
Operation::Delete { job_id } => {
let signer = term::signer(&profile)?;
let job_id = job_id.resolve(&repo.backend)?;
ci_store.remove(&job_id, &signer)?;
}