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(check): Allow to only check trees+packs for given snapshots #1230

Merged
merged 2 commits into from
Oct 2, 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
17 changes: 15 additions & 2 deletions src/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ use crate::{commands::open_repository, status_err, Application, RUSTIC_APP};

use abscissa_core::{Command, Runnable, Shutdown};
use anyhow::Result;
use rustic_core::CheckOptions;
use rustic_core::{CheckOptions, SnapshotGroupCriterion};

/// `check` subcommand
#[derive(clap::Parser, Command, Debug)]
pub(crate) struct CheckCmd {
/// Snapshots to check. If none is given, use filter options to filter from all snapshots
#[clap(value_name = "ID")]
ids: Vec<String>,

/// Check options
#[clap(flatten)]
opts: CheckOptions,
Expand All @@ -27,7 +31,16 @@ impl CheckCmd {
fn inner_run(&self) -> Result<()> {
let config = RUSTIC_APP.config();
let repo = open_repository(&config.repository)?;
repo.check(self.opts)?;

let groups = repo.get_snapshot_group(&self.ids, SnapshotGroupCriterion::new(), |sn| {
simonsan marked this conversation as resolved.
Show resolved Hide resolved
config.snapshot_filter.matches(sn)
})?;
let trees = groups
.into_iter()
.flat_map(|(_, snaps)| snaps)
.map(|snap| snap.tree)
.collect();
repo.check_with_trees(self.opts, trees)?;
Ok(())
}
}