@@ -23,9 +23,18 @@ pub enum LockfileChange {
23
23
WithContent ( Vec < u8 > ) ,
24
24
}
25
25
26
+ #[ derive( Debug , PartialEq , Eq ) ]
27
+ pub enum AllPackageChangeReason {
28
+ DefaultGlobalFileChanged ,
29
+ LockfileChangeDetectionFailed ,
30
+ LockfileChangedWithoutDetails ,
31
+ RootInternalDepChanged ,
32
+ NonPackageFileChanged ,
33
+ }
34
+
26
35
#[ derive( Debug , PartialEq , Eq ) ]
27
36
pub enum PackageChanges {
28
- All ,
37
+ All ( AllPackageChangeReason ) ,
29
38
Some ( HashSet < WorkspacePackage > ) ,
30
39
}
31
40
@@ -62,39 +71,50 @@ impl<'a, PD: PackageChangeMapper> ChangeMapper<'a, PD> {
62
71
) -> Result < PackageChanges , ChangeMapError > {
63
72
if Self :: default_global_file_changed ( & changed_files) {
64
73
debug ! ( "global file changed" ) ;
65
- return Ok ( PackageChanges :: All ) ;
74
+ return Ok ( PackageChanges :: All (
75
+ AllPackageChangeReason :: DefaultGlobalFileChanged ,
76
+ ) ) ;
66
77
}
67
78
68
79
// get filtered files and add the packages that contain them
69
80
let filtered_changed_files = self . filter_ignored_files ( changed_files. iter ( ) ) ?;
70
- let PackageChanges :: Some ( mut changed_pkgs) =
71
- self . get_changed_packages ( filtered_changed_files. into_iter ( ) )
72
- else {
73
- return Ok ( PackageChanges :: All ) ;
74
- } ;
75
-
76
- match lockfile_change {
77
- Some ( LockfileChange :: WithContent ( content) ) => {
78
- // if we run into issues, don't error, just assume all packages have changed
79
- let Ok ( lockfile_changes) = self . get_changed_packages_from_lockfile ( content) else {
80
- debug ! ( "unable to determine lockfile changes, assuming all packages changed" ) ;
81
- return Ok ( PackageChanges :: All ) ;
82
- } ;
83
-
84
- debug ! (
85
- "found {} packages changed by lockfile" ,
86
- lockfile_changes. len( )
87
- ) ;
88
- changed_pkgs. extend ( lockfile_changes) ;
89
-
90
- Ok ( PackageChanges :: Some ( changed_pkgs) )
91
- }
92
- // We don't have the actual contents, so just invalidate everything
93
- Some ( LockfileChange :: Empty ) => {
94
- debug ! ( "no previous lockfile available, assuming all packages changed" ) ;
95
- Ok ( PackageChanges :: All )
81
+
82
+ match self . get_changed_packages ( filtered_changed_files. into_iter ( ) ) {
83
+ PackageChanges :: All ( reason) => Ok ( PackageChanges :: All ( reason) ) ,
84
+
85
+ PackageChanges :: Some ( mut changed_pkgs) => {
86
+ match lockfile_change {
87
+ Some ( LockfileChange :: WithContent ( content) ) => {
88
+ // if we run into issues, don't error, just assume all packages have changed
89
+ let Ok ( lockfile_changes) = self . get_changed_packages_from_lockfile ( content)
90
+ else {
91
+ debug ! (
92
+ "unable to determine lockfile changes, assuming all packages \
93
+ changed"
94
+ ) ;
95
+ return Ok ( PackageChanges :: All (
96
+ AllPackageChangeReason :: LockfileChangeDetectionFailed ,
97
+ ) ) ;
98
+ } ;
99
+ debug ! (
100
+ "found {} packages changed by lockfile" ,
101
+ lockfile_changes. len( )
102
+ ) ;
103
+ changed_pkgs. extend ( lockfile_changes) ;
104
+
105
+ Ok ( PackageChanges :: Some ( changed_pkgs) )
106
+ }
107
+
108
+ // We don't have the actual contents, so just invalidate everything
109
+ Some ( LockfileChange :: Empty ) => {
110
+ debug ! ( "no previous lockfile available, assuming all packages changed" ) ;
111
+ Ok ( PackageChanges :: All (
112
+ AllPackageChangeReason :: LockfileChangedWithoutDetails ,
113
+ ) )
114
+ }
115
+ None => Ok ( PackageChanges :: Some ( changed_pkgs) ) ,
116
+ }
96
117
}
97
- None => Ok ( PackageChanges :: Some ( changed_pkgs) ) ,
98
118
}
99
119
}
100
120
@@ -120,18 +140,19 @@ impl<'a, PD: PackageChangeMapper> ChangeMapper<'a, PD> {
120
140
// Internal root dependency changed so global hash has changed
121
141
PackageMapping :: Package ( pkg) if root_internal_deps. contains ( & pkg) => {
122
142
debug ! (
123
- "root internal dependency \" {}\" changed due to: {file:?}" ,
143
+ "{} changes root internal dependency: \" {}\" " ,
144
+ file. to_string( ) ,
124
145
pkg. name
125
146
) ;
126
- return PackageChanges :: All ;
147
+ return PackageChanges :: All ( AllPackageChangeReason :: RootInternalDepChanged ) ;
127
148
}
128
149
PackageMapping :: Package ( pkg) => {
129
- debug ! ( "package {pkg:?} changed due to {file:?}" ) ;
150
+ debug ! ( "{} changes \" {} \" " , file . to_string ( ) , pkg . name ) ;
130
151
changed_packages. insert ( pkg) ;
131
152
}
132
153
PackageMapping :: All => {
133
154
debug ! ( "all packages changed due to {file:?}" ) ;
134
- return PackageChanges :: All ;
155
+ return PackageChanges :: All ( AllPackageChangeReason :: NonPackageFileChanged ) ;
135
156
}
136
157
PackageMapping :: None => { }
137
158
}
0 commit comments