🔧 fix: address clippy warnings after refactoring
- Change &PathBuf to &Path parameter in plan_credential_file_operation - Use inline format string in log message - Both formatting and linting now clean
This commit is contained in:
committed by
Jeremiah Russell
parent
aaa4ebcbde
commit
df9d2b6c8a
@@ -506,13 +506,13 @@ impl InitCli {
|
|||||||
&self,
|
&self,
|
||||||
operations: &mut Vec<Operation>,
|
operations: &mut Vec<Operation>,
|
||||||
config_path: &Path,
|
config_path: &Path,
|
||||||
cred_file: &PathBuf,
|
cred_file: &Path,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let dest_path = config_path.join(InitDefaults::credential_filename());
|
let dest_path = config_path.join(InitDefaults::credential_filename());
|
||||||
self.check_file_conflicts(&dest_path, "Credential file")?;
|
self.check_file_conflicts(&dest_path, "Credential file")?;
|
||||||
|
|
||||||
operations.push(Operation::CopyFile {
|
operations.push(Operation::CopyFile {
|
||||||
from: cred_file.clone(),
|
from: cred_file.to_path_buf(),
|
||||||
to: dest_path.clone(),
|
to: dest_path.clone(),
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
mode: Some(0o600),
|
mode: Some(0o600),
|
||||||
@@ -674,9 +674,7 @@ impl InitCli {
|
|||||||
Operation::RunOAuth2 {
|
Operation::RunOAuth2 {
|
||||||
config_root,
|
config_root,
|
||||||
credential_file,
|
credential_file,
|
||||||
} => {
|
} => self.execute_oauth_flow(config_root, credential_file).await,
|
||||||
self.execute_oauth_flow(config_root, credential_file).await
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -697,7 +695,8 @@ impl InitCli {
|
|||||||
backup_if_exists: bool,
|
backup_if_exists: bool,
|
||||||
operation: &Operation,
|
operation: &Operation,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
self.handle_existing_file(to, backup_if_exists, "file copy").await?;
|
self.handle_existing_file(to, backup_if_exists, "file copy")
|
||||||
|
.await?;
|
||||||
|
|
||||||
log::info!("Copying file: {} → {}", from.display(), to.display());
|
log::info!("Copying file: {} → {}", from.display(), to.display());
|
||||||
fs::copy(from, to).map_err(|e| Error::FileIo(format!("Failed to copy file: {e}")))?;
|
fs::copy(from, to).map_err(|e| Error::FileIo(format!("Failed to copy file: {e}")))?;
|
||||||
@@ -713,16 +712,22 @@ impl InitCli {
|
|||||||
backup_if_exists: bool,
|
backup_if_exists: bool,
|
||||||
operation: &Operation,
|
operation: &Operation,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
self.handle_existing_file(path, backup_if_exists, "file write").await?;
|
self.handle_existing_file(path, backup_if_exists, "file write")
|
||||||
|
.await?;
|
||||||
|
|
||||||
log::info!("Writing file: {}", path.display());
|
log::info!("Writing file: {}", path.display());
|
||||||
fs::write(path, contents).map_err(|e| Error::FileIo(format!("Failed to write file: {e}")))?;
|
fs::write(path, contents)
|
||||||
|
.map_err(|e| Error::FileIo(format!("Failed to write file: {e}")))?;
|
||||||
|
|
||||||
self.apply_permissions_if_needed(path, operation)
|
self.apply_permissions_if_needed(path, operation)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Execute token directory creation operation.
|
/// Execute token directory creation operation.
|
||||||
async fn execute_ensure_token_directory(&self, path: &Path, operation: &Operation) -> Result<()> {
|
async fn execute_ensure_token_directory(
|
||||||
|
&self,
|
||||||
|
path: &Path,
|
||||||
|
operation: &Operation,
|
||||||
|
) -> Result<()> {
|
||||||
log::info!("Ensuring token directory: {}", path.display());
|
log::info!("Ensuring token directory: {}", path.display());
|
||||||
fs::create_dir_all(path)
|
fs::create_dir_all(path)
|
||||||
.map_err(|e| Error::FileIo(format!("Failed to create token directory: {e}")))?;
|
.map_err(|e| Error::FileIo(format!("Failed to create token directory: {e}")))?;
|
||||||
@@ -774,7 +779,7 @@ impl InitCli {
|
|||||||
.map_err(|e| Error::FileIo(format!("Interactive prompt failed: {e}")))?;
|
.map_err(|e| Error::FileIo(format!("Interactive prompt failed: {e}")))?;
|
||||||
|
|
||||||
if !should_overwrite {
|
if !should_overwrite {
|
||||||
log::info!("Skipping {} due to user choice", operation_name);
|
log::info!("Skipping {operation_name} due to user choice");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
//! Integration tests for the init CLI command.
|
//! Integration tests for the init CLI command.
|
||||||
|
|
||||||
use assert_cmd::prelude::*;
|
use assert_cmd::prelude::*;
|
||||||
use assert_fs::prelude::*;
|
|
||||||
use assert_fs::fixture::ChildPath;
|
use assert_fs::fixture::ChildPath;
|
||||||
|
use assert_fs::prelude::*;
|
||||||
use predicates::prelude::*;
|
use predicates::prelude::*;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user