git: Remove JobStatus from PendingOp in favour of in-flight pruning (#42955)
The idea is that we only store running (`!self.finished`) or finished (`self.finished`) pending ops, while everything else (skipped, errored) jobs are pruned out immediately. We don't really need them in the grand scheme of things anyway. Release Notes: - N/A
This commit is contained in:
@@ -11,14 +11,6 @@ pub enum GitStatus {
|
||||
Unchanged,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum JobStatus {
|
||||
Running,
|
||||
Finished,
|
||||
Skipped,
|
||||
Error,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct PendingOps {
|
||||
pub repo_path: RepoPath,
|
||||
@@ -29,7 +21,7 @@ pub struct PendingOps {
|
||||
pub struct PendingOp {
|
||||
pub id: PendingOpId,
|
||||
pub git_status: GitStatus,
|
||||
pub job_status: JobStatus,
|
||||
pub finished: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@@ -114,7 +106,7 @@ impl PendingOps {
|
||||
/// File is staged if the last job is finished and has status Staged.
|
||||
pub fn staged(&self) -> bool {
|
||||
if let Some(last) = self.ops.last() {
|
||||
if last.git_status == GitStatus::Staged && last.job_status == JobStatus::Finished {
|
||||
if last.git_status == GitStatus::Staged && last.finished {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -124,24 +116,10 @@ impl PendingOps {
|
||||
/// File is staged if the last job is not finished and has status Staged.
|
||||
pub fn staging(&self) -> bool {
|
||||
if let Some(last) = self.ops.last() {
|
||||
if last.git_status == GitStatus::Staged && last.job_status != JobStatus::Finished {
|
||||
if last.git_status == GitStatus::Staged && !last.finished {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl PendingOp {
|
||||
pub fn running(&self) -> bool {
|
||||
self.job_status == JobStatus::Running
|
||||
}
|
||||
|
||||
pub fn finished(&self) -> bool {
|
||||
matches!(self.job_status, JobStatus::Finished | JobStatus::Skipped)
|
||||
}
|
||||
|
||||
pub fn error(&self) -> bool {
|
||||
self.job_status == JobStatus::Error
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user