@@ -105,8 +105,10 @@ public void RemoteUpdaterSavesRefSpecsPermanently()
105105
106106 using ( var repo = new Repository ( path ) )
107107 {
108- var remote = repo . Network . Remotes [ "origin" ] ;
109- repo . Network . Remotes . Update ( remote , r => r . FetchRefSpecs = fetchRefSpecs ) ;
108+ using ( var remote = repo . Network . Remotes [ "origin" ] )
109+ {
110+ repo . Network . Remotes . Update ( remote , r => r . FetchRefSpecs = fetchRefSpecs ) ;
111+ }
110112 }
111113
112114 using ( var repo = new Repository ( path ) )
@@ -127,22 +129,23 @@ public void CanAddAndRemoveRefSpecs()
127129 var path = SandboxStandardTestRepo ( ) ;
128130
129131 using ( var repo = new Repository ( path ) )
132+ using ( var remote = repo . Network . Remotes [ "origin" ] )
130133 {
131- var remote = repo . Network . Remotes [ "origin" ] ;
132-
133- remote = repo . Network . Remotes . Update ( remote ,
134+ using ( var updatedRemote = repo . Network . Remotes . Update ( remote ,
134135 r => r . FetchRefSpecs . Add ( newRefSpec ) ,
135- r => r . PushRefSpecs . Add ( newRefSpec ) ) ;
136-
137- Assert . Contains ( newRefSpec , remote . FetchRefSpecs . Select ( r => r . Specification ) ) ;
138- Assert . Contains ( newRefSpec , remote . PushRefSpecs . Select ( r => r . Specification ) ) ;
139-
140- remote = repo . Network . Remotes . Update ( remote ,
141- r => r . FetchRefSpecs . Remove ( newRefSpec ) ,
142- r => r . PushRefSpecs . Remove ( newRefSpec ) ) ;
143-
144- Assert . DoesNotContain ( newRefSpec , remote . FetchRefSpecs . Select ( r => r . Specification ) ) ;
145- Assert . DoesNotContain ( newRefSpec , remote . PushRefSpecs . Select ( r => r . Specification ) ) ;
136+ r => r . PushRefSpecs . Add ( newRefSpec ) ) )
137+ {
138+ Assert . Contains ( newRefSpec , updatedRemote . FetchRefSpecs . Select ( r => r . Specification ) ) ;
139+ Assert . Contains ( newRefSpec , updatedRemote . PushRefSpecs . Select ( r => r . Specification ) ) ;
140+
141+ using ( var updatedRemote2 = repo . Network . Remotes . Update ( updatedRemote ,
142+ r => r . FetchRefSpecs . Remove ( newRefSpec ) ,
143+ r => r . PushRefSpecs . Remove ( newRefSpec ) ) )
144+ {
145+ Assert . DoesNotContain ( newRefSpec , updatedRemote2 . FetchRefSpecs . Select ( r => r . Specification ) ) ;
146+ Assert . DoesNotContain ( newRefSpec , updatedRemote2 . PushRefSpecs . Select ( r => r . Specification ) ) ;
147+ }
148+ }
146149 }
147150 }
148151
0 commit comments