diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index edc6b00a7b..2dea0e1376 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -4,6 +4,7 @@ pub mod git_traversal; use crate::{ ProjectEnvironment, ProjectItem, ProjectPath, buffer_store::{BufferStore, BufferStoreEvent}, + project_settings::ProjectSettings, worktree_store::{WorktreeStore, WorktreeStoreEvent}, }; use anyhow::{Context as _, Result, anyhow, bail}; @@ -47,6 +48,7 @@ use rpc::{ proto::{self, FromProto, SSH_PROJECT_ID, ToProto, git_reset, split_repository_update}, }; use serde::Deserialize; +use settings::Settings; use std::{ cmp::Ordering, collections::{BTreeSet, VecDeque}, @@ -2244,6 +2246,21 @@ impl GitStore { let buffer = this.read_with(&cx, |this, cx| { this.buffer_store.read(cx).get_existing(buffer_id) })??; + + if envelope.original_sender_id.is_some() { + let allowed = this.read_with(&cx, |_, cx| { + ProjectSettings::get_global(cx) + .git + .inline_blame_share_with_collaborators() + })?; + + if !allowed { + return Ok(proto::BlameBufferResponse { + blame_response: None, + }); + } + } + buffer .update(&mut cx, |buffer, _| { buffer.wait_for_version(version.clone()) diff --git a/crates/project/src/project_settings.rs b/crates/project/src/project_settings.rs index a6fea4059c..fcb974c514 100644 --- a/crates/project/src/project_settings.rs +++ b/crates/project/src/project_settings.rs @@ -448,6 +448,16 @@ impl GitSettings { _ => false, } } + + pub fn inline_blame_share_with_collaborators(&self) -> bool { + match self.inline_blame { + Some(InlineBlameSettings { + share_with_collaborators, + .. + }) => share_with_collaborators, + _ => true, + } + } } #[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, JsonSchema)] @@ -501,6 +511,11 @@ pub struct InlineBlameSettings { /// Default: false #[serde(default)] pub show_commit_summary: bool, + /// Allow sending blame information to collaborators in shared projects. + /// + /// When false, the host will refuse remote blame requests for buffers. Default: true + #[serde(default = "default_true")] + pub share_with_collaborators: bool, } fn default_inline_blame_padding() -> u32 { @@ -515,6 +530,7 @@ impl Default for InlineBlameSettings { padding: default_inline_blame_padding(), min_column: 0, show_commit_summary: false, + share_with_collaborators: true, } } }