File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,8 @@ pub enum PathFreshness {
190190///
191191/// `target_paths` should be a non-empty slice of paths (relative to `git_dir` or the
192192/// 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.
193195///
194196/// The function behaves differently in CI and outside CI.
195197///
Original file line number Diff line number Diff line change @@ -123,6 +123,30 @@ fn test_changes_in_previous_upstream() {
123123 } ) ;
124124}
125125
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+
126150struct GitCtx {
127151 dir : tempfile:: TempDir ,
128152 git_repo : String ,
@@ -203,9 +227,10 @@ impl GitCtx {
203227 writeln ! ( file, "line" ) . unwrap ( ) ;
204228 }
205229
206- fn commit ( & self ) {
230+ fn commit ( & self ) -> String {
207231 self . run_git ( & [ "add" , "." ] ) ;
208232 self . run_git ( & [ "commit" , "-m" , "commit message" ] ) ;
233+ self . get_current_commit ( )
209234 }
210235
211236 fn switch_to_branch ( & self , name : & str ) {
You can’t perform that action at this time.
0 commit comments