Include commit summary in inline Git blame (#19759)
Closes #19758 Release Notes: - Added feature to show commit summary as part of the inline Git blame --------- Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
This commit is contained in:
parent
f7b2b41df9
commit
84328c303b
3 changed files with 29 additions and 1 deletions
|
@ -1978,6 +1978,7 @@ async fn test_git_blame_is_forwarded(cx_a: &mut TestAppContext, cx_b: &mut TestA
|
||||||
enabled: false,
|
enabled: false,
|
||||||
delay_ms: None,
|
delay_ms: None,
|
||||||
min_column: None,
|
min_column: None,
|
||||||
|
show_commit_summary: false,
|
||||||
});
|
});
|
||||||
cx_a.update(|cx| {
|
cx_a.update(|cx| {
|
||||||
SettingsStore::update_global(cx, |store, cx| {
|
SettingsStore::update_global(cx, |store, cx| {
|
||||||
|
|
|
@ -4153,7 +4153,16 @@ fn render_inline_blame_entry(
|
||||||
let relative_timestamp = blame_entry_relative_timestamp(&blame_entry);
|
let relative_timestamp = blame_entry_relative_timestamp(&blame_entry);
|
||||||
|
|
||||||
let author = blame_entry.author.as_deref().unwrap_or_default();
|
let author = blame_entry.author.as_deref().unwrap_or_default();
|
||||||
let text = format!("{}, {}", author, relative_timestamp);
|
let summary_enabled = ProjectSettings::get_global(cx)
|
||||||
|
.git
|
||||||
|
.show_inline_commit_summary();
|
||||||
|
|
||||||
|
let text = match blame_entry.summary.as_ref() {
|
||||||
|
Some(summary) if summary_enabled => {
|
||||||
|
format!("{}, {} - {}", author, relative_timestamp, summary)
|
||||||
|
}
|
||||||
|
_ => format!("{}, {}", author, relative_timestamp),
|
||||||
|
};
|
||||||
|
|
||||||
let details = blame.read(cx).details_for_entry(&blame_entry);
|
let details = blame.read(cx).details_for_entry(&blame_entry);
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,16 @@ impl GitSettings {
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn show_inline_commit_summary(&self) -> bool {
|
||||||
|
match self.inline_blame {
|
||||||
|
Some(InlineBlameSettings {
|
||||||
|
show_commit_summary,
|
||||||
|
..
|
||||||
|
}) => show_commit_summary,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
||||||
|
@ -141,11 +151,19 @@ pub struct InlineBlameSettings {
|
||||||
///
|
///
|
||||||
/// Default: 0
|
/// Default: 0
|
||||||
pub min_column: Option<u32>,
|
pub min_column: Option<u32>,
|
||||||
|
/// Whether to show commit summary as part of the inline blame.
|
||||||
|
///
|
||||||
|
/// Default: false
|
||||||
|
#[serde(default = "false_value")]
|
||||||
|
pub show_commit_summary: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
const fn true_value() -> bool {
|
const fn true_value() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
const fn false_value() -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
|
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
|
||||||
pub struct BinarySettings {
|
pub struct BinarySettings {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue