@@ -105,8 +105,10 @@ public void RemoteUpdaterSavesRefSpecsPermanently()
105
105
106
106
using ( var repo = new Repository ( path ) )
107
107
{
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
+ }
110
112
}
111
113
112
114
using ( var repo = new Repository ( path ) )
@@ -127,22 +129,23 @@ public void CanAddAndRemoveRefSpecs()
127
129
var path = SandboxStandardTestRepo ( ) ;
128
130
129
131
using ( var repo = new Repository ( path ) )
132
+ using ( var remote = repo . Network . Remotes [ "origin" ] )
130
133
{
131
- var remote = repo . Network . Remotes [ "origin" ] ;
132
-
133
- remote = repo . Network . Remotes . Update ( remote ,
134
+ using ( var updatedRemote = repo . Network . Remotes . Update ( remote ,
134
135
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
+ }
146
149
}
147
150
}
148
151
0 commit comments