git_ui: Show author name on commits in branch picker (#36812)
See related discussion https://github.com/zed-industries/zed/discussions/36511. <img alt="zed" src="https://github.com/user-attachments/assets/da7fc30d-2504-48f4-a392-7c8d5cd8acb1" /> Release Notes: - Added option to show the author name in a branch picker commit information --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
co-authored by
Conrad Irwin
parent
9529cd18d1
commit
46fb521333
@@ -90,6 +90,11 @@ impl BlameRenderer for GitBlameRenderer {
|
||||
sha: blame_entry.sha.to_string().into(),
|
||||
subject: blame_entry.summary.clone().unwrap_or_default().into(),
|
||||
commit_timestamp: blame_entry.committer_time.unwrap_or_default(),
|
||||
author_name: blame_entry
|
||||
.committer_name
|
||||
.clone()
|
||||
.unwrap_or_default()
|
||||
.into(),
|
||||
has_parent: true,
|
||||
},
|
||||
repository.downgrade(),
|
||||
@@ -229,6 +234,7 @@ impl BlameRenderer for GitBlameRenderer {
|
||||
.into()
|
||||
}),
|
||||
commit_timestamp: commit_details.commit_time.unix_timestamp(),
|
||||
author_name: commit_details.author_name.clone(),
|
||||
has_parent: false,
|
||||
};
|
||||
|
||||
@@ -374,6 +380,7 @@ impl BlameRenderer for GitBlameRenderer {
|
||||
sha: blame_entry.sha.to_string().into(),
|
||||
subject: blame_entry.summary.clone().unwrap_or_default().into(),
|
||||
commit_timestamp: blame_entry.committer_time.unwrap_or_default(),
|
||||
author_name: blame_entry.committer_name.unwrap_or_default().into(),
|
||||
has_parent: true,
|
||||
},
|
||||
repository.downgrade(),
|
||||
|
||||
@@ -10,6 +10,8 @@ use gpui::{
|
||||
};
|
||||
use picker::{Picker, PickerDelegate, PickerEditorPosition};
|
||||
use project::git_store::Repository;
|
||||
use project::project_settings::ProjectSettings;
|
||||
use settings::Settings;
|
||||
use std::sync::Arc;
|
||||
use time::OffsetDateTime;
|
||||
use time_format::format_local_timestamp;
|
||||
@@ -454,7 +456,7 @@ impl PickerDelegate for BranchListDelegate {
|
||||
) -> Option<Self::ListItem> {
|
||||
let entry = &self.matches[ix];
|
||||
|
||||
let (commit_time, subject) = entry
|
||||
let (commit_time, author_name, subject) = entry
|
||||
.branch
|
||||
.most_recent_commit
|
||||
.as_ref()
|
||||
@@ -467,9 +469,10 @@ impl PickerDelegate for BranchListDelegate {
|
||||
OffsetDateTime::now_utc(),
|
||||
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()
|
||||
&& entry.is_new
|
||||
@@ -550,7 +553,19 @@ impl PickerDelegate for BranchListDelegate {
|
||||
"based off the current branch".to_string()
|
||||
}
|
||||
} 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)
|
||||
.size(LabelSize::Small)
|
||||
|
||||
@@ -229,6 +229,7 @@ impl Render for CommitTooltip {
|
||||
.into()
|
||||
}),
|
||||
commit_timestamp: self.commit.commit_time.unix_timestamp(),
|
||||
author_name: self.commit.author_name.clone(),
|
||||
has_parent: false,
|
||||
};
|
||||
|
||||
|
||||
@@ -5017,6 +5017,7 @@ impl Component for PanelRepoFooter {
|
||||
sha: "abc123".into(),
|
||||
subject: "Modify stuff".into(),
|
||||
commit_timestamp: 1710932954,
|
||||
author_name: "John Doe".into(),
|
||||
has_parent: true,
|
||||
}),
|
||||
}
|
||||
@@ -5034,6 +5035,7 @@ impl Component for PanelRepoFooter {
|
||||
sha: "abc123".into(),
|
||||
subject: "Modify stuff".into(),
|
||||
commit_timestamp: 1710932954,
|
||||
author_name: "John Doe".into(),
|
||||
has_parent: true,
|
||||
}),
|
||||
}
|
||||
|
||||
@@ -1220,6 +1220,7 @@ mod preview {
|
||||
sha: "abc123".into(),
|
||||
subject: "Modify stuff".into(),
|
||||
commit_timestamp: 1710932954,
|
||||
author_name: "John Doe".into(),
|
||||
has_parent: true,
|
||||
}),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user