Skip to content

Commit 1ab2c00

Browse files
Address code review comments from PR #1518
This commit addresses the unresolved review comments from the merged PR that added the josh CLI tool: ## Error Handling Improvements - Add anyhow and thiserror to workspace dependencies - Replace Box<dyn std::error::Error> with anyhow::Result throughout josh-cli - Use anyhow::Context for better error messages with context ## josh-core/src/changes.rs Improvements - Use into_iter() instead of iter() where changes vec is consumed - Replace manual indexing with .windows(2) for cleaner iteration - Use iterator chaining with base_tree for tree collection - Use HashSet::insert() which returns false for duplicates - Improve variable naming: old -> base_oid, v -> push_refs - Change ref_with_options parameter from String to &str for consistency - Replace if let with match for better pattern matching - Use filter_map instead of filter + map ## josh-cli/src/bin/josh.rs Improvements - Remove all std::env::set_current_dir() calls (hacky global state) - Create internal helper functions that accept repo_path parameter: - handle_fetch_internal(args, repo_path) - handle_remote_add_internal(args, repo_path) - handle_filter_internal(args, repo_path, print_messages) - apply_josh_filtering(repo_path, filter, remote_name) - Remove commented out code - Update all error handling to use anyhow::Context - Fix build_to_push call to pass &remote_ref instead of remote_ref 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Vlad Ivanov <[email protected]>
1 parent 8620bb3 commit 1ab2c00

File tree

4 files changed

+187
-199
lines changed

4 files changed

+187
-199
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ opt-level = 3
2020
codegen-units = 1
2121

2222
[workspace.dependencies]
23+
anyhow = "1.0"
2324
base64 = "0.22.1"
2425
defer = "0.2.1"
2526
env_logger = "0.11.5"
@@ -34,6 +35,7 @@ rs_tracing = { version = "1.1.0", features = ["rs_tracing"] }
3435
serde = { version = "1.0.228", features = ["std", "derive"] }
3536
serde_json = "1.0.145"
3637
serde_yaml = "0.9.34"
38+
thiserror = "2.0"
3739
toml = "0.9.8"
3840
tracing-subscriber = { version = "0.3.20", features = ["env-filter"] }
3941
tempfile = "3.23.0"

josh-cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ version = "22.4.15"
1313
josh = { path = "../josh-core" }
1414
josh-graphql = { path = "../josh-graphql" }
1515
josh-templates = { path = "../josh-templates" }
16+
anyhow = { workspace = true }
1617
env_logger = { workspace = true }
1718
log = { workspace = true }
1819
serde_json = { workspace = true }

0 commit comments

Comments
 (0)