fix: cannot call non const from const...

This commit is contained in:
əlemi 2024-02-13 21:40:45 +01:00
parent 83d4b3cbbc
commit f6d570fccd
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 6 additions and 3 deletions

View file

@ -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"

View file

@ -29,7 +29,9 @@ struct TciConfig {
cleanup: Vec<String>,
}
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<dyn std::error::Error>> {
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)?;