Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Unwind deprecated permalinks code (#26395)
Conrad Irwinc37d6d5feda1
diff --git a/Cargo.lock b/Cargo.lockindex 051ffa281ac..07203de7878 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -4458,7 +4458,6 @@ dependencies = ["env_logger 0.11.6","feature_flags","fs",- "git","gpui","http_client","language",diff --git a/crates/collab/src/tests/editor_tests.rs b/crates/collab/src/tests/editor_tests.rsindex 1bc0813e393..30b8f7d8aae 100644--- a/crates/collab/src/tests/editor_tests.rs+++ b/crates/collab/src/tests/editor_tests.rs@@ -3,7 +3,6 @@ use crate::{tests::{rust_lang, TestServer},};use call::ActiveCall;-use collections::HashMap;use editor::{actions::{ConfirmCodeAction, ConfirmCompletion, ConfirmRename, ContextMenuFirst, Redo, Rename,@@ -1983,7 +1982,6 @@ async fn test_git_blame_is_forwarded(cx_a: &mut TestAppContext, cx_b: &mut TestAblame_entry("3a3a3a", 2..3),blame_entry("4c4c4c", 3..4),],- permalinks: HashMap::default(), // This field is deprecratedmessages: [("1b1b1b", "message for idx-0"),("0d0d0d", "message for idx-1"),diff --git a/crates/editor/src/git/blame.rs b/crates/editor/src/git/blame.rsindex 58681336425..c3b76a651df 100644--- a/crates/editor/src/git/blame.rs+++ b/crates/editor/src/git/blame.rs@@ -370,7 +370,6 @@ impl GitBlame {async move {let Some(Blame {entries,- permalinks,messages,remote_url,}) = blame.await?@@ -379,13 +378,8 @@ impl GitBlame {};let entries = build_blame_entry_sum_tree(entries, snapshot.max_point().row);- let commit_details = parse_commit_messages(- messages,- remote_url,- &permalinks,- provider_registry,- )- .await;+ let commit_details =+ parse_commit_messages(messages, remote_url, provider_registry).await;anyhow::Ok(Some((entries, commit_details)))}@@ -477,7 +471,6 @@ fn build_blame_entry_sum_tree(entries: Vec<BlameEntry>, max_row: u32) -> SumTreeasync fn parse_commit_messages(messages: impl IntoIterator<Item = (Oid, String)>,remote_url: Option<String>,- deprecated_permalinks: &HashMap<Oid, Url>,provider_registry: Arc<GitHostingProviderRegistry>,) -> HashMap<Oid, ParsedCommitMessage> {let mut commit_details = HashMap::default();@@ -495,11 +488,7 @@ async fn parse_commit_messages(},))} else {- // DEPRECATED (18 Apr 24): Sending permalinks over the wire is deprecated. Clients- // now do the parsing. This is here for backwards compatibility, so that- // when an old peer sends a client no `parsed_remote_url` but `deprecated_permalinks`,- // we fall back to that.- deprecated_permalinks.get(&oid).cloned()+ continue;};let remote = parsed_remote_urldiff --git a/crates/evals/Cargo.toml b/crates/evals/Cargo.tomlindex 6484e9a6a70..9661da04eb3 100644--- a/crates/evals/Cargo.toml+++ b/crates/evals/Cargo.toml@@ -22,7 +22,6 @@ collections.workspace = trueenv_logger.workspace = truefeature_flags.workspace = truefs.workspace = true-git.workspace = truegpui.workspace = truehttp_client.workspace = truelanguage.workspace = truediff --git a/crates/evals/src/eval.rs b/crates/evals/src/eval.rsindex 5953bd4c112..fd60221ba92 100644--- a/crates/evals/src/eval.rs+++ b/crates/evals/src/eval.rs@@ -5,7 +5,6 @@ use client::{Client, UserStore};use clock::RealSystemClock;use collections::BTreeMap;use feature_flags::FeatureFlagAppExt as _;-use git::GitHostingProviderRegistry;use gpui::{AppContext as _, AsyncApp, BackgroundExecutor, Entity};use http_client::{HttpClient, Method};use language::LanguageRegistry;@@ -274,8 +273,7 @@ async fn run_evaluation(let repos_dir = Path::new(EVAL_REPOS_DIR);let db_path = Path::new(EVAL_DB_PATH);let api_key = std::env::var("OPENAI_API_KEY").unwrap();- let git_hosting_provider_registry = Arc::new(GitHostingProviderRegistry::new());- let fs = Arc::new(RealFs::new(git_hosting_provider_registry, None)) as Arc<dyn Fs>;+ let fs = Arc::new(RealFs::new(None)) as Arc<dyn Fs>;let clock = Arc::new(RealSystemClock);let client = cx.update(|cx| {diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rsindex f881726da3b..05946de3b7b 100644--- a/crates/fs/src/fs.rs+++ b/crates/fs/src/fs.rs@@ -11,7 +11,6 @@ use collections::HashMap;use git::status::StatusCode;#[cfg(any(test, feature = "test-support"))]use git::status::TrackedStatus;-use git::GitHostingProviderRegistry;#[cfg(any(test, feature = "test-support"))]use git::{repository::RepoPath, status::FileStatus};@@ -247,7 +246,6 @@ impl From<MTime> for proto::Timestamp {#[derive(Default)]pub struct RealFs {- git_hosting_provider_registry: Arc<GitHostingProviderRegistry>,git_binary_path: Option<PathBuf>,}@@ -300,14 +298,8 @@ impl FileHandle for std::fs::File {pub struct RealWatcher {}impl RealFs {- pub fn new(- git_hosting_provider_registry: Arc<GitHostingProviderRegistry>,- git_binary_path: Option<PathBuf>,- ) -> Self {- Self {- git_hosting_provider_registry,- git_binary_path,- }+ pub fn new(git_binary_path: Option<PathBuf>) -> Self {+ Self { git_binary_path }}}@@ -770,7 +762,6 @@ impl Fs for RealFs {Some(Arc::new(RealGitRepository::new(repo,self.git_binary_path.clone(),- self.git_hosting_provider_registry.clone(),)))}diff --git a/crates/git/src/blame.rs b/crates/git/src/blame.rsindex fcdd427c5aa..71d61eeefc9 100644--- a/crates/git/src/blame.rs+++ b/crates/git/src/blame.rs@@ -1,17 +1,15 @@use crate::commit::get_messages;-use crate::{parse_git_remote_url, BuildCommitPermalinkParams, GitHostingProviderRegistry, Oid};+use crate::Oid;use anyhow::{anyhow, Context as _, Result};use collections::{HashMap, HashSet};use serde::{Deserialize, Serialize};use std::io::Write;use std::process::Stdio;-use std::sync::Arc;use std::{ops::Range, path::Path};use text::Rope;use time::macros::format_description;use time::OffsetDateTime;use time::UtcOffset;-use url::Url;pub use git2 as libgit;@@ -19,7 +17,6 @@ pub use git2 as libgit;pub struct Blame {pub entries: Vec<BlameEntry>,pub messages: HashMap<Oid, String>,- pub permalinks: HashMap<Oid, Url>,pub remote_url: Option<String>,}@@ -30,32 +27,15 @@ impl Blame {path: &Path,content: &Rope,remote_url: Option<String>,- provider_registry: Arc<GitHostingProviderRegistry>,) -> Result<Self> {let output = run_git_blame(git_binary, working_directory, path, content)?;let mut entries = parse_git_blame(&output)?;entries.sort_unstable_by(|a, b| a.range.start.cmp(&b.range.start));- let mut permalinks = HashMap::default();let mut unique_shas = HashSet::default();- let parsed_remote_url = remote_url- .as_deref()- .and_then(|remote_url| parse_git_remote_url(provider_registry, remote_url));for entry in entries.iter_mut() {unique_shas.insert(entry.sha);- // DEPRECATED (18 Apr 24): Sending permalinks over the wire is deprecated. Clients- // now do the parsing.- if let Some((provider, remote)) = parsed_remote_url.as_ref() {- permalinks.entry(entry.sha).or_insert_with(|| {- provider.build_commit_permalink(- remote,- BuildCommitPermalinkParams {- sha: entry.sha.to_string().as_str(),- },- )- });- }}let shas = unique_shas.into_iter().collect::<Vec<_>>();@@ -64,7 +44,6 @@ impl Blame {Ok(Self {entries,- permalinks,messages,remote_url,})diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rsindex 9013d33c3ca..99a490c0dca 100644--- a/crates/git/src/repository.rs+++ b/crates/git/src/repository.rs@@ -1,5 +1,4 @@use crate::status::FileStatus;-use crate::GitHostingProviderRegistry;use crate::{blame::Blame, status::GitStatus};use anyhow::{anyhow, Context, Result};use askpass::{AskPassResult, AskPassSession};@@ -263,19 +262,13 @@ impl std::fmt::Debug for dyn GitRepository {pub struct RealGitRepository {pub repository: Mutex<git2::Repository>,pub git_binary_path: PathBuf,- hosting_provider_registry: Arc<GitHostingProviderRegistry>,}impl RealGitRepository {- pub fn new(- repository: git2::Repository,- git_binary_path: Option<PathBuf>,- hosting_provider_registry: Arc<GitHostingProviderRegistry>,- ) -> Self {+ pub fn new(repository: git2::Repository, git_binary_path: Option<PathBuf>) -> Self {Self {repository: Mutex::new(repository),git_binary_path: git_binary_path.unwrap_or_else(|| PathBuf::from("git")),- hosting_provider_registry,}}@@ -617,7 +610,6 @@ impl GitRepository for RealGitRepository {path,&content,remote_url,- self.hosting_provider_registry.clone(),)}diff --git a/crates/project/src/buffer_store.rs b/crates/project/src/buffer_store.rsindex 04de596eb6a..e514d91ec22 100644--- a/crates/project/src/buffer_store.rs+++ b/crates/project/src/buffer_store.rs@@ -15,7 +15,6 @@ use git::{blame::Blame, repository::RepoPath};use gpui::{App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Subscription, Task, WeakEntity,};-use http_client::Url;use language::{proto::{deserialize_line_ending, deserialize_version, serialize_line_ending, serialize_version,@@ -34,7 +33,6 @@ use std::{ops::Range,path::{Path, PathBuf},pin::pin,- str::FromStr as _,sync::Arc,time::Instant,};@@ -2776,20 +2774,10 @@ fn serialize_blame_buffer_response(blame: Option<git::blame::Blame>) -> proto::B}).collect::<Vec<_>>();- let permalinks = blame- .permalinks- .into_iter()- .map(|(oid, url)| proto::CommitPermalink {- oid: oid.as_bytes().into(),- permalink: url.to_string(),- })- .collect::<Vec<_>>();-proto::BlameBufferResponse {blame_response: Some(proto::blame_buffer_response::BlameResponse {entries,messages,- permalinks,remote_url: blame.remote_url,}),}@@ -2828,20 +2816,8 @@ fn deserialize_blame_buffer_response(.filter_map(|message| Some((git::Oid::from_bytes(&message.oid).ok()?, message.message))).collect::<HashMap<_, _>>();- let permalinks = response- .permalinks- .into_iter()- .filter_map(|permalink| {- Some((- git::Oid::from_bytes(&permalink.oid).ok()?,- Url::from_str(&permalink.permalink).ok()?,- ))- })- .collect::<HashMap<_, _>>();-Some(Blame {entries,- permalinks,messages,remote_url: response.remote_url,})diff --git a/crates/proto/proto/zed.proto b/crates/proto/proto/zed.protoindex 5cc19ca51eb..5feddb92699 100644--- a/crates/proto/proto/zed.proto+++ b/crates/proto/proto/zed.proto@@ -2321,8 +2321,8 @@ message BlameBufferResponse {message BlameResponse {repeated BlameEntry entries = 1;repeated CommitMessage messages = 2;- repeated CommitPermalink permalinks = 3;optional string remote_url = 4;+ reserved 3;}optional BlameResponse blame_response = 5;diff --git a/crates/remote_server/src/unix.rs b/crates/remote_server/src/unix.rsindex def19f5ab36..d7eabaf648f 100644--- a/crates/remote_server/src/unix.rs+++ b/crates/remote_server/src/unix.rs@@ -445,7 +445,7 @@ pub fn execute_run(let extension_host_proxy = ExtensionHostProxy::global(cx);let project = cx.new(|cx| {- let fs = Arc::new(RealFs::new(Default::default(), None));+ let fs = Arc::new(RealFs::new(None));let node_settings_rx = initialize_settings(session.clone(), fs.clone(), cx);let proxy_url = read_proxy_settings(cx);diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rsindex 4133a15867a..f832fe7029e 100644--- a/crates/zed/src/main.rs+++ b/crates/zed/src/main.rs@@ -254,10 +254,7 @@ fn main() {};log::info!("Using git binary path: {:?}", git_binary_path);- let fs = Arc::new(RealFs::new(- git_hosting_provider_registry.clone(),- git_binary_path,- ));+ let fs = Arc::new(RealFs::new(git_binary_path));let user_settings_file_rx = watch_config_file(&app.background_executor(),fs.clone(),