Skip to content

Commit 623d74a

Browse files
committed
Add a way to get a list of changed items in the worktree.
1 parent 2c1bc32 commit 623d74a

File tree

11 files changed

+591
-16
lines changed

11 files changed

+591
-16
lines changed

Cargo.lock

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

crates/but-cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ but-core.workspace = true
1717
but-workspace.workspace = true
1818

1919
clap = { version = "4.5.23", features = ["derive", "env"] }
20+
gix.workspace = true
2021
anyhow.workspace = true
2122
tracing-forest = { version = "0.1.6" }
2223
tracing-subscriber.workspace = true

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@ pub fn project_from_path(path: PathBuf) -> anyhow::Result<Project> {
55
Project::from_path(&path)
66
}
77

8+
pub fn project_repo(path: PathBuf) -> anyhow::Result<gix::Repository> {
9+
let project = project_from_path(path)?;
10+
Ok(gix::open(project.gb_dir())?)
11+
}
12+
813
fn debug_print(this: impl std::fmt::Debug) -> anyhow::Result<()> {
914
println!("{:#?}", this);
1015
Ok(())
1116
}
1217

1318
pub mod status {
14-
use crate::command::debug_print;
19+
use crate::command::{debug_print, project_repo};
20+
use std::path::PathBuf;
1521

16-
pub fn doit() -> anyhow::Result<()> {
17-
debug_print("call into but-core")
22+
pub fn doit(current_dir: PathBuf) -> anyhow::Result<()> {
23+
debug_print(but_core::worktree::changes(&project_repo(current_dir)?))
1824
}
1925
}
2026

crates/but-cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn main() -> Result<()> {
1515
let _op_span = tracing::info_span!("cli-op").entered();
1616

1717
match args.cmd {
18-
args::Subcommands::Status => command::status::doit(),
18+
args::Subcommands::Status => command::status::doit(args.current_dir),
1919
args::Subcommands::Stacks => command::stacks::list(args.current_dir),
2020
}
2121
}

crates/but-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ doctest = false
1212
serde = { workspace = true, features = ["std"] }
1313
bstr.workspace = true
1414
anyhow = "1.0.95"
15-
gix = { workspace = true, features = ["dirwalk", "credentials", "parallel"] }
15+
gix = { workspace = true, features = ["dirwalk", "credentials", "parallel", "serde", "status"] }
1616
walkdir = "2.5.0"
1717
toml.workspace = true

0 commit comments

Comments
 (0)