chore(deps): update rust crate kxio to v4
All checks were successful
Rust / build (map[name:nightly]) (push) Successful in 9m51s
Rust / build (map[name:stable]) (push) Successful in 8m12s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Release Please / Release-plz (push) Successful in 5m52s
ci/woodpecker/cron/cron-docker-builder Pipeline was successful
ci/woodpecker/cron/push-next Pipeline was successful
ci/woodpecker/cron/tag-created Pipeline was successful
All checks were successful
Rust / build (map[name:nightly]) (push) Successful in 9m51s
Rust / build (map[name:stable]) (push) Successful in 8m12s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Release Please / Release-plz (push) Successful in 5m52s
ci/woodpecker/cron/cron-docker-builder Pipeline was successful
ci/woodpecker/cron/push-next Pipeline was successful
ci/woodpecker/cron/tag-created Pipeline was successful
This commit is contained in:
parent
39dbc9b902
commit
b69243acf1
5 changed files with 25 additions and 29 deletions
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -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",
|
||||
]
|
||||
|
||||
|
|
|
@ -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"] }
|
||||
|
|
|
@ -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<PathBuf> =
|
||||
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> {
|
|||
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",
|
||||
|
|
|
@ -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::<Vec<_>>();
|
||||
tracing::debug!(?config_lines, "original file");
|
||||
|
|
|
@ -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::<Vec<_>>();
|
||||
let mut config_lines = config_file.lines().expect("lines").collect::<Vec<_>>();
|
||||
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)]
|
||||
|
|
Loading…
Reference in a new issue