diff --git a/Cargo.lock b/Cargo.lock index 48b605e..a5190bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2755,10 +2755,11 @@ dependencies = [ [[package]] name = "kxio" -version = "3.1.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6fd1ff0b499ac9329ab39bdc334571c0c9488aec5cdc84b4463b7a65a9e276b" +checksum = "b711909378294af8b006b4df66e8b2de75fc0c2c98ff9ea7ef1422ae7c859a3d" dependencies = [ + "base64 0.22.1", "bytes", "derive_more", "http 1.1.0", @@ -2766,6 +2767,7 @@ dependencies = [ "reqwest", "tempfile", "tokio", + "tracing", "url", ] diff --git a/Cargo.toml b/Cargo.toml index 26f9ae5..2c9fedc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,7 +60,7 @@ async-trait = "0.1" git-url-parse = "0.4" # fs/network -kxio = "3.1" +kxio = "4.0" # TOML parsing serde = { version = "1.0", features = ["derive"] } diff --git a/Dockerfile b/Dockerfile index dfa8aa0..f5334d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # Leveraging the pre-built Docker images with # cargo-chef and the Rust toolchain -FROM git.kemitix.net/kemitix/git-next-builder:2024.08.04 AS chef +FROM git.kemitix.net/kemitix/git-next-builder:2024.12.28 AS chef WORKDIR /app FROM chef AS planner diff --git a/crates/cli/src/tui/logging.rs b/crates/cli/src/tui/logging.rs index 954a501..e985ef2 100644 --- a/crates/cli/src/tui/logging.rs +++ b/crates/cli/src/tui/logging.rs @@ -9,10 +9,18 @@ use tracing_subscriber::{self, layer::SubscriberExt, util::SubscriberInitExt, La lazy_static! { pub static ref PROJECT_NAME: String = env!("CARGO_CRATE_NAME").to_uppercase(); - pub static ref DATA_FOLDER: Option = - std::env::var(format!("{}_DATA", PROJECT_NAME.clone())) - .ok() - .map(PathBuf::from); + pub static ref DATA_FOLDER: PathBuf = std::env::var(format!("{}_DATA", PROJECT_NAME.clone())) + .ok() + .map(PathBuf::from) + .map_or_else( + || { + project_directory().map_or_else( + || PathBuf::from(".").join(".data"), + |proj_dirs| proj_dirs.data_local_dir().to_path_buf(), + ) + }, + |data_folder| data_folder, + ); pub static ref LOG_ENV: String = format!("{}_LOGLEVEL", PROJECT_NAME.clone()); pub static ref LOG_FILE: String = format!("{}.log", env!("CARGO_PKG_NAME")); } @@ -21,23 +29,9 @@ fn project_directory() -> Option { ProjectDirs::from("net", "kemitix", env!("CARGO_PKG_NAME")) } -pub fn get_data_dir() -> PathBuf { - let directory = DATA_FOLDER.clone().map_or_else( - || { - project_directory().map_or_else( - || PathBuf::from(".").join(".data"), - |proj_dirs| proj_dirs.data_local_dir().to_path_buf(), - ) - }, - |data_folder| data_folder, - ); - directory -} - pub fn initialize_logging() -> Result<()> { - let directory = get_data_dir(); - std::fs::create_dir_all(directory.clone())?; - let log_path = directory.join(LOG_FILE.clone()); + std::fs::create_dir_all(DATA_FOLDER.clone())?; + let log_path = DATA_FOLDER.join(LOG_FILE.clone()); let log_file = std::fs::File::create(log_path)?; std::env::set_var( "RUST_LOG", diff --git a/crates/core/src/git/repo_details.rs b/crates/core/src/git/repo_details.rs index fa6c4cd..f4d2200 100644 --- a/crates/core/src/git/repo_details.rs +++ b/crates/core/src/git/repo_details.rs @@ -145,7 +145,7 @@ impl RepoDetails { let file = fs.file(config_filename); let config_file = file.reader()?; let mut config_lines = config_file - .lines() + .lines()? .map(ToOwned::to_owned) .collect::>(); tracing::debug!(?config_lines, "original file"); diff --git a/crates/core/src/git/tests.rs b/crates/core/src/git/tests.rs index 7c6b237..2955eb8 100644 --- a/crates/core/src/git/tests.rs +++ b/crates/core/src/git/tests.rs @@ -326,22 +326,22 @@ pub mod given { ) } - #[allow(clippy::unwrap_used)] + #[allow(clippy::expect_used)] pub fn a_bare_repo_with_url(path: &Path, url: &str, fs: &kxio::fs::FileSystem) { // create a basic bare repo - let repo = gix::prepare_clone_bare(url, fs.base()).unwrap(); + let repo = gix::prepare_clone_bare(url, fs.base()).expect("prepare_clone_bare"); repo.persist(); // load config file let file = fs.file(&path.join("config")); - let config_file = file.reader().unwrap(); + let config_file = file.reader().expect("reader"); // add use are origin url - let mut config_lines = config_file.lines().collect::>(); + let mut config_lines = config_file.lines().expect("lines").collect::>(); config_lines.push(r#"[remote "origin"]"#); let url_line = format!(r#" url = "{url}""#); tracing::info!(?url, %url_line, "writing"); config_lines.push(&url_line); // write config file back out - file.write(config_lines.join("\n").as_str()).unwrap(); + file.write(config_lines.join("\n").as_str()).expect("write"); } #[allow(clippy::unwrap_used)]