1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//! Changes analysis module for detecting and analyzing file and commit changes.
//!
//! **What**: Provides comprehensive analysis of file changes and commits in both single-package
//! and monorepo configurations, mapping changes to affected packages.
//!
//! **How**: This module integrates with Git to analyze working directory changes and commit ranges,
//! maps changed files to their respective packages, and calculates version impacts based on
//! changeset information.
//!
//! **Why**: To enable accurate detection of which packages are affected by changes and to provide
//! detailed information about what changed, supporting informed version bumping and changelog generation.
//!
//! # Features
//!
//! - **Working Directory Analysis**: Analyze uncommitted changes in the working directory
//! - **Commit Range Analysis**: Analyze changes between two Git commits or refs
//! - **Package Mapping**: Map changed files to their containing packages
//! - **Commit Association**: Associate commits with the packages they affect
//! - **Version Preview**: Calculate next versions based on changeset and changes
//! - **Change Statistics**: Provide detailed statistics about changes (files, lines, commits)
//! - **Multi-Package Support**: Handle both single-package and monorepo structures
//! - **Change Filtering**: Filter changes by type, package, or directory
//!
//! # Example
//!
//! ```rust,ignore
//! use sublime_pkg_tools::changes::ChangesAnalyzer;
//! use sublime_pkg_tools::config::PackageToolsConfig;
//! use sublime_git_tools::Repo;
//! use sublime_standard_tools::filesystem::FileSystemManager;
//! use std::path::PathBuf;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let workspace_root = PathBuf::from(".");
//! let fs = FileSystemManager::new();
//! let config = PackageToolsConfig::default();
//! let git_repo = Repo::open(".")?;
//!
//! let analyzer = ChangesAnalyzer::new(workspace_root, git_repo, fs, config).await?;
//!
//! // Analyze working directory changes
//! let changes = analyzer.analyze_working_directory().await?;
//! for package_change in changes.packages {
//! println!("Package: {}", package_change.package_name());
//! println!(" Files changed: {}", package_change.files.len());
//! println!(" Has changes: {}", package_change.has_changes);
//! }
//!
//! // Analyze commit range
//! let changes = analyzer.analyze_commit_range("main", "HEAD").await?;
//! println!("Total packages affected: {}", changes.summary.packages_with_changes);
//! # Ok(())
//! # }
//! ```
//!
//! # Change Types
//!
//! The module tracks different types of file changes:
//! - **Added**: New files created
//! - **Modified**: Existing files changed
//! - **Deleted**: Files removed
//! - **Renamed**: Files moved or renamed
//! - **Copied**: Files copied to new locations
//!
//! # Integration with Changesets
//!
//! This module can be used in conjunction with changesets to provide comprehensive
//! version impact analysis:
//!
//! ```rust,ignore
//! # use sublime_pkg_tools::changes::ChangesAnalyzer;
//! # use sublime_pkg_tools::changeset::ChangesetManager;
//! # use sublime_pkg_tools::config::PackageToolsConfig;
//! # use sublime_git_tools::Repo;
//! # use sublime_standard_tools::filesystem::FileSystemManager;
//! # use std::path::PathBuf;
//! #
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! # let workspace_root = PathBuf::from(".");
//! # let fs = FileSystemManager::new();
//! # let config = PackageToolsConfig::default();
//! # let git_repo = Repo::open(".")?;
//! let analyzer = ChangesAnalyzer::new(workspace_root.clone(), git_repo.clone(), fs.clone(), config.clone()).await?;
//! let changeset_manager = ChangesetManager::new(workspace_root, fs, config).await?;
//!
//! let changeset = changeset_manager.load("my-changeset").await?;
//! let changes = analyzer.analyze_with_versions("main", "HEAD", &changeset).await?;
//!
//! for package_change in &changes.packages {
//! if let (Some(current), Some(next)) = (&package_change.current_version, &package_change.next_version) {
//! println!("Package: {} -> {}", current, next);
//! }
//! }
//! # Ok(())
//! # }
//! ```
//!
//! # Module Structure
//!
//! This module will contain:
//! - `analyzer`: The main `ChangesAnalyzer` for orchestrating change analysis
//! - `package_changes`: Per-package change information and statistics
//! - `file_change`: Individual file change details
//! - `commit_info`: Commit information and metadata
//! - `stats`: Change statistics and summaries
// Analyzer module - Story 7.1
pub use ChangesAnalyzer;
// Mapping module - Story 7.2
pub use PackageMapper;
// Report types - Story 7.3
pub use ;
// Package changes - Story 7.3
pub use PackageChanges;
// File changes - Story 7.3
pub use ;
// Commit info - Story 7.3 (minimal implementation)
pub use CommitInfo;
// Statistics - Story 7.3
pub use ;
// Tests module