git: Add setting to hide blame info in shared project
Fixes #16814 Implementation strategy: - introduce share_with_collaborators setting to InlineBlameSettings. - modify GitStore::handle_blame_buffer to read this setting and send empty BlameBufferResponse when the value is true.
This commit is contained in:
parent
159b5e9fb5
commit
29a458e9d8
2 changed files with 33 additions and 0 deletions
|
@ -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())
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue