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:
parent
538648c542
commit
9abedf449b
|
|
@ -133,7 +133,6 @@ impl Args for Options {
|
||||||
|
|
||||||
pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
let profile = ctx.profile()?;
|
let profile = ctx.profile()?;
|
||||||
let signer = term::signer(&profile)?;
|
|
||||||
let mut node = radicle::Node::new(profile.socket());
|
let mut node = radicle::Node::new(profile.socket());
|
||||||
|
|
||||||
if !node.is_running() {
|
if !node.is_running() {
|
||||||
|
|
@ -148,7 +147,6 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
options.scope,
|
options.scope,
|
||||||
options.sync.with_profile(&profile),
|
options.sync.with_profile(&profile),
|
||||||
&mut node,
|
&mut node,
|
||||||
&signer,
|
|
||||||
&profile,
|
&profile,
|
||||||
)?;
|
)?;
|
||||||
let delegates = doc
|
let delegates = doc
|
||||||
|
|
@ -229,16 +227,15 @@ pub enum CloneError {
|
||||||
Fetch(#[from] sync::FetchError),
|
Fetch(#[from] sync::FetchError),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clone<G: Signer>(
|
pub fn clone(
|
||||||
id: RepoId,
|
id: RepoId,
|
||||||
directory: Option<PathBuf>,
|
directory: Option<PathBuf>,
|
||||||
scope: Scope,
|
scope: Scope,
|
||||||
settings: SyncSettings,
|
settings: SyncSettings,
|
||||||
node: &mut Node,
|
node: &mut Node,
|
||||||
signer: &G,
|
|
||||||
profile: &Profile,
|
profile: &Profile,
|
||||||
) -> Result<(raw::Repository, storage::git::Repository, Doc, Project), CloneError> {
|
) -> Result<(raw::Repository, storage::git::Repository, Doc, Project), CloneError> {
|
||||||
let me = *signer.public_key();
|
let me = profile.id();
|
||||||
|
|
||||||
// Seed repository.
|
// Seed repository.
|
||||||
if node.seed(id, scope)? {
|
if node.seed(id, scope)? {
|
||||||
|
|
@ -283,7 +280,7 @@ pub fn clone<G: Signer>(
|
||||||
"Creating checkout in ./{}..",
|
"Creating checkout in ./{}..",
|
||||||
term::format::tertiary(path.display())
|
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();
|
spinner.finish();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,6 @@ impl Args for Options {
|
||||||
|
|
||||||
pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
let profile = ctx.profile()?;
|
let profile = ctx.profile()?;
|
||||||
let signer = term::signer(&profile)?;
|
|
||||||
let (_, rid) = radicle::rad::cwd()?;
|
let (_, rid) = radicle::rad::cwd()?;
|
||||||
let repo = profile.storage.repository_mut(rid)?;
|
let repo = profile.storage.repository_mut(rid)?;
|
||||||
let announce = options.announce
|
let announce = options.announce
|
||||||
|
|
@ -222,6 +221,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
|
|
||||||
match options.op {
|
match options.op {
|
||||||
Operation::Trigger { commit } => {
|
Operation::Trigger { commit } => {
|
||||||
|
let signer = term::signer(&profile)?;
|
||||||
trigger(&commit, &mut ci_store, &repo, &signer, options.quiet)?;
|
trigger(&commit, &mut ci_store, &repo, &signer, options.quiet)?;
|
||||||
}
|
}
|
||||||
Operation::Start {
|
Operation::Start {
|
||||||
|
|
@ -229,6 +229,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
run_id,
|
run_id,
|
||||||
info_url,
|
info_url,
|
||||||
} => {
|
} => {
|
||||||
|
let signer = term::signer(&profile)?;
|
||||||
start(&job_id, &run_id, info_url, &mut ci_store, &repo, &signer)?;
|
start(&job_id, &run_id, info_url, &mut ci_store, &repo, &signer)?;
|
||||||
}
|
}
|
||||||
Operation::List => {
|
Operation::List => {
|
||||||
|
|
@ -238,9 +239,11 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
show(&job_id, &ci_store, &repo)?;
|
show(&job_id, &ci_store, &repo)?;
|
||||||
}
|
}
|
||||||
Operation::Finish { job_id, reason } => {
|
Operation::Finish { job_id, reason } => {
|
||||||
|
let signer = term::signer(&profile)?;
|
||||||
finish(&job_id, reason, &mut ci_store, &repo, &signer)?;
|
finish(&job_id, reason, &mut ci_store, &repo, &signer)?;
|
||||||
}
|
}
|
||||||
Operation::Delete { job_id } => {
|
Operation::Delete { job_id } => {
|
||||||
|
let signer = term::signer(&profile)?;
|
||||||
let job_id = job_id.resolve(&repo.backend)?;
|
let job_id = job_id.resolve(&repo.backend)?;
|
||||||
ci_store.remove(&job_id, &signer)?;
|
ci_store.remove(&job_id, &signer)?;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue