feature: show author name in brach picker commit information
This commit is contained in:
parent
d49409caba
commit
9f3d9fc730
11 changed files with 98 additions and 5 deletions
|
@ -1177,6 +1177,10 @@
|
||||||
// The minimum column number to show the inline blame information at
|
// The minimum column number to show the inline blame information at
|
||||||
"min_column": 0
|
"min_column": 0
|
||||||
},
|
},
|
||||||
|
// Control which information is shown in the branch picker.
|
||||||
|
"branch_picker": {
|
||||||
|
"show_author_name": false
|
||||||
|
},
|
||||||
// How git hunks are displayed visually in the editor.
|
// How git hunks are displayed visually in the editor.
|
||||||
// This setting can take two values:
|
// This setting can take two values:
|
||||||
//
|
//
|
||||||
|
|
|
@ -150,6 +150,7 @@ pub struct CommitSummary {
|
||||||
pub subject: SharedString,
|
pub subject: SharedString,
|
||||||
/// This is a unix timestamp
|
/// This is a unix timestamp
|
||||||
pub commit_timestamp: i64,
|
pub commit_timestamp: i64,
|
||||||
|
pub author_name: SharedString,
|
||||||
pub has_parent: bool,
|
pub has_parent: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -987,6 +988,7 @@ impl GitRepository for RealGitRepository {
|
||||||
"%(upstream)",
|
"%(upstream)",
|
||||||
"%(upstream:track)",
|
"%(upstream:track)",
|
||||||
"%(committerdate:unix)",
|
"%(committerdate:unix)",
|
||||||
|
"%(authorname)",
|
||||||
"%(contents:subject)",
|
"%(contents:subject)",
|
||||||
]
|
]
|
||||||
.join("%00");
|
.join("%00");
|
||||||
|
@ -2020,6 +2022,7 @@ fn parse_branch_input(input: &str) -> Result<Vec<Branch>> {
|
||||||
let upstream_name = fields.next().context("no upstream")?.to_string();
|
let upstream_name = fields.next().context("no upstream")?.to_string();
|
||||||
let upstream_tracking = parse_upstream_track(fields.next().context("no upstream:track")?)?;
|
let upstream_tracking = parse_upstream_track(fields.next().context("no upstream:track")?)?;
|
||||||
let commiterdate = fields.next().context("no committerdate")?.parse::<i64>()?;
|
let commiterdate = fields.next().context("no committerdate")?.parse::<i64>()?;
|
||||||
|
let author_name = fields.next().context("no authorname")?.to_string().into();
|
||||||
let subject: SharedString = fields
|
let subject: SharedString = fields
|
||||||
.next()
|
.next()
|
||||||
.context("no contents:subject")?
|
.context("no contents:subject")?
|
||||||
|
@ -2033,6 +2036,7 @@ fn parse_branch_input(input: &str) -> Result<Vec<Branch>> {
|
||||||
sha: head_sha,
|
sha: head_sha,
|
||||||
subject,
|
subject,
|
||||||
commit_timestamp: commiterdate,
|
commit_timestamp: commiterdate,
|
||||||
|
author_name: author_name,
|
||||||
has_parent: !parent_sha.is_empty(),
|
has_parent: !parent_sha.is_empty(),
|
||||||
}),
|
}),
|
||||||
upstream: if upstream_name.is_empty() {
|
upstream: if upstream_name.is_empty() {
|
||||||
|
@ -2343,7 +2347,7 @@ mod tests {
|
||||||
fn test_branches_parsing() {
|
fn test_branches_parsing() {
|
||||||
// suppress "help: octal escapes are not supported, `\0` is always null"
|
// suppress "help: octal escapes are not supported, `\0` is always null"
|
||||||
#[allow(clippy::octal_escapes)]
|
#[allow(clippy::octal_escapes)]
|
||||||
let input = "*\0060964da10574cd9bf06463a53bf6e0769c5c45e\0\0refs/heads/zed-patches\0refs/remotes/origin/zed-patches\0\01733187470\0generated protobuf\n";
|
let input = "*\0060964da10574cd9bf06463a53bf6e0769c5c45e\0\0refs/heads/zed-patches\0refs/remotes/origin/zed-patches\0\01733187470\0John Doe\0generated protobuf\n";
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_branch_input(input).unwrap(),
|
parse_branch_input(input).unwrap(),
|
||||||
vec![Branch {
|
vec![Branch {
|
||||||
|
@ -2360,6 +2364,7 @@ mod tests {
|
||||||
sha: "060964da10574cd9bf06463a53bf6e0769c5c45e".into(),
|
sha: "060964da10574cd9bf06463a53bf6e0769c5c45e".into(),
|
||||||
subject: "generated protobuf".into(),
|
subject: "generated protobuf".into(),
|
||||||
commit_timestamp: 1733187470,
|
commit_timestamp: 1733187470,
|
||||||
|
author_name: SharedString::new("John Doe"),
|
||||||
has_parent: false,
|
has_parent: false,
|
||||||
})
|
})
|
||||||
}]
|
}]
|
||||||
|
|
|
@ -90,6 +90,11 @@ impl BlameRenderer for GitBlameRenderer {
|
||||||
sha: blame_entry.sha.to_string().into(),
|
sha: blame_entry.sha.to_string().into(),
|
||||||
subject: blame_entry.summary.clone().unwrap_or_default().into(),
|
subject: blame_entry.summary.clone().unwrap_or_default().into(),
|
||||||
commit_timestamp: blame_entry.committer_time.unwrap_or_default(),
|
commit_timestamp: blame_entry.committer_time.unwrap_or_default(),
|
||||||
|
author_name: blame_entry
|
||||||
|
.committer_name
|
||||||
|
.clone()
|
||||||
|
.unwrap_or_default()
|
||||||
|
.into(),
|
||||||
has_parent: true,
|
has_parent: true,
|
||||||
},
|
},
|
||||||
repository.downgrade(),
|
repository.downgrade(),
|
||||||
|
@ -229,6 +234,7 @@ impl BlameRenderer for GitBlameRenderer {
|
||||||
.into()
|
.into()
|
||||||
}),
|
}),
|
||||||
commit_timestamp: commit_details.commit_time.unix_timestamp(),
|
commit_timestamp: commit_details.commit_time.unix_timestamp(),
|
||||||
|
author_name: commit_details.author_name.clone(),
|
||||||
has_parent: false,
|
has_parent: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -374,6 +380,7 @@ impl BlameRenderer for GitBlameRenderer {
|
||||||
sha: blame_entry.sha.to_string().into(),
|
sha: blame_entry.sha.to_string().into(),
|
||||||
subject: blame_entry.summary.clone().unwrap_or_default().into(),
|
subject: blame_entry.summary.clone().unwrap_or_default().into(),
|
||||||
commit_timestamp: blame_entry.committer_time.unwrap_or_default(),
|
commit_timestamp: blame_entry.committer_time.unwrap_or_default(),
|
||||||
|
author_name: blame_entry.committer_name.unwrap_or_default().into(),
|
||||||
has_parent: true,
|
has_parent: true,
|
||||||
},
|
},
|
||||||
repository.downgrade(),
|
repository.downgrade(),
|
||||||
|
|
|
@ -10,6 +10,8 @@ use gpui::{
|
||||||
};
|
};
|
||||||
use picker::{Picker, PickerDelegate, PickerEditorPosition};
|
use picker::{Picker, PickerDelegate, PickerEditorPosition};
|
||||||
use project::git_store::Repository;
|
use project::git_store::Repository;
|
||||||
|
use project::project_settings::ProjectSettings;
|
||||||
|
use settings::Settings;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
use time_format::format_local_timestamp;
|
use time_format::format_local_timestamp;
|
||||||
|
@ -452,7 +454,7 @@ impl PickerDelegate for BranchListDelegate {
|
||||||
) -> Option<Self::ListItem> {
|
) -> Option<Self::ListItem> {
|
||||||
let entry = &self.matches[ix];
|
let entry = &self.matches[ix];
|
||||||
|
|
||||||
let (commit_time, subject) = entry
|
let (commit_time, author_name, subject) = entry
|
||||||
.branch
|
.branch
|
||||||
.most_recent_commit
|
.most_recent_commit
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -465,9 +467,10 @@ impl PickerDelegate for BranchListDelegate {
|
||||||
OffsetDateTime::now_utc(),
|
OffsetDateTime::now_utc(),
|
||||||
time_format::TimestampFormat::Relative,
|
time_format::TimestampFormat::Relative,
|
||||||
);
|
);
|
||||||
(Some(formatted_time), Some(subject))
|
let author = commit.author_name.clone();
|
||||||
|
(Some(formatted_time), Some(author), Some(subject))
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| (None, None));
|
.unwrap_or_else(|| (None, None, None));
|
||||||
|
|
||||||
let icon = if let Some(default_branch) = self.default_branch.clone()
|
let icon = if let Some(default_branch) = self.default_branch.clone()
|
||||||
&& entry.is_new
|
&& entry.is_new
|
||||||
|
@ -548,7 +551,19 @@ impl PickerDelegate for BranchListDelegate {
|
||||||
"based off the current branch".to_string()
|
"based off the current branch".to_string()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
subject.unwrap_or("no commits found".into()).to_string()
|
let show_author_name = ProjectSettings::get_global(cx)
|
||||||
|
.git
|
||||||
|
.branch_picker
|
||||||
|
.unwrap_or_default()
|
||||||
|
.show_author_name;
|
||||||
|
|
||||||
|
subject.map_or("no commits found".into(), |subject| {
|
||||||
|
if show_author_name && author_name.is_some() {
|
||||||
|
format!("{} • {}", author_name.unwrap(), subject)
|
||||||
|
} else {
|
||||||
|
subject.to_string()
|
||||||
|
}
|
||||||
|
})
|
||||||
};
|
};
|
||||||
Label::new(message)
|
Label::new(message)
|
||||||
.size(LabelSize::Small)
|
.size(LabelSize::Small)
|
||||||
|
|
|
@ -229,6 +229,7 @@ impl Render for CommitTooltip {
|
||||||
.into()
|
.into()
|
||||||
}),
|
}),
|
||||||
commit_timestamp: self.commit.commit_time.unix_timestamp(),
|
commit_timestamp: self.commit.commit_time.unix_timestamp(),
|
||||||
|
author_name: self.commit.author_name.clone(),
|
||||||
has_parent: false,
|
has_parent: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4963,6 +4963,7 @@ impl Component for PanelRepoFooter {
|
||||||
sha: "abc123".into(),
|
sha: "abc123".into(),
|
||||||
subject: "Modify stuff".into(),
|
subject: "Modify stuff".into(),
|
||||||
commit_timestamp: 1710932954,
|
commit_timestamp: 1710932954,
|
||||||
|
author_name: "John Doe".into(),
|
||||||
has_parent: true,
|
has_parent: true,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
@ -4980,6 +4981,7 @@ impl Component for PanelRepoFooter {
|
||||||
sha: "abc123".into(),
|
sha: "abc123".into(),
|
||||||
subject: "Modify stuff".into(),
|
subject: "Modify stuff".into(),
|
||||||
commit_timestamp: 1710932954,
|
commit_timestamp: 1710932954,
|
||||||
|
author_name: "John Doe".into(),
|
||||||
has_parent: true,
|
has_parent: true,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1219,6 +1219,7 @@ mod preview {
|
||||||
sha: "abc123".into(),
|
sha: "abc123".into(),
|
||||||
subject: "Modify stuff".into(),
|
subject: "Modify stuff".into(),
|
||||||
commit_timestamp: 1710932954,
|
commit_timestamp: 1710932954,
|
||||||
|
author_name: "John Doe".into(),
|
||||||
has_parent: true,
|
has_parent: true,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
|
@ -4785,6 +4785,7 @@ fn branch_to_proto(branch: &git::repository::Branch) -> proto::Branch {
|
||||||
sha: commit.sha.to_string(),
|
sha: commit.sha.to_string(),
|
||||||
subject: commit.subject.to_string(),
|
subject: commit.subject.to_string(),
|
||||||
commit_timestamp: commit.commit_timestamp,
|
commit_timestamp: commit.commit_timestamp,
|
||||||
|
author_name: commit.author_name.to_string(),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4814,6 +4815,7 @@ fn proto_to_branch(proto: &proto::Branch) -> git::repository::Branch {
|
||||||
sha: commit.sha.to_string().into(),
|
sha: commit.sha.to_string().into(),
|
||||||
subject: commit.subject.to_string().into(),
|
subject: commit.subject.to_string().into(),
|
||||||
commit_timestamp: commit.commit_timestamp,
|
commit_timestamp: commit.commit_timestamp,
|
||||||
|
author_name: commit.author_name.to_string().into(),
|
||||||
has_parent: true,
|
has_parent: true,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -393,6 +393,10 @@ pub struct GitSettings {
|
||||||
///
|
///
|
||||||
/// Default: on
|
/// Default: on
|
||||||
pub inline_blame: Option<InlineBlameSettings>,
|
pub inline_blame: Option<InlineBlameSettings>,
|
||||||
|
/// Which information to show in the branch picker.
|
||||||
|
///
|
||||||
|
/// Default: on
|
||||||
|
pub branch_picker: Option<BranchPickerSettings>,
|
||||||
/// How hunks are displayed visually in the editor.
|
/// How hunks are displayed visually in the editor.
|
||||||
///
|
///
|
||||||
/// Default: staged_hollow
|
/// Default: staged_hollow
|
||||||
|
@ -497,6 +501,24 @@ impl Default for InlineBlameSettings {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub struct BranchPickerSettings {
|
||||||
|
/// Whether to show author name as part of the commit information.
|
||||||
|
///
|
||||||
|
/// Default: false
|
||||||
|
#[serde(default)]
|
||||||
|
pub show_author_name: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for BranchPickerSettings {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
show_author_name: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema, Hash)]
|
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema, Hash)]
|
||||||
pub struct BinarySettings {
|
pub struct BinarySettings {
|
||||||
pub path: Option<String>,
|
pub path: Option<String>,
|
||||||
|
|
|
@ -95,6 +95,7 @@ message CommitSummary {
|
||||||
string sha = 1;
|
string sha = 1;
|
||||||
string subject = 2;
|
string subject = 2;
|
||||||
int64 commit_timestamp = 3;
|
int64 commit_timestamp = 3;
|
||||||
|
string author_name = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GitBranches {
|
message GitBranches {
|
||||||
|
|
|
@ -1725,6 +1725,9 @@ To interpret all `.c` files as C++, files called `MyLockFile` as TOML and files
|
||||||
"inline_blame": {
|
"inline_blame": {
|
||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
|
"branch_picker": {
|
||||||
|
"show_author_name": true
|
||||||
|
},
|
||||||
"hunk_style": "staged_hollow"
|
"hunk_style": "staged_hollow"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1856,6 +1859,36 @@ Example:
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Branch Picker
|
||||||
|
|
||||||
|
- Description: Configuration related to the branch picker.
|
||||||
|
- Setting: `branch_picker`
|
||||||
|
- Default:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"git": {
|
||||||
|
"branch_picker": {
|
||||||
|
"show_author_name": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Options**
|
||||||
|
|
||||||
|
1. Show the author name in the branch picker:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"git": {
|
||||||
|
"branch_picker": {
|
||||||
|
"show_author_name": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Hunk Style
|
### Hunk Style
|
||||||
|
|
||||||
- Description: What styling we should use for the diff hunks.
|
- Description: What styling we should use for the diff hunks.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue