Format
This commit is contained in:
parent
e98507d8bf
commit
18cec8d64f
2 changed files with 23 additions and 34 deletions
|
@ -3787,14 +3787,9 @@ mod tests {
|
||||||
let oid = repo.index().unwrap().write_tree().unwrap();
|
let oid = repo.index().unwrap().write_tree().unwrap();
|
||||||
let tree = repo.find_tree(oid).unwrap();
|
let tree = repo.find_tree(oid).unwrap();
|
||||||
if let Some(head) = repo.head().ok() {
|
if let Some(head) = repo.head().ok() {
|
||||||
let parent_obj = head
|
let parent_obj = head.peel(git2::ObjectType::Commit).unwrap();
|
||||||
.peel(git2::ObjectType::Commit)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let parent_commit = parent_obj
|
|
||||||
.as_commit()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
|
let parent_commit = parent_obj.as_commit().unwrap();
|
||||||
|
|
||||||
repo.commit(
|
repo.commit(
|
||||||
Some("HEAD"),
|
Some("HEAD"),
|
||||||
|
@ -3806,15 +3801,8 @@ mod tests {
|
||||||
)
|
)
|
||||||
.expect("Failed to commit with parent");
|
.expect("Failed to commit with parent");
|
||||||
} else {
|
} else {
|
||||||
repo.commit(
|
repo.commit(Some("HEAD"), &signature, &signature, msg, &tree, &[])
|
||||||
Some("HEAD"),
|
.expect("Failed to commit");
|
||||||
&signature,
|
|
||||||
&signature,
|
|
||||||
msg,
|
|
||||||
&tree,
|
|
||||||
&[],
|
|
||||||
)
|
|
||||||
.expect("Failed to commit");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3842,14 +3830,13 @@ mod tests {
|
||||||
.expect("Could not reset");
|
.expect("Could not reset");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn git_status(repo: &git2::Repository) -> HashMap<String, git2::Status> {
|
fn git_status(repo: &git2::Repository) -> HashMap<String, git2::Status> {
|
||||||
repo.statuses(None)
|
repo.statuses(None)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|status| {
|
.map(|status| (status.path().unwrap().to_string(), status.status()))
|
||||||
(status.path().unwrap().to_string(), status.status())
|
|
||||||
})
|
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3931,10 +3918,8 @@ mod tests {
|
||||||
let snapshot = tree.snapshot();
|
let snapshot = tree.snapshot();
|
||||||
let (_, repo) = snapshot.repository_entries.iter().next().unwrap();
|
let (_, repo) = snapshot.repository_entries.iter().next().unwrap();
|
||||||
|
|
||||||
|
|
||||||
dbg!(&repo.statuses);
|
dbg!(&repo.statuses);
|
||||||
|
|
||||||
|
|
||||||
assert_eq!(repo.statuses.iter().count(), 1);
|
assert_eq!(repo.statuses.iter().count(), 1);
|
||||||
assert_eq!(repo.statuses.get(&Path::new(A_TXT).into()), None);
|
assert_eq!(repo.statuses.get(&Path::new(A_TXT).into()), None);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
|
@ -5,6 +5,7 @@ use futures::stream::StreamExt;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions,
|
actions,
|
||||||
anyhow::{anyhow, Result},
|
anyhow::{anyhow, Result},
|
||||||
|
color::Color,
|
||||||
elements::{
|
elements::{
|
||||||
AnchorCorner, ChildView, ContainerStyle, Empty, Flex, Label, MouseEventHandler,
|
AnchorCorner, ChildView, ContainerStyle, Empty, Flex, Label, MouseEventHandler,
|
||||||
ParentElement, ScrollTarget, Stack, Svg, UniformList, UniformListState,
|
ParentElement, ScrollTarget, Stack, Svg, UniformList, UniformListState,
|
||||||
|
@ -13,10 +14,13 @@ use gpui::{
|
||||||
keymap_matcher::KeymapContext,
|
keymap_matcher::KeymapContext,
|
||||||
platform::{CursorStyle, MouseButton, PromptLevel},
|
platform::{CursorStyle, MouseButton, PromptLevel},
|
||||||
AnyElement, AppContext, ClipboardItem, Element, Entity, ModelHandle, Task, View, ViewContext,
|
AnyElement, AppContext, ClipboardItem, Element, Entity, ModelHandle, Task, View, ViewContext,
|
||||||
ViewHandle, WeakViewHandle, color::Color,
|
ViewHandle, WeakViewHandle,
|
||||||
};
|
};
|
||||||
use menu::{Confirm, SelectNext, SelectPrev};
|
use menu::{Confirm, SelectNext, SelectPrev};
|
||||||
use project::{Entry, EntryKind, Project, ProjectEntryId, ProjectPath, Worktree, WorktreeId, repository::GitStatus};
|
use project::{
|
||||||
|
repository::GitStatus, Entry, EntryKind, Project, ProjectEntryId, ProjectPath, Worktree,
|
||||||
|
WorktreeId,
|
||||||
|
};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use std::{
|
use std::{
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
|
@ -86,7 +90,7 @@ pub struct EntryDetails {
|
||||||
is_editing: bool,
|
is_editing: bool,
|
||||||
is_processing: bool,
|
is_processing: bool,
|
||||||
is_cut: bool,
|
is_cut: bool,
|
||||||
git_status: Option<GitStatus>
|
git_status: Option<GitStatus>,
|
||||||
}
|
}
|
||||||
|
|
||||||
actions!(
|
actions!(
|
||||||
|
@ -1010,11 +1014,9 @@ impl ProjectPanel {
|
||||||
let entry_range = range.start.saturating_sub(ix)..end_ix - ix;
|
let entry_range = range.start.saturating_sub(ix)..end_ix - ix;
|
||||||
for entry in &visible_worktree_entries[entry_range] {
|
for entry in &visible_worktree_entries[entry_range] {
|
||||||
let path = &entry.path;
|
let path = &entry.path;
|
||||||
let status = snapshot.repo_for(path)
|
let status = snapshot
|
||||||
.and_then(|entry| {
|
.repo_for(path)
|
||||||
entry.status_for(&snapshot, path)
|
.and_then(|entry| entry.status_for(&snapshot, path));
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
let mut details = EntryDetails {
|
let mut details = EntryDetails {
|
||||||
filename: entry
|
filename: entry
|
||||||
|
@ -1036,7 +1038,7 @@ impl ProjectPanel {
|
||||||
is_cut: self
|
is_cut: self
|
||||||
.clipboard_entry
|
.clipboard_entry
|
||||||
.map_or(false, |e| e.is_cut() && e.entry_id() == entry.id),
|
.map_or(false, |e| e.is_cut() && e.entry_id() == entry.id),
|
||||||
git_status: status
|
git_status: status,
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(edit_state) = &self.edit_state {
|
if let Some(edit_state) = &self.edit_state {
|
||||||
|
@ -1078,14 +1080,16 @@ impl ProjectPanel {
|
||||||
let kind = details.kind;
|
let kind = details.kind;
|
||||||
let show_editor = details.is_editing && !details.is_processing;
|
let show_editor = details.is_editing && !details.is_processing;
|
||||||
|
|
||||||
let git_color = details.git_status.as_ref().and_then(|status| {
|
let git_color = details
|
||||||
match status {
|
.git_status
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|status| match status {
|
||||||
GitStatus::Added => Some(Color::green()),
|
GitStatus::Added => Some(Color::green()),
|
||||||
GitStatus::Modified => Some(Color::blue()),
|
GitStatus::Modified => Some(Color::blue()),
|
||||||
GitStatus::Conflict => Some(Color::red()),
|
GitStatus::Conflict => Some(Color::red()),
|
||||||
GitStatus::Untracked => None,
|
GitStatus::Untracked => None,
|
||||||
}
|
})
|
||||||
}).unwrap_or(Color::transparent_black());
|
.unwrap_or(Color::transparent_black());
|
||||||
|
|
||||||
Flex::row()
|
Flex::row()
|
||||||
.with_child(
|
.with_child(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue