Skip to content

Commit aec986f

Browse files
committed
feat: Update copy and add --force
1 parent a3d71bb commit aec986f

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

Cargo.lock

Lines changed: 6 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commands/copy.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,22 @@ pub struct CopyCmd {
2626
#[merge(skip)]
2727
ids: Vec<String>,
2828

29+
/// Target repository (can be specified multiple times)
30+
#[clap(long = "target", value_name = "TARGET")]
31+
#[merge(strategy=conflate::vec::overwrite_empty)]
32+
targets: Vec<String>,
33+
2934
/// Initialize non-existing target repositories
3035
#[clap(long)]
3136
#[serde(skip)]
3237
#[merge(skip)]
3338
init: bool,
3439

35-
/// Target repository (can be specified multiple times)
36-
#[clap(long = "target", value_name = "TARGET")]
37-
#[merge(strategy=conflate::vec::overwrite_empty)]
38-
targets: Vec<String>,
40+
/// Copy snapshots even if the target already contains the original snapshot
41+
#[clap(long)]
42+
#[serde(skip)]
43+
#[merge(skip)]
44+
force: bool,
3945

4046
/// Key options (when using --init)
4147
#[clap(flatten, next_help_heading = "Key options (when using --init)")]
@@ -125,10 +131,18 @@ impl CopyCmd {
125131
);
126132
}
127133

128-
let snaps = target_repo.relevant_copy_snapshots(
129-
|sn| !self.ids.is_empty() || config.snapshot_filter.matches(sn),
130-
snapshots,
131-
)?;
134+
let snaps = if self.force {
135+
snapshots
136+
.iter()
137+
.cloned()
138+
.map(|sn| CopySnapshot { sn, relevant: true })
139+
.collect()
140+
} else {
141+
target_repo.relevant_copy_snapshots(
142+
|sn| !self.ids.is_empty() || config.snapshot_filter.matches(sn),
143+
snapshots,
144+
)?
145+
};
132146

133147
let mut table =
134148
table_with_titles(["ID", "Time", "Host", "Label", "Tags", "Paths", "Status"]);

0 commit comments

Comments
 (0)