diff options
| author | JJ Liebig <jonathan.liebig@gmail.com> | 2026-09-04 01:05:35 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-04 01:05:35 +0200 |
| commit | 3150bd92d6162ba248bc28fd4d40bd0d6238e1af (patch) | |
| tree | beab751f2fc61d49a9f771091b9132cd1357b070 /src/integration/env.rs | |
| parent | 73825652244edaf11d3fddc89b5b00266edcae0d (diff) | |
fix(integration): resolve Devin config on Windows (#3595)
refs #2724
Diffstat (limited to 'src/integration/env.rs')
| -rw-r--r-- | src/integration/env.rs | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/integration/env.rs b/src/integration/env.rs index 8f3a9e65..c4ee1c34 100644 --- a/src/integration/env.rs +++ b/src/integration/env.rs @@ -76,6 +76,11 @@ pub(crate) fn devin_dir() -> io::Result<PathBuf> { return expand_tilde_path(PathBuf::from(value)).map(|path| path.join("devin")); } + #[cfg(windows)] + if let Some(value) = std::env::var_os("APPDATA").filter(|value| !value.is_empty()) { + return Ok(PathBuf::from(value).join("devin")); + } + Ok(home_dir()?.join(".config").join("devin")) } @@ -215,7 +220,31 @@ pub(crate) fn home_dir() -> io::Result<PathBuf> { } #[cfg(test)] -pub(crate) fn integration_env_lock() -> MutexGuard<'static, ()> { +pub(crate) struct IntegrationEnvLock { + _guard: MutexGuard<'static, ()>, + #[cfg(windows)] + appdata: Option<std::ffi::OsString>, +} + +#[cfg(test)] +impl Drop for IntegrationEnvLock { + fn drop(&mut self) { + #[cfg(windows)] + if let Some(appdata) = self.appdata.take() { + std::env::set_var("APPDATA", appdata); + } else { + std::env::remove_var("APPDATA"); + } + } +} + +#[cfg(test)] +pub(crate) fn integration_env_lock() -> IntegrationEnvLock { static LOCK: OnceLock<Mutex<()>> = OnceLock::new(); - LOCK.get_or_init(|| Mutex::new(())).lock().unwrap() + let guard = LOCK.get_or_init(|| Mutex::new(())).lock().unwrap(); + IntegrationEnvLock { + _guard: guard, + #[cfg(windows)] + appdata: std::env::var_os("APPDATA"), + } } |
