Expand description
Changes analysis command implementation.
This module implements the workspace changes command which analyzes changes in
the workspace to detect affected packages and their change statistics.
§What
Provides the execute_changes function that:
- Analyzes working directory changes (unstaged/staged/both)
- Analyzes commit range changes (between refs)
- Analyzes branch comparison changes
- Maps changed files to affected packages
- Calculates change statistics (lines added/deleted, files changed)
- Displays results in table or JSON format
§How
The command flow:
- Loads workspace configuration and sets up analyzers
- Opens Git repository for the workspace
- Determines analysis mode based on command arguments:
- Working directory: –staged, –unstaged, or both (default)
- Commit range: –since and –until
- Branch comparison: –branch
- Uses
ChangesAnalyzerfrom pkg tools to perform analysis - Filters results by –packages if specified
- Formats output as table (human) or JSON (automation)
§Analysis Modes
§Working Directory Mode (default)
- Analyzes uncommitted changes in the working tree
- Can filter to only staged (–staged) or unstaged (–unstaged)
- Default shows both staged and unstaged changes
§Commit Range Mode (–since / –until)
- Analyzes changes between two Git references
- –since: Starting reference (exclusive)
- –until: Ending reference (default: HEAD)
- Shows all commits and files changed in the range
§Branch Comparison Mode (–branch)
- Compares current branch against specified branch
- Shows changes that exist in current but not in target
- Useful for PR/MR review and planning
§Why
Change analysis is essential for:
- Understanding which packages are affected by changes
- Planning version bumps and releases
- CI/CD integration for affected package detection
- Code review and impact analysis
- Automated changeset creation
§Examples
use sublime_cli_tools::commands::changes::execute_changes;
use sublime_cli_tools::cli::commands::ChangesArgs;
use sublime_cli_tools::output::{Output, OutputFormat};
use std::io;
use std::path::Path;
// Analyze working directory changes
let args = ChangesArgs {
since: None,
until: None,
branch: None,
staged: false,
unstaged: false,
packages: None,
};
let output = Output::new(OutputFormat::Human, io::stdout(), false);
execute_changes(&args, &output, Path::new("."), None).await?;Functions§
- execute_
changes - Execute the changes analysis command.