Improve when the commit suggestions would show (#26313)
Release Notes: - Git Beta: Fixed a few bugs where the suggested commit text wouldn't show in certain cases, or would update slowly.
This commit is contained in:
parent
e70d0edfac
commit
f6345a6995
4 changed files with 180 additions and 89 deletions
|
@ -54,6 +54,39 @@ impl From<TrackedStatus> for FileStatus {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub enum StageStatus {
|
||||
Staged,
|
||||
Unstaged,
|
||||
PartiallyStaged,
|
||||
}
|
||||
|
||||
impl StageStatus {
|
||||
pub fn is_fully_staged(&self) -> bool {
|
||||
matches!(self, StageStatus::Staged)
|
||||
}
|
||||
|
||||
pub fn is_fully_unstaged(&self) -> bool {
|
||||
matches!(self, StageStatus::Unstaged)
|
||||
}
|
||||
|
||||
pub fn has_staged(&self) -> bool {
|
||||
matches!(self, StageStatus::Staged | StageStatus::PartiallyStaged)
|
||||
}
|
||||
|
||||
pub fn has_unstaged(&self) -> bool {
|
||||
matches!(self, StageStatus::Unstaged | StageStatus::PartiallyStaged)
|
||||
}
|
||||
|
||||
pub fn as_bool(self) -> Option<bool> {
|
||||
match self {
|
||||
StageStatus::Staged => Some(true),
|
||||
StageStatus::Unstaged => Some(false),
|
||||
StageStatus::PartiallyStaged => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FileStatus {
|
||||
pub const fn worktree(worktree_status: StatusCode) -> Self {
|
||||
FileStatus::Tracked(TrackedStatus {
|
||||
|
@ -106,15 +139,15 @@ impl FileStatus {
|
|||
Ok(status)
|
||||
}
|
||||
|
||||
pub fn is_staged(self) -> Option<bool> {
|
||||
pub fn staging(self) -> StageStatus {
|
||||
match self {
|
||||
FileStatus::Untracked | FileStatus::Ignored | FileStatus::Unmerged { .. } => {
|
||||
Some(false)
|
||||
StageStatus::Unstaged
|
||||
}
|
||||
FileStatus::Tracked(tracked) => match (tracked.index_status, tracked.worktree_status) {
|
||||
(StatusCode::Unmodified, _) => Some(false),
|
||||
(_, StatusCode::Unmodified) => Some(true),
|
||||
_ => None,
|
||||
(StatusCode::Unmodified, _) => StageStatus::Unstaged,
|
||||
(_, StatusCode::Unmodified) => StageStatus::Staged,
|
||||
_ => StageStatus::PartiallyStaged,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue