Skip to content

Commit

Permalink
feat(commands): Add delete_unchanged option to forget (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
aawsome authored Dec 23, 2024
1 parent bd86c10 commit 9456147
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/core/src/commands/forget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ pub struct KeepOptions {
#[cfg_attr(feature = "merge", merge(strategy=conflate::bool::overwrite_false))]
#[serde(skip_serializing_if = "std::ops::Not::not")]
pub keep_none: bool,

/// Delete unchanged follow-up snapshots (i.e. with identical tree)
#[cfg_attr(feature = "clap", clap(long))]
#[cfg_attr(feature = "merge", merge(strategy=conflate::bool::overwrite_false))]
#[serde(skip_serializing_if = "std::ops::Not::not")]
pub delete_unchanged: bool,
}

/// Always return false
Expand Down Expand Up @@ -589,6 +595,10 @@ impl KeepOptions {
(true, vec!["snapshot"])
} else if sn.must_delete(now) {
(false, vec!["snapshot"])
} else if self.delete_unchanged
&& iter.peek().is_some_and(|sn_next| sn_next.tree == sn.tree)
{
(false, vec!["unchanged"])
} else {
let reasons =
group_keep.matches(&sn, last.as_ref(), iter.peek().is_some(), latest_time);
Expand Down

0 comments on commit 9456147

Please sign in to comment.