aports/testing/zed/dont-download-supermaven.patch

95 lines
3.2 KiB
Diff

From 50281646e70c7b405649f95cc1a26f2ea66a815c Mon Sep 17 00:00:00 2001
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Sun, 2 Jun 2024 23:46:10 +0200
Subject: [PATCH] Don't download Supermaven agent
See https://github.com/zed-industries/zed/issues/12589
---
crates/supermaven_api/src/supermaven_api.rs | 68 ++-------------------
1 file changed, 5 insertions(+), 63 deletions(-)
diff --git a/crates/supermaven_api/src/supermaven_api.rs b/crates/supermaven_api/src/supermaven_api.rs
index 6b1725644..fd4e60583 100644
--- a/crates/supermaven_api/src/supermaven_api.rs
+++ b/crates/supermaven_api/src/supermaven_api.rs
@@ -222,70 +222,12 @@ pub async fn has_version(version_path: &Path) -> bool {
}
pub fn get_supermaven_agent_path(
- client: Arc<dyn HttpClient>,
+ _client: Arc<dyn HttpClient>,
) -> impl Future<Output = Result<PathBuf>> {
+ // XXX-Patched
async move {
- fs::create_dir_all(&*SUPERMAVEN_DIR)
- .await
- .with_context(|| {
- format!(
- "Could not create Supermaven Agent Directory at {:?}",
- &*SUPERMAVEN_DIR
- )
- })?;
-
- let platform = match std::env::consts::OS {
- "macos" => "darwin",
- "windows" => "windows",
- "linux" => "linux",
- _ => return Err(anyhow!("unsupported platform")),
- };
-
- let arch = match std::env::consts::ARCH {
- "x86_64" => "amd64",
- "aarch64" => "arm64",
- _ => return Err(anyhow!("unsupported architecture")),
- };
-
- let download_info = latest_release(client.clone(), platform, arch).await?;
-
- let binary_path = version_path(download_info.version);
-
- if has_version(&binary_path).await {
- return Ok(binary_path);
- }
-
- let request = HttpRequest::get(&download_info.download_url);
-
- let mut response = client
- .send(request.body(AsyncBody::default())?)
- .await
- .with_context(|| "Unable to download Supermaven Agent".to_string())?;
-
- let mut file = File::create(&binary_path)
- .await
- .with_context(|| format!("Unable to create file at {:?}", binary_path))?;
-
- futures::io::copy(BufReader::new(response.body_mut()), &mut file)
- .await
- .with_context(|| format!("Unable to write binary to file at {:?}", binary_path))?;
-
- #[cfg(not(windows))]
- {
- file.set_permissions(<fs::Permissions as fs::unix::PermissionsExt>::from_mode(
- 0o755,
- ))
- .await?;
- }
-
- let mut old_binary_paths = fs::read_dir(&*SUPERMAVEN_DIR).await?;
- while let Some(old_binary_path) = old_binary_paths.next().await {
- let old_binary_path = old_binary_path?;
- if old_binary_path.path() != binary_path {
- fs::remove_file(old_binary_path.path()).await?;
- }
- }
-
- Ok(binary_path)
+ std::env::var("SUPERMAVEN_AGENT")
+ .map(PathBuf::from)
+ .with_context(|| "Set environment variable SUPERMAVEN_AGENT with path to Supermaven Agent")
}
}
--
2.43.0