.
This commit is contained in:
@@ -79,6 +79,8 @@ pub struct RepoDetailView {
|
||||
/// A clone/fetch is in flight.
|
||||
loading: bool,
|
||||
error: Option<SharedString>,
|
||||
/// Commit HEAD currently points to, shown in the header button.
|
||||
head_commit: Option<FileCommit>,
|
||||
/// Branch selector (header): local branches, searchable.
|
||||
branch_select: Entity<ComboboxState<SearchableVec<SharedString>>>,
|
||||
/// Tag selector (header): tags, searchable.
|
||||
@@ -164,6 +166,7 @@ impl RepoDetailView {
|
||||
item_sizes: Rc::new(Vec::new()),
|
||||
loading: true,
|
||||
error: None,
|
||||
head_commit: None,
|
||||
branch_select,
|
||||
tag_select,
|
||||
switching_ref: false,
|
||||
@@ -203,6 +206,7 @@ impl RepoDetailView {
|
||||
),
|
||||
None => (Vec::new(), Vec::new(), None),
|
||||
};
|
||||
let head_commit = signed_git::head_commit(&repo).unwrap_or(None);
|
||||
|
||||
Ok::<_, Error>((
|
||||
entries,
|
||||
@@ -212,6 +216,7 @@ impl RepoDetailView {
|
||||
branches,
|
||||
tags,
|
||||
current_branch,
|
||||
head_commit,
|
||||
))
|
||||
});
|
||||
|
||||
@@ -228,8 +233,10 @@ impl RepoDetailView {
|
||||
branches,
|
||||
tags,
|
||||
current_branch,
|
||||
head_commit,
|
||||
)) => {
|
||||
this.worktree = Some(worktree);
|
||||
this.head_commit = head_commit;
|
||||
this.tree_state.update(cx, |state, cx| {
|
||||
state.set_items(build_tree_items(&entries), cx);
|
||||
});
|
||||
@@ -259,7 +266,7 @@ impl RepoDetailView {
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok((_, _, _, None, _, _, _)) => {
|
||||
Ok((_, _, _, None, _, _, _, _)) => {
|
||||
this.error = Some("Repository has no worktree".into());
|
||||
}
|
||||
Err(error) => {
|
||||
@@ -589,6 +596,7 @@ impl RepoDetailView {
|
||||
this.switching_ref = false;
|
||||
match result {
|
||||
Ok(snapshot) => {
|
||||
this.head_commit = snapshot.head_commit;
|
||||
// Rebuild the tree from scratch: entries of the
|
||||
// previous branch are gone, and with them the
|
||||
// expansion state.
|
||||
@@ -619,6 +627,7 @@ impl RepoDetailView {
|
||||
}
|
||||
Err(error) => {
|
||||
this.error = Some(error.to_string().into());
|
||||
this.head_commit = None;
|
||||
// The tree may show files that no longer exist.
|
||||
this.tree_state.update(cx, |state, cx| {
|
||||
state.set_items(Vec::new(), cx);
|
||||
@@ -870,6 +879,34 @@ impl Render for RepoDetailView {
|
||||
)
|
||||
}),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
Button::new("enc")
|
||||
.secondary()
|
||||
.when_some(self.head_commit.as_ref(), |this, commit| {
|
||||
this.child(
|
||||
div()
|
||||
.text_xs()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child(SharedString::from(&commit.id)),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.max_w(px(200.))
|
||||
.overflow_hidden()
|
||||
.text_ellipsis()
|
||||
.whitespace_nowrap()
|
||||
.text_xs()
|
||||
.child(SharedString::from(&commit.summary)),
|
||||
)
|
||||
})
|
||||
.tooltip(
|
||||
self.head_commit
|
||||
.as_ref()
|
||||
.map_or_else(SharedString::default, |commit| {
|
||||
commit.summary.clone().into()
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user