diff --git a/docs/hooks.md b/docs/hooks.md index 1749143e0..07638c988 100644 --- a/docs/hooks.md +++ b/docs/hooks.md @@ -20,7 +20,7 @@ This hook is run when the project is entered. Changing directories while in the enter = "echo 'I entered the project'" ``` -## Leave hook (not yet implemented) +## Leave hook This hook is run when the project is left. Changing directories while in the project will not trigger this hook. @@ -80,7 +80,6 @@ implemented something similar. I think in most situations this is probably fine, though worth keeping in mind. -The leave hook (when it's implemented) will give you a way to manually reset the state. ::: ## Multiple hooks syntax diff --git a/e2e/config/test_hooks b/e2e/config/test_hooks index 9f25ed980..c66d85352 100644 --- a/e2e/config/test_hooks +++ b/e2e/config/test_hooks @@ -4,9 +4,9 @@ cat <mise.toml [tools] dummy = 'latest' [hooks] -enter = 'echo ENTER' -#leave = 'echo LEAVE' -cd = 'echo CD' +enter = 'echo HOOK-ENTER' +leave = 'echo HOOK-LEAVE' +cd = 'echo HOOK-CD' preinstall = 'echo PREINSTALL' postinstall = 'echo POSTINSTALL' EOF @@ -15,17 +15,21 @@ assert_contains "mise i 2>&1" "PREINSTALL" assert_contains "mise i dummy@1 2>&1" "POSTINSTALL" eval "$(mise hook-env)" -assert_not_contains "mise hook-env 2>&1" "CD" -assert_not_contains "mise hook-env 2>&1" "ENTER" +assert_not_contains "mise hook-env 2>&1" "HOOK-CD" +assert_not_contains "mise hook-env 2>&1" "HOOK-ENTER" +assert_not_contains "mise hook-env 2>&1" "HOOK-LEAVE" pushd .. || exit 1 -assert_not_contains "mise hook-env 2>&1" "CD" -assert_not_contains "mise hook-env 2>&1" "ENTER" +assert_not_contains "mise hook-env 2>&1" "HOOK-CD" +assert_not_contains "mise hook-env 2>&1" "HOOK-ENTER" +assert_contains "mise hook-env 2>&1" "HOOK-LEAVE" eval "$(mise hook-env)" popd || exit 1 -assert_contains "mise hook-env 2>&1" "CD" -assert_contains "mise hook-env 2>&1" "ENTER" +assert_contains "mise hook-env 2>&1" "HOOK-CD" +assert_contains "mise hook-env 2>&1" "HOOK-ENTER" +assert_not_contains "mise hook-env 2>&1" "HOOK-LEAVE" eval "$(mise hook-env)" mkdir foo cd foo || exit 1 -assert_contains "mise hook-env 2>&1" "CD" -assert_not_contains "mise hook-env 2>&1" "ENTER" +assert_contains "mise hook-env 2>&1" "HOOK-CD" +assert_not_contains "mise hook-env 2>&1" "HOOK-ENTER" +assert_not_contains "mise hook-env 2>&1" "HOOK-LEAVE" diff --git a/src/cli/hook_env.rs b/src/cli/hook_env.rs index 41b393773..592e61345 100644 --- a/src/cli/hook_env.rs +++ b/src/cli/hook_env.rs @@ -1,20 +1,20 @@ +use crate::config::{Config, Settings}; +use crate::direnv::DirenvDiff; use crate::env::{join_paths, split_paths, PATH_ENV_SEP}; +use crate::env::{PATH_KEY, TERM_WIDTH, __MISE_DIFF}; +use crate::env_diff::{EnvDiff, EnvDiffOperation}; +use crate::file::display_rel_path; +use crate::hook_env::{WatchFilePattern, CUR_SESSION}; +use crate::shell::{get_shell, ShellType}; +use crate::toolset::Toolset; +use crate::{env, hook_env, hooks, watch_files}; use console::truncate_str; use eyre::Result; +use indexmap::IndexSet; use itertools::Itertools; use std::ops::Deref; use std::path::PathBuf; -use crate::config::{Config, Settings}; -use crate::direnv::DirenvDiff; -use crate::env::{PATH_KEY, TERM_WIDTH, __MISE_DIFF}; -use crate::env_diff::{EnvDiff, EnvDiffOperation}; -use crate::hook_env::WatchFilePattern; -use crate::hooks::Hooks; -use crate::shell::{get_shell, Shell, ShellType}; -use crate::toolset::{Toolset, ToolsetBuilder}; -use crate::{dirs, env, hook_env, hooks, watch_files}; - /// [internal] called by activate hook to update env vars directory change #[derive(Debug, clap::Args)] #[clap(hide = true)] @@ -42,7 +42,7 @@ impl HookEnv { return Ok(()); } time!("should_exit_early false"); - let ts = ToolsetBuilder::new().build(&config)?; + let ts = config.get_toolset()?; let shell = get_shell(self.shell).expect("no shell provided, use `--shell=zsh`"); miseprint!("{}", hook_env::clear_old_env(&*shell))?; let mut env = ts.env(&config)?; @@ -60,61 +60,36 @@ impl HookEnv { let settings = Settings::try_get()?; patches.extend(self.build_path_operations(&settings, &paths, &__MISE_DIFF.path)?); patches.push(self.build_diff_operation(&diff)?); - patches.push(self.build_watch_operation(watch_files.clone())?); - patches.push(self.build_dir_operation()?); + patches.push(self.build_session_operation(watch_files.clone())?); let output = hook_env::build_env_commands(&*shell, &patches); miseprint!("{output}")?; - self.display_status(&config, &ts)?; + self.display_status(&config, ts)?; - self.run_shell_hooks(&config, &*shell)?; - hooks::run_all_hooks(&ts); - watch_files::execute_runs(&ts); + hooks::run_all_hooks(ts, &*shell); + watch_files::execute_runs(ts); Ok(()) } - fn run_shell_hooks(&self, config: &Config, shell: &dyn Shell) -> Result<()> { - let hooks = config.hooks()?; - for h in hooks::SCHEDULED_HOOKS.lock().unwrap().iter() { - let hooks = hooks - .iter() - .map(|(_p, hook)| hook) - .filter(|hook| hook.hook == *h && hook.shell == Some(shell.to_string())) - .collect_vec(); - match *h { - Hooks::Enter => { - for hook in hooks { - miseprintln!("{}", hook.script); - } - } - Hooks::Cd => { - for hook in hooks { - miseprintln!("{}", hook.script); - } - } - Hooks::Leave => { - for _hook in hooks { - warn!("leave hook not yet implemented"); - } - } - _ => {} - } - } - Ok(()) - } - fn display_status(&self, config: &Config, ts: &Toolset) -> Result<()> { let settings = Settings::get(); if self.status || settings.status.show_tools { - let installed_versions = ts + let prev = &CUR_SESSION.loaded_tools; + let cur = ts .list_current_installed_versions() .into_iter() .rev() .map(|(_, tv)| format!("{}@{}", tv.short(), tv.version)) - .collect_vec(); - if !installed_versions.is_empty() { - let status = installed_versions.into_iter().rev().join(" "); + .collect::>(); + let removed = prev.difference(&cur).collect::>(); + let new = cur.difference(prev).collect::>(); + if !new.is_empty() { + let status = new.into_iter().map(|t| format!("+{t}")).rev().join(" "); + info!("{}", truncate_str(&status, TERM_WIDTH.max(60) - 5, "…")); + } + if !removed.is_empty() { + let status = removed.into_iter().map(|t| format!("-{t}")).rev().join(" "); info!("{}", truncate_str(&status, TERM_WIDTH.max(60) - 5, "…")); } } @@ -124,6 +99,27 @@ impl HookEnv { let env_diff = env_diff.into_iter().map(patch_to_status).join(" "); info!("{}", truncate_str(&env_diff, TERM_WIDTH.max(60) - 5, "…")); } + let new_paths: IndexSet = config + .path_dirs() + .map(|p| p.iter().cloned().collect()) + .unwrap_or_default(); + let old_paths = &CUR_SESSION.config_paths; + let removed_paths = old_paths.difference(&new_paths).collect::>(); + let added_paths = new_paths.difference(old_paths).collect::>(); + if !added_paths.is_empty() { + let status = added_paths + .iter() + .map(|p| format!("+{}", display_rel_path(p))) + .join(" "); + info!("{}", truncate_str(&status, TERM_WIDTH.max(60) - 5, "…")); + } + if !removed_paths.is_empty() { + let status = removed_paths + .iter() + .map(|p| format!("-{}", display_rel_path(p))) + .join(" "); + info!("{}", truncate_str(&status, TERM_WIDTH.max(60) - 5, "…")); + } } ts.notify_if_versions_missing(); Ok(()) @@ -199,29 +195,14 @@ impl HookEnv { )) } - /// set the directory where hook-env was last run from - /// prefixed with ":" so it does not conflict with zsh's auto_name_dirs feature - fn build_dir_operation(&self) -> Result { - Ok(EnvDiffOperation::Add( - "__MISE_DIR".into(), - format!( - ":{}", - dirs::CWD - .as_ref() - .map(|p| p.to_string_lossy().to_string()) - .unwrap_or_default() - ), - )) - } - - fn build_watch_operation( + fn build_session_operation( &self, watch_files: impl IntoIterator, ) -> Result { - let watches = hook_env::build_watches(watch_files)?; + let session = hook_env::build_session(watch_files)?; Ok(EnvDiffOperation::Add( - "__MISE_WATCH".into(), - hook_env::serialize_watches(&watches)?, + "__MISE_SESSION".into(), + hook_env::serialize(&session)?, )) } } diff --git a/src/config/mod.rs b/src/config/mod.rs index db4cc9021..993f477a4 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -58,6 +58,7 @@ pub struct Config { env_with_sources: OnceCell, redactions: OnceCell>, shorthands: OnceLock, + hooks: OnceCell>, tasks: OnceCell>, tool_request_set: OnceCell, toolset: OnceCell, @@ -572,19 +573,21 @@ impl Config { Ok(env_results) } - pub fn hooks(&self) -> Result> { - self.config_files - .values() - .map(|cf| Ok((cf.project_root(), cf.hooks()?))) - .filter_map_ok(|(root, hooks)| root.map(|r| (r.to_path_buf(), hooks))) - .map_ok(|(root, hooks)| { - hooks - .into_iter() - .map(|h| (root.clone(), h)) - .collect::>() - }) - .flatten_ok() - .collect() + pub fn hooks(&self) -> Result<&Vec<(PathBuf, Hook)>> { + self.hooks.get_or_try_init(|| { + self.config_files + .values() + .map(|cf| Ok((cf.project_root(), cf.hooks()?))) + .filter_map_ok(|(root, hooks)| root.map(|r| (r.to_path_buf(), hooks))) + .map_ok(|(root, hooks)| { + hooks + .into_iter() + .map(|h| (root.clone(), h)) + .collect::>() + }) + .flatten_ok() + .collect() + }) } pub fn watch_file_hooks(&self) -> Result> { diff --git a/src/env.rs b/src/env.rs index b7a934ced..c11f6fff9 100644 --- a/src/env.rs +++ b/src/env.rs @@ -1,7 +1,6 @@ use crate::cli::args::{ENV_ARG, PROFILE_ARG}; use crate::env_diff::{EnvDiff, EnvDiffOperation, EnvDiffPatches}; use crate::file::replace_path; -use crate::hook_env::{deserialize_watches, HookEnvWatches}; use indexmap::IndexSet; use itertools::Itertools; use log::LevelFilter; @@ -154,21 +153,7 @@ pub static MISE_TIMINGS: Lazy = Lazy::new(|| var_u8("MISE_TIMINGS")); pub static MISE_PID: Lazy = Lazy::new(|| process::id().to_string()); pub static __MISE_SCRIPT: Lazy = Lazy::new(|| var_is_true("__MISE_SCRIPT")); pub static __MISE_DIFF: Lazy = Lazy::new(get_env_diff); -/// the directory where hook-env was last run from -/// prefixed with ":" so it does not conflict with zsh's auto_name_dirs feature -pub static __MISE_DIR: Lazy> = Lazy::new(|| { - var("__MISE_DIR") - .map(|d| PathBuf::from(d.strip_prefix(":").unwrap_or(&d))) - .ok() -}); pub static __MISE_ORIG_PATH: Lazy> = Lazy::new(|| var("__MISE_ORIG_PATH").ok()); -pub static __MISE_WATCH: Lazy> = Lazy::new(|| match var("__MISE_WATCH") { - Ok(raw) => deserialize_watches(raw) - // TODO: enable this later when the bigint change goes out - .map_err(|e| debug!("Failed to deserialize __MISE_WATCH {e}")) - .ok(), - _ => None, -}); pub static LINUX_DISTRO: Lazy> = Lazy::new(linux_distro); pub static PREFER_STALE: Lazy = Lazy::new(|| prefer_stale(&ARGS.read().unwrap())); /// essentially, this is whether we show spinners or build output on runtime install diff --git a/src/file.rs b/src/file.rs index cf0b0468b..eaf343f2b 100644 --- a/src/file.rs +++ b/src/file.rs @@ -214,6 +214,14 @@ pub fn display_path>(path: P) -> String { } } +pub fn display_rel_path>(path: P) -> String { + let path = path.as_ref(); + match path.strip_prefix(dirs::CWD.as_ref().unwrap()) { + Ok(rel) => format!("./{}", rel.display()), + Err(_) => display_path(path), + } +} + /// replaces $HOME in a string with "~" and $PATH with "$PATH", generally used to clean up output /// after it is rendered pub fn replace_paths_in_string(input: S) -> String { diff --git a/src/hook_env.rs b/src/hook_env.rs index 64039c0ab..5589236f3 100644 --- a/src/hook_env.rs +++ b/src/hook_env.rs @@ -8,15 +8,32 @@ use base64::prelude::*; use eyre::Result; use flate2::write::{ZlibDecoder, ZlibEncoder}; use flate2::Compression; +use indexmap::IndexSet; use itertools::Itertools; +use once_cell::sync::Lazy; use serde_derive::{Deserialize, Serialize}; +use crate::config::Config; use crate::env::PATH_KEY; use crate::env_diff::{EnvDiffOperation, EnvDiffPatches}; use crate::hash::hash_to_str; use crate::shell::Shell; use crate::{dirs, env, hooks, watch_files}; +pub static CUR_SESSION: Lazy = Lazy::new(|| { + env::var("__MISE_SESSION") + .ok() + .and_then(|s| { + deserialize(s) + .map_err(|err| { + warn!("error deserializing __MISE_SESSION: {err}"); + err + }) + .ok() + }) + .unwrap_or_default() +}); + #[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] pub struct WatchFilePattern { pub root: Option, @@ -52,25 +69,18 @@ pub fn should_exit_early(watch_files: impl IntoIterator return false; } }; - match &*env::__MISE_WATCH { - Some(watches) => { - if have_files_been_modified(watches, watch_files) { - return false; - } - if have_mise_env_vars_been_modified(watches) { - return false; - } - } - None => { - return false; - } - }; + if have_files_been_modified(watch_files) { + return false; + } + if have_mise_env_vars_been_modified() { + return false; + } trace!("early-exit"); true } pub fn dir_change() -> Option<(Option, PathBuf)> { - match (&*env::__MISE_DIR, &*dirs::CWD) { + match (&CUR_SESSION.dir, &*dirs::CWD) { (Some(old), Some(new)) if old != new => { trace!("dir change: {:?} -> {:?}", old, new); Some((Some(old.clone()), new.clone())) @@ -83,7 +93,7 @@ pub fn dir_change() -> Option<(Option, PathBuf)> { } } -fn have_files_been_modified(watches: &HookEnvWatches, watch_files: BTreeSet) -> bool { +fn have_files_been_modified(watch_files: BTreeSet) -> bool { // check the files to see if they've been altered let mut modified = false; for fp in &watch_files { @@ -92,7 +102,7 @@ fn have_files_been_modified(watches: &HookEnvWatches, watch_files: BTreeSet watches.latest_update { + if modtime > CUR_SESSION.latest_update { trace!("file modified: {:?}", fp); modified = true; watch_files::add_modified_file(fp.clone()); @@ -105,26 +115,30 @@ fn have_files_been_modified(watches: &HookEnvWatches, watch_files: BTreeSet bool { - if get_mise_env_vars_hashed() != watches.env_var_hash { +fn have_mise_env_vars_been_modified() -> bool { + if get_mise_env_vars_hashed() != CUR_SESSION.env_var_hash { return true; } false } #[derive(Debug, Default, Serialize, Deserialize)] -pub struct HookEnvWatches { - latest_update: u128, +pub struct HookEnvSession { + pub loaded_tools: IndexSet, + pub loaded_configs: IndexSet, + pub config_paths: IndexSet, + dir: Option, env_var_hash: String, + latest_update: u128, } -pub fn serialize_watches(watches: &HookEnvWatches) -> Result { +pub fn serialize(obj: &T) -> Result { let mut gz = ZlibEncoder::new(Vec::new(), Compression::fast()); - gz.write_all(&rmp_serde::to_vec_named(watches)?)?; + gz.write_all(&rmp_serde::to_vec_named(obj)?)?; Ok(BASE64_STANDARD_NO_PAD.encode(gz.finish()?)) } -pub fn deserialize_watches(raw: String) -> Result { +pub fn deserialize(raw: String) -> Result { let mut writer = Vec::new(); let mut decoder = ZlibDecoder::new(writer); let bytes = BASE64_STANDARD_NO_PAD.decode(raw)?; @@ -133,9 +147,10 @@ pub fn deserialize_watches(raw: String) -> Result { Ok(rmp_serde::from_slice(&writer[..])?) } -pub fn build_watches( +pub fn build_session( watch_files: impl IntoIterator, -) -> Result { +) -> Result { + let config = Config::get(); let mut max_modtime = UNIX_EPOCH; for cf in get_watch_files(watch_files)? { if let Ok(Ok(modified)) = cf.metadata().map(|m| m.modified()) { @@ -143,8 +158,23 @@ pub fn build_watches( } } - Ok(HookEnvWatches { + let config_paths = if let Ok(paths) = config.path_dirs() { + paths.iter().cloned().collect() + } else { + IndexSet::new() + }; + + Ok(HookEnvSession { + dir: dirs::CWD.clone(), env_var_hash: get_mise_env_vars_hashed(), + loaded_configs: config.config_files.keys().cloned().collect(), + loaded_tools: config + .get_toolset()? + .list_current_versions() + .into_iter() + .map(|(_, tv)| tv.to_string()) + .collect(), + config_paths, latest_update: max_modtime .duration_since(SystemTime::UNIX_EPOCH) .unwrap() diff --git a/src/hooks.rs b/src/hooks.rs index 2a2330c05..e99c7481d 100644 --- a/src/hooks.rs +++ b/src/hooks.rs @@ -1,5 +1,6 @@ use crate::cmd::cmd; -use crate::config::{Config, SETTINGS}; +use crate::config::{config_file, Config, SETTINGS}; +use crate::shell::Shell; use crate::toolset::Toolset; use crate::{dirs, hook_env}; use eyre::{eyre, Result}; @@ -7,7 +8,7 @@ use indexmap::IndexSet; use itertools::Itertools; use once_cell::sync::Lazy; use std::iter::once; -use std::path::Path; +use std::path::{Path, PathBuf}; use std::sync::Mutex; #[derive( @@ -46,42 +47,65 @@ pub fn schedule_hook(hook: Hooks) { mu.insert(hook); } -pub fn run_all_hooks(ts: &Toolset) { +pub fn run_all_hooks(ts: &Toolset, shell: &dyn Shell) { let mut mu = SCHEDULED_HOOKS.lock().unwrap(); for hook in mu.drain(..) { - run_one_hook(ts, hook); + run_one_hook(ts, hook, Some(shell)); } } -pub fn run_one_hook(ts: &Toolset, hook: Hooks) { +static ALL_HOOKS: Lazy> = Lazy::new(|| { let config = Config::get(); - let hooks = config.hooks().unwrap_or_default(); - for (root, h) in hooks { - if hook != h.hook || h.shell.is_some() { + let mut hooks = config.hooks().cloned().unwrap_or_default(); + let cur_configs = config.config_files.keys().cloned().collect::>(); + let prev_configs = &hook_env::CUR_SESSION.loaded_configs; + let old_configs = prev_configs.difference(&cur_configs); + for p in old_configs { + if let Ok(cf) = config_file::parse(p) { + if let Ok(h) = cf.hooks() { + hooks.extend(h.into_iter().map(|h| (cf.config_root(), h))); + } + } + } + hooks +}); + +pub fn run_one_hook(ts: &Toolset, hook: Hooks, shell: Option<&dyn Shell>) { + for (root, h) in &*ALL_HOOKS { + if hook != h.hook || (h.shell.is_some() && h.shell != shell.map(|s| s.to_string())) { continue; } trace!("running hook {hook} in {root:?}"); match (hook, hook_env::dir_change()) { (Hooks::Enter, Some((old, new))) => { - if !new.starts_with(&root) { + if !root.starts_with(&new) { continue; } - if old.is_some_and(|old| old.starts_with(&root)) { + if !new.starts_with(root) { + continue; + } + if old.as_ref().is_some_and(|old| old.starts_with(root)) { continue; } } (Hooks::Leave, Some((old, new))) => { - warn!("leave hook not yet implemented"); - if new.starts_with(&root) { + if new.starts_with(root) { + continue; + } + if old.as_ref().is_some_and(|old| !old.starts_with(root)) { continue; } - if old.is_some_and(|old| !old.starts_with(&root)) { + } + (Hooks::Cd, Some((_old, new))) => { + if !new.starts_with(root) { continue; } } _ => {} } - if let Err(e) = execute(ts, &root, &h) { + if h.shell.is_some() { + println!("{}", h.script); + } else if let Err(e) = execute(ts, root, h) { warn!("error executing hook: {e}"); } } diff --git a/src/shell/bash.rs b/src/shell/bash.rs index 3fb93b68a..8d25c1774 100644 --- a/src/shell/bash.rs +++ b/src/shell/bash.rs @@ -94,7 +94,7 @@ impl Shell for Bash { unset mise unset MISE_SHELL unset __MISE_DIFF - unset __MISE_WATCH + unset __MISE_SESSION "#} } diff --git a/src/shell/elvish.rs b/src/shell/elvish.rs index 9d0f400c4..9765bcdd0 100644 --- a/src/shell/elvish.rs +++ b/src/shell/elvish.rs @@ -63,7 +63,7 @@ impl Shell for Elvish { formatdoc! {r#" unset-env MISE_SHELL unset-env __MISE_DIFF - unset-env __MISE_WATCH + unset-env __MISE_SESSION "#} } diff --git a/src/shell/fish.rs b/src/shell/fish.rs index 0a36dc906..181dbf27b 100644 --- a/src/shell/fish.rs +++ b/src/shell/fish.rs @@ -112,7 +112,7 @@ impl Shell for Fish { functions --erase mise set -e MISE_SHELL set -e __MISE_DIFF - set -e __MISE_WATCH + set -e __MISE_SESSION "#} } diff --git a/src/shell/snapshots/mise__shell__bash__tests__deactivate.snap b/src/shell/snapshots/mise__shell__bash__tests__deactivate.snap index 550cb2578..599a73768 100644 --- a/src/shell/snapshots/mise__shell__bash__tests__deactivate.snap +++ b/src/shell/snapshots/mise__shell__bash__tests__deactivate.snap @@ -9,4 +9,4 @@ unset _mise_hook unset mise unset MISE_SHELL unset __MISE_DIFF -unset __MISE_WATCH +unset __MISE_SESSION diff --git a/src/shell/snapshots/mise__shell__elvish__tests__deactivate.snap b/src/shell/snapshots/mise__shell__elvish__tests__deactivate.snap index 634eb8758..0b4a2f85e 100644 --- a/src/shell/snapshots/mise__shell__elvish__tests__deactivate.snap +++ b/src/shell/snapshots/mise__shell__elvish__tests__deactivate.snap @@ -5,4 +5,4 @@ snapshot_kind: text --- unset-env MISE_SHELL unset-env __MISE_DIFF -unset-env __MISE_WATCH +unset-env __MISE_SESSION diff --git a/src/shell/snapshots/mise__shell__fish__tests__deactivate.snap b/src/shell/snapshots/mise__shell__fish__tests__deactivate.snap index 950a09010..3575a40e4 100644 --- a/src/shell/snapshots/mise__shell__fish__tests__deactivate.snap +++ b/src/shell/snapshots/mise__shell__fish__tests__deactivate.snap @@ -9,4 +9,4 @@ functions --erase __mise_cd_hook functions --erase mise set -e MISE_SHELL set -e __MISE_DIFF -set -e __MISE_WATCH +set -e __MISE_SESSION diff --git a/src/shell/snapshots/mise__shell__xonsh__tests__xonsh_deactivate.snap b/src/shell/snapshots/mise__shell__xonsh__tests__xonsh_deactivate.snap index ed54e07ac..d5506348a 100644 --- a/src/shell/snapshots/mise__shell__xonsh__tests__xonsh_deactivate.snap +++ b/src/shell/snapshots/mise__shell__xonsh__tests__xonsh_deactivate.snap @@ -23,5 +23,5 @@ del XSH.env['MISE_SHELL'] del os.environ['MISE_SHELL'] del XSH.env['__MISE_DIFF'] del os.environ['__MISE_DIFF'] -del XSH.env['__MISE_WATCH'] -del os.environ['__MISE_WATCH'] +del XSH.env['__MISE_SESSION'] +del os.environ['__MISE_SESSION'] diff --git a/src/shell/snapshots/mise__shell__zsh__tests__deactivate.snap b/src/shell/snapshots/mise__shell__zsh__tests__deactivate.snap index dfb93008f..61f8ace48 100644 --- a/src/shell/snapshots/mise__shell__zsh__tests__deactivate.snap +++ b/src/shell/snapshots/mise__shell__zsh__tests__deactivate.snap @@ -8,5 +8,5 @@ chpwd_functions=( ${chpwd_functions:#_mise_hook} ) unset -f _mise_hook unset -f mise unset MISE_SHELL -unset __MISE_WATCH unset __MISE_DIFF +unset __MISE_SESSION diff --git a/src/shell/xonsh.rs b/src/shell/xonsh.rs index 2f65f6d58..0a76ab168 100644 --- a/src/shell/xonsh.rs +++ b/src/shell/xonsh.rs @@ -92,8 +92,8 @@ impl Shell for Xonsh { del os.environ['MISE_SHELL'] del XSH.env['__MISE_DIFF'] del os.environ['__MISE_DIFF'] - del XSH.env['__MISE_WATCH'] - del os.environ['__MISE_WATCH'] + del XSH.env['__MISE_SESSION'] + del os.environ['__MISE_SESSION'] "#} } diff --git a/src/shell/zsh.rs b/src/shell/zsh.rs index 788a145d6..39ea058fd 100644 --- a/src/shell/zsh.rs +++ b/src/shell/zsh.rs @@ -93,8 +93,8 @@ impl Shell for Zsh { unset -f _mise_hook unset -f mise unset MISE_SHELL - unset __MISE_WATCH unset __MISE_DIFF + unset __MISE_SESSION "#} } diff --git a/src/toolset/mod.rs b/src/toolset/mod.rs index ce01b4825..de067ad07 100644 --- a/src/toolset/mod.rs +++ b/src/toolset/mod.rs @@ -208,7 +208,7 @@ impl Toolset { if versions.is_empty() { return Ok(vec![]); } - hooks::run_one_hook(self, Hooks::Preinstall); + hooks::run_one_hook(self, Hooks::Preinstall, None); self.init_request_options(&mut versions); show_python_install_hint(&versions); let mut installed = vec![]; @@ -248,7 +248,7 @@ impl Toolset { } } } - hooks::run_one_hook(self, Hooks::Postinstall); + hooks::run_one_hook(self, Hooks::Postinstall, None); Ok(installed) }