Skip to content

Commit e3a701b

Browse files
committed
add snapshot diff to the CLI
1 parent 4c3db04 commit e3a701b

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

crates/gitbutler-cli/src/args.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ pub mod snapshot {
160160
/// The snapshot to restore
161161
snapshot_id: String,
162162
},
163+
/// Show what is stored in a given snapshot.
164+
Diff {
165+
/// The hex-hash of the commit-id of the snapshot.
166+
snapshot_id: String,
167+
},
163168
}
164169
}
165170

crates/gitbutler-cli/src/command/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ pub mod prepare;
22
pub mod project;
33
pub mod vbranch;
44
pub mod snapshot {
5+
use crate::command::debug_print;
56
use anyhow::Result;
67
use gitbutler_oplog::OplogExt;
78
use gitbutler_project::Project;
@@ -23,6 +24,10 @@ pub mod snapshot {
2324
project.restore_snapshot(snapshot_id.parse()?)?;
2425
Ok(())
2526
}
27+
28+
pub fn diff(project: Project, snapshot_id: String) -> Result<()> {
29+
debug_print(project.snapshot_diff(snapshot_id.parse()?))
30+
}
2631
}
2732

2833
fn debug_print(this: impl std::fmt::Debug) -> anyhow::Result<()> {

crates/gitbutler-cli/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ fn main() -> Result<()> {
8585
Some(snapshot::SubCommands::Restore { snapshot_id }) => {
8686
command::snapshot::restore(project, snapshot_id)
8787
}
88+
Some(snapshot::SubCommands::Diff { snapshot_id }) => {
89+
command::snapshot::diff(project, snapshot_id)
90+
}
8891
None => command::snapshot::list(project),
8992
}
9093
}

0 commit comments

Comments
 (0)