File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,8 @@ pub enum PathFreshness {
190
190
///
191
191
/// `target_paths` should be a non-empty slice of paths (relative to `git_dir` or the
192
192
/// current working directory) whose modifications would invalidate the artifact.
193
+ /// Each path can also be a negative match, i.e. `:!foo`. This matches changes outside
194
+ /// the `foo` directory.
193
195
///
194
196
/// The function behaves differently in CI and outside CI.
195
197
///
Original file line number Diff line number Diff line change @@ -123,6 +123,30 @@ fn test_changes_in_previous_upstream() {
123
123
} ) ;
124
124
}
125
125
126
+ #[ test]
127
+ fn test_changes_negative_path ( ) {
128
+ git_test ( |ctx| {
129
+ let upstream = ctx. create_upstream_merge ( & [ "a" ] ) ;
130
+ ctx. create_branch ( "feature" ) ;
131
+ ctx. modify ( "b" ) ;
132
+ ctx. modify ( "d" ) ;
133
+ ctx. commit ( ) ;
134
+
135
+ assert_eq ! (
136
+ ctx. get_source( & [ ":!b" , ":!d" ] , CiEnv :: None ) ,
137
+ PathFreshness :: LastModifiedUpstream { upstream: upstream. clone( ) }
138
+ ) ;
139
+ assert_eq ! (
140
+ ctx. get_source( & [ ":!c" ] , CiEnv :: None ) ,
141
+ PathFreshness :: HasLocalModifications { upstream: upstream. clone( ) }
142
+ ) ;
143
+ assert_eq ! (
144
+ ctx. get_source( & [ ":!d" , ":!x" ] , CiEnv :: None ) ,
145
+ PathFreshness :: HasLocalModifications { upstream }
146
+ ) ;
147
+ } ) ;
148
+ }
149
+
126
150
struct GitCtx {
127
151
dir : tempfile:: TempDir ,
128
152
git_repo : String ,
@@ -203,9 +227,10 @@ impl GitCtx {
203
227
writeln ! ( file, "line" ) . unwrap ( ) ;
204
228
}
205
229
206
- fn commit ( & self ) {
230
+ fn commit ( & self ) -> String {
207
231
self . run_git ( & [ "add" , "." ] ) ;
208
232
self . run_git ( & [ "commit" , "-m" , "commit message" ] ) ;
233
+ self . get_current_commit ( )
209
234
}
210
235
211
236
fn switch_to_branch ( & self , name : & str ) {
You can’t perform that action at this time.
0 commit comments