@@ -334,5 +334,43 @@ public void CanNotRenameWhenRemoteWithSameNameExists()
334334 Assert . Throws < NameConflictException > ( ( ) => repo . Network . Remotes . Rename ( "origin" , "upstream" ) ) ;
335335 }
336336 }
337+
338+ [ Theory ]
339+ [ InlineData ( null , null , false ) ]
340+ [ InlineData ( null , false , false ) ]
341+ [ InlineData ( null , true , true ) ]
342+ [ InlineData ( false , null , false ) ]
343+ [ InlineData ( false , false , false ) ]
344+ [ InlineData ( false , true , true ) ]
345+ [ InlineData ( true , null , true ) ]
346+ [ InlineData ( true , false , false ) ]
347+ [ InlineData ( true , true , true ) ]
348+ public void ShoudlPruneOnFetchReflectsTheConfiguredSetting ( bool ? fetchPrune , bool ? remotePrune , bool expectedFetchPrune )
349+ {
350+ var path = SandboxStandardTestRepo ( ) ;
351+ var scd = BuildSelfCleaningDirectory ( ) ;
352+
353+ using ( var repo = new Repository ( path , BuildFakeConfigs ( scd ) ) )
354+ {
355+ Assert . Null ( repo . Config . Get < bool > ( "fetch.prune" ) ) ;
356+ Assert . Null ( repo . Config . Get < bool > ( "remote.origin.prune" ) ) ;
357+
358+ SetIfNotNull ( repo , "fetch.prune" , fetchPrune ) ;
359+ SetIfNotNull ( repo , "remote.origin.prune" , remotePrune ) ;
360+
361+ var remote = repo . Network . Remotes [ "origin" ] ;
362+ Assert . Equal ( expectedFetchPrune , remote . AutomaticallyPruneOnFetch ) ;
363+ }
364+ }
365+
366+ private void SetIfNotNull ( IRepository repo , string configName , bool ? value )
367+ {
368+ if ( ! value . HasValue )
369+ {
370+ return ;
371+ }
372+
373+ repo . Config . Set ( configName , value . Value ) ;
374+ }
337375 }
338376}
0 commit comments