Skip to content
Merged
Show file tree
Hide file tree
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
263 changes: 134 additions & 129 deletions Cargo.lock

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ repository = "https://github.com/lettertwo/git-workon"
rust-version = "1.68.2"

[workspace.dependencies]
assert_cmd = { version = "2.0.14", features = ["color", "color-auto"] }
assert_fs = { version = "1.1.1", features = ["color", "color-auto"] }
clap = { version = "4.5.59", features = [
assert_cmd = { version = "2.1.2", features = ["color", "color-auto"] }
assert_fs = { version = "1.1.3", features = ["color", "color-auto"] }
clap = { version = "4.5.60", features = [
"derive",
"color",
"wrap_help",
Expand All @@ -24,8 +24,8 @@ clap = { version = "4.5.59", features = [
clap-verbosity-flag = "3.0.4"
clap_complete = { version = "4.5.66", features = ["unstable-dynamic"] }
clap_mangen = "0.2.31"
dialoguer = { version = "0.11.0", features = ["fuzzy-select"] }
env_logger = "0.11.3"
dialoguer = { version = "0.12.0", features = ["fuzzy-select"] }
env_logger = "0.11.6"
git-workon-lib = { version = "0.1.0", path = "./git-workon-lib" }
git-workon-fixture = { version = "0.1.0", path = "./git-workon-fixture" }
git2_credentials = { version = "0.15.0", features = ["ui4dialoguer"] }
Expand All @@ -34,13 +34,16 @@ git2 = { version = "0.20.4", default-features = false, features = [
"https",
] }
glob = "0.3"
log = "0.4.17"
miette = { version = "7.2.0", features = ["fancy"] }
log = "0.4.29"
miette = { version = "7.6.0", features = ["fancy"] }
owo-colors = "4"
predicates = { version = "3.1.0" }
predicates = { version = "3.1.4" }
supports-color = "3"
expectrl = "0.8"
pathdiff = "0.2.3"
serde_json = "1.0"
thiserror = "2.0.12"
thiserror = "2.0.18"
unicode-width = "0.2.2"

# The profile that 'dist' will build with
[profile.dist]
Expand Down
6 changes: 3 additions & 3 deletions git-workon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ log.workspace = true
miette.workspace = true
serde_json.workspace = true
owo-colors.workspace = true
pathdiff = "0.2.3"
pathdiff.workspace = true
supports-color.workspace = true
unicode-width = "0.2.2"
unicode-width.workspace = true

[dev-dependencies]
assert_cmd.workspace = true
assert_fs.workspace = true
git2.workspace = true
git-workon-fixture.workspace = true
expectrl = "0.7"
expectrl.workspace = true
predicates.workspace = true

[build-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions git-workon/tests/clone.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use assert_cmd::Command;
use assert_cmd::cargo_bin_cmd;
use assert_fs::TempDir;
use git2::Repository;
use git_workon_fixture::prelude::*;
Expand All @@ -15,7 +15,7 @@ fn clone_default() -> Result<(), Box<dyn std::error::Error>> {
let clone_dest = TempDir::new()?;

// Clone the remote repository
let mut cmd = Command::cargo_bin("git-workon")?;
let mut cmd = cargo_bin_cmd!("git-workon");
cmd.current_dir(&clone_dest)
.arg("clone")
.arg(remote.cwd()?.to_str().unwrap())
Expand Down Expand Up @@ -59,7 +59,7 @@ fn clone_with_name() -> Result<(), Box<dyn std::error::Error>> {
let temp = TempDir::new()?;

// Clone the remote repository with a custom directory name
let mut cmd = Command::cargo_bin("git-workon")?;
let mut cmd = cargo_bin_cmd!("git-workon");
cmd.current_dir(&temp)
.arg("clone")
.arg(remote.cwd()?.to_str().unwrap())
Expand Down
20 changes: 10 additions & 10 deletions git-workon/tests/copy_untracked.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use assert_cmd::Command;
use assert_cmd::cargo_bin_cmd;
use git_workon_fixture::prelude::*;
use std::fs;

Expand All @@ -24,7 +24,7 @@ fn copy_basic() -> Result<(), Box<dyn std::error::Error>> {
)?;

// Copy files from main to feature (uses config patterns)
let mut cmd = Command::cargo_bin("git-workon")?;
let mut cmd = cargo_bin_cmd!("git-workon");
cmd.current_dir(&fixture)
.arg("copy-untracked")
.arg("main")
Expand Down Expand Up @@ -70,7 +70,7 @@ fn copy_with_config_patterns() -> Result<(), Box<dyn std::error::Error>> {
fs::write(main_worktree.join("build/output.js"), "build output")?;

// Copy using config patterns (default behavior)
let mut cmd = Command::cargo_bin("git-workon")?;
let mut cmd = cargo_bin_cmd!("git-workon");
cmd.current_dir(&fixture)
.arg("copy-untracked")
.arg("main")
Expand Down Expand Up @@ -117,7 +117,7 @@ fn copy_with_excludes() -> Result<(), Box<dyn std::error::Error>> {
fs::write(main_worktree.join("temp/cache.dat"), "cached data")?;

// Copy all files using config pattern
let mut cmd = Command::cargo_bin("git-workon")?;
let mut cmd = cargo_bin_cmd!("git-workon");
cmd.current_dir(&fixture)
.arg("copy-untracked")
.arg("main")
Expand Down Expand Up @@ -160,7 +160,7 @@ fn copy_with_pattern_override() -> Result<(), Box<dyn std::error::Error>> {
fs::write(main_worktree.join("app.js"), "app code")?;

// Copy with --pattern flag (should override config)
let mut cmd = Command::cargo_bin("git-workon")?;
let mut cmd = cargo_bin_cmd!("git-workon");
cmd.current_dir(&fixture)
.arg("copy-untracked")
.arg("--pattern")
Expand Down Expand Up @@ -201,7 +201,7 @@ fn copy_respects_force_flag() -> Result<(), Box<dyn std::error::Error>> {
fs::write(feature_worktree.join("data.txt"), "feature version")?;

// Copy without --force (should skip existing file)
let mut cmd = Command::cargo_bin("git-workon")?;
let mut cmd = cargo_bin_cmd!("git-workon");
let output = cmd
.current_dir(&fixture)
.arg("copy-untracked")
Expand All @@ -219,7 +219,7 @@ fn copy_respects_force_flag() -> Result<(), Box<dyn std::error::Error>> {
);

// Now copy with --force (should overwrite)
let mut cmd2 = Command::cargo_bin("git-workon")?;
let mut cmd2 = cargo_bin_cmd!("git-workon");
cmd2.current_dir(&fixture)
.arg("copy-untracked")
.arg("--force")
Expand Down Expand Up @@ -255,7 +255,7 @@ fn copy_creates_directories() -> Result<(), Box<dyn std::error::Error>> {
)?;

// Copy files
let mut cmd = Command::cargo_bin("git-workon")?;
let mut cmd = cargo_bin_cmd!("git-workon");
cmd.current_dir(&fixture)
.arg("copy-untracked")
.arg("main")
Expand Down Expand Up @@ -296,7 +296,7 @@ fn copy_with_no_matching_files() -> Result<(), Box<dyn std::error::Error>> {
fs::write(main_worktree.join("readme.txt"), "readme")?;

// Try to copy with non-matching pattern
let mut cmd = Command::cargo_bin("git-workon")?;
let mut cmd = cargo_bin_cmd!("git-workon");
let output = cmd
.current_dir(&fixture)
.arg("copy-untracked")
Expand Down Expand Up @@ -338,7 +338,7 @@ fn copy_without_config_defaults_to_all() -> Result<(), Box<dyn std::error::Error
fs::write(main_worktree.join("src/main.rs"), "fn main() {}")?;

// Copy without config or pattern (should copy everything)
let mut cmd = Command::cargo_bin("git-workon")?;
let mut cmd = cargo_bin_cmd!("git-workon");
cmd.current_dir(&fixture)
.arg("copy-untracked")
.arg("main")
Expand Down
12 changes: 6 additions & 6 deletions git-workon/tests/doctor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use assert_cmd::Command;
use assert_cmd::cargo_bin_cmd;
use git_workon_fixture::prelude::*;

#[test]
Expand All @@ -10,7 +10,7 @@ fn doctor_healthy_worktrees() -> Result<(), Box<dyn std::error::Error>> {
.build()?;

// Doctor should succeed and report no worktree-level issues
let output = Command::cargo_bin("git-workon")?
let output = cargo_bin_cmd!("git-workon")
.current_dir(&fixture)
.arg("doctor")
.output()?;
Expand Down Expand Up @@ -44,7 +44,7 @@ fn doctor_detects_missing_directory() -> Result<(), Box<dyn std::error::Error>>

// Run doctor from the main worktree
let main_path = fixture.root()?.join("main");
Command::cargo_bin("git-workon")?
cargo_bin_cmd!("git-workon")
.current_dir(&main_path)
.arg("doctor")
.assert()
Expand All @@ -69,7 +69,7 @@ fn doctor_fix_missing_directory() -> Result<(), Box<dyn std::error::Error>> {

// Run doctor --fix from the main worktree
let main_path = fixture.root()?.join("main");
Command::cargo_bin("git-workon")?
cargo_bin_cmd!("git-workon")
.current_dir(&main_path)
.arg("doctor")
.arg("--fix")
Expand Down Expand Up @@ -103,7 +103,7 @@ fn doctor_dry_run_does_not_fix() -> Result<(), Box<dyn std::error::Error>> {

// Run doctor --dry-run from the main worktree
let main_path = fixture.root()?.join("main");
Command::cargo_bin("git-workon")?
cargo_bin_cmd!("git-workon")
.current_dir(&main_path)
.arg("doctor")
.arg("--dry-run")
Expand Down Expand Up @@ -136,7 +136,7 @@ fn doctor_json_output() -> Result<(), Box<dyn std::error::Error>> {
std::fs::remove_dir_all(&feature_path)?;

let main_path = fixture.root()?.join("main");
let output = Command::cargo_bin("git-workon")?
let output = cargo_bin_cmd!("git-workon")
.current_dir(&main_path)
.arg("doctor")
.arg("--json")
Expand Down
26 changes: 15 additions & 11 deletions git-workon/tests/find.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use std::path::{Path, PathBuf};
use std::time::Duration;

use assert_cmd::Command;
use assert_cmd::cargo_bin_cmd;
use expectrl::{
session::{OsProcess, OsStream},
Expect, Session,
};
use git_workon_fixture::prelude::*;

#[test]
Expand All @@ -12,7 +16,7 @@ fn find_exact_match() -> Result<(), Box<dyn std::error::Error>> {
.worktree("feature")
.build()?;

Command::cargo_bin("git-workon")?
cargo_bin_cmd!("git-workon")
.current_dir(&fixture)
.arg("find")
.arg("feature")
Expand All @@ -31,7 +35,7 @@ fn find_no_match_errors() -> Result<(), Box<dyn std::error::Error>> {
.worktree("feature")
.build()?;

Command::cargo_bin("git-workon")?
cargo_bin_cmd!("git-workon")
.current_dir(&fixture)
.arg("find")
.arg("nonexistent")
Expand All @@ -52,7 +56,7 @@ fn find_multiple_fuzzy_matches_errors_with_no_interactive() -> Result<(), Box<dy
.worktree("feature-2")
.build()?;

Command::cargo_bin("git-workon")?
cargo_bin_cmd!("git-workon")
.current_dir(&fixture)
.arg("find")
.arg("feature")
Expand All @@ -72,7 +76,7 @@ fn find_no_name_errors_with_no_interactive() -> Result<(), Box<dyn std::error::E
.worktree("feature")
.build()?;

Command::cargo_bin("git-workon")?
cargo_bin_cmd!("git-workon")
.current_dir(&fixture)
.arg("find")
.arg("--no-interactive")
Expand All @@ -99,7 +103,7 @@ fn find_with_dirty_filter() -> Result<(), Box<dyn std::error::Error>> {
)?;

// Should find dirty when searching with --dirty
Command::cargo_bin("git-workon")?
cargo_bin_cmd!("git-workon")
.current_dir(&fixture)
.arg("find")
.arg("dirty")
Expand All @@ -108,7 +112,7 @@ fn find_with_dirty_filter() -> Result<(), Box<dyn std::error::Error>> {
.success();

// Should NOT find clean with --dirty filter
Command::cargo_bin("git-workon")?
cargo_bin_cmd!("git-workon")
.current_dir(&fixture)
.arg("find")
.arg("clean")
Expand All @@ -127,7 +131,7 @@ fn find_all_filtered_out_errors() -> Result<(), Box<dyn std::error::Error>> {
.worktree("clean")
.build()?;

Command::cargo_bin("git-workon")?
cargo_bin_cmd!("git-workon")
.current_dir(&fixture)
.arg("find")
.arg("--dirty")
Expand All @@ -149,7 +153,7 @@ fn find_single_fuzzy_match_returns_directly() -> Result<(), Box<dyn std::error::
.build()?;

// "feature" matches only "feature-branch" → return without interaction
Command::cargo_bin("git-workon")?
cargo_bin_cmd!("git-workon")
.current_dir(&fixture)
.arg("find")
.arg("feature")
Expand All @@ -169,7 +173,7 @@ fn find_case_insensitive_fuzzy_match() -> Result<(), Box<dyn std::error::Error>>
.build()?;

// "feature" should match "Feature-Branch" (case-insensitive)
Command::cargo_bin("git-workon")?
cargo_bin_cmd!("git-workon")
.current_dir(&fixture)
.arg("find")
.arg("feature")
Expand All @@ -188,7 +192,7 @@ fn cargo_bin_path() -> PathBuf {
PathBuf::from(env!("CARGO_BIN_EXE_git-workon"))
}

fn spawn_interactive(cwd: &Path, args: &[&str]) -> expectrl::Session {
fn spawn_interactive(cwd: &Path, args: &[&str]) -> Session<OsProcess, OsStream> {
let mut cmd = std::process::Command::new(cargo_bin_path());
cmd.current_dir(cwd);
for arg in args {
Expand Down
Loading