From f6d570fccd04109952dce771e1cabb20f6307cb1 Mon Sep 17 00:00:00 2001 From: alemi Date: Tue, 13 Feb 2024 21:40:45 +0100 Subject: [PATCH] fix: cannot call non const from const... --- Cargo.toml | 1 + src/main.rs | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bdd7578..0f148fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ repository = "https://git.alemi.dev/tci.git" [dependencies] git2 = "0.18.2" +lazy_static = "1.4.0" serde = { version = "1.0.196", features = ["derive"] } tempdir = "0.3.7" thiserror = "1.0.57" diff --git a/src/main.rs b/src/main.rs index dc04b63..39c75a6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,7 +29,9 @@ struct TciConfig { cleanup: Vec, } -const HOME : &str = &std::env::var("HOME").unwrap_or_default(); +lazy_static::lazy_static!{ + static ref HOME : String = std::env::var("HOME").unwrap_or_default(); +} fn main() { // load tci config @@ -99,7 +101,7 @@ fn tci(cfg: TciConfig) -> Result<(), Box> { fn tci_hook(repo_path: &PathBuf, tci_script: &str) -> Result<(), TciError> { // TODO kind of ew but ehh should do its job let mut name = repo_path.to_string_lossy() - .replace(HOME, ""); + .replace(HOME.as_str(), ""); if name.starts_with('/') { name.remove(0); } @@ -124,7 +126,7 @@ fn tci_hook(repo_path: &PathBuf, tci_script: &str) -> Result<(), TciError> { println!("[=] running tci script for repo '{name}'"); let res = shell(tmp.path().join(tci_script))?; - println!("[:] {}", res.replace("\n", "\n[:]")); + println!("[:] {}", res.replace('\n', "\n[:]")); std::env::set_current_dir(repo_path)?;