Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(commands): Add delete_unchanged option to forget #386

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
#[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 @@
(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)

Check warning on line 599 in crates/core/src/commands/forget.rs

View check run for this annotation

Codecov / codecov/patch

crates/core/src/commands/forget.rs#L599

Added line #L599 was not covered by tests
{
(false, vec!["unchanged"])

Check warning on line 601 in crates/core/src/commands/forget.rs

View check run for this annotation

Codecov / codecov/patch

crates/core/src/commands/forget.rs#L601

Added line #L601 was not covered by tests
} else {
let reasons =
group_keep.matches(&sn, last.as_ref(), iter.peek().is_some(), latest_time);
Expand Down
Loading