@@ -153,7 +153,8 @@ pub fn git_update(repo_path: &Path, repo_url: &str, revision: Option<&str>) -> R
153
153
repo_path. display( )
154
154
)
155
155
} ) ?;
156
- return Ok ( ( ) ) ;
156
+
157
+ Ok ( ( ) )
157
158
}
158
159
159
160
fn random_remote_name ( ) -> String {
@@ -178,14 +179,14 @@ fn git_resolve_revision(repo_path: &Path, remote_name: &str, revision: &str) ->
178
179
. stderr ( Stdio :: null ( ) )
179
180
. stdout ( Stdio :: piped ( ) )
180
181
. spawn ( )
181
- . with_context ( || format ! ( "Failed to spawn" ) ) ?;
182
+ . with_context ( || "Failed to spawn" . to_string ( ) ) ?;
182
183
183
184
let stdout = child. stdout . take ( ) . expect ( "failed to capture stdout" ) ;
184
185
let reader = BufReader :: new ( stdout) ;
185
186
186
187
if let Some ( parts) = reader
187
188
. lines ( )
188
- . filter_map ( |line| line . ok ( ) )
189
+ . map_while ( Result :: ok )
189
190
. map ( |line| line. split ( "\t " ) . map ( String :: from) . collect :: < Vec < String > > ( ) )
190
191
. filter ( |parts| parts. len ( ) == 2 )
191
192
. find ( |parts| parts[ 1 ] == expected_tag_ref)
@@ -204,22 +205,22 @@ fn git_resolve_revision(repo_path: &Path, remote_name: &str, revision: &str) ->
204
205
let expected_branch_ref = format ! ( "refs/heads/{}" , revision) ;
205
206
let mut command = safe_command (
206
207
format ! (
207
- "git ls-remote --quiet --branches \" {}\" \" {}\" " ,
208
+ "git ls-remote --quiet \" {}\" \" {}\" " ,
208
209
remote_name, expected_branch_ref
209
210
) ,
210
211
repo_path,
211
212
) ?;
212
213
let mut child = command
213
214
. stdout ( Stdio :: piped ( ) )
214
215
. spawn ( )
215
- . with_context ( || format ! ( "Failed to spawn" ) ) ?;
216
+ . with_context ( || "Failed to spawn" . to_string ( ) ) ?;
216
217
217
218
let stdout = child. stdout . take ( ) . expect ( "failed to capture stdout" ) ;
218
219
let reader = BufReader :: new ( stdout) ;
219
220
220
221
if let Some ( parts) = reader
221
222
. lines ( )
222
- . filter_map ( |line| line . ok ( ) )
223
+ . map_while ( Result :: ok )
223
224
. map ( |line| line. split ( "\t " ) . map ( String :: from) . collect :: < Vec < String > > ( ) )
224
225
. filter ( |parts| parts. len ( ) == 2 )
225
226
. find ( |parts| parts[ 1 ] == expected_branch_ref)
@@ -268,10 +269,10 @@ fn git_resolve_revision(repo_path: &Path, remote_name: &str, revision: &str) ->
268
269
269
270
let stdout = child. stdout . take ( ) . expect ( "failed to capture stdout" ) ;
270
271
let reader = BufReader :: new ( stdout) ;
271
- if let Some ( _ ) = reader
272
+ if reader
272
273
. lines ( )
273
- . filter_map ( |line| line . ok ( ) )
274
- . find ( |line| line. clone ( ) . starts_with ( & remote_branch_prefix) )
274
+ . map_while ( Result :: ok )
275
+ . any ( |line| line. clone ( ) . starts_with ( & remote_branch_prefix) )
275
276
{
276
277
// we found a remote ref that contains the commit sha
277
278
child. kill ( ) ?; // Abort the child process.
@@ -286,11 +287,11 @@ fn git_resolve_revision(repo_path: &Path, remote_name: &str, revision: &str) ->
286
287
)
287
288
} ) ?;
288
289
289
- return Err ( anyhow ! (
290
+ Err ( anyhow ! (
290
291
"cannot find revision {} in remote {}" ,
291
292
revision,
292
293
remote_name
293
- ) ) ;
294
+ ) )
294
295
}
295
296
296
297
fn safe_command ( command : String , cwd : & Path ) -> Result < Command , Error > {
@@ -408,7 +409,8 @@ pub fn get_all_scheme_file_paths(
408
409
file. path( ) . file_stem( ) ?. to_str( ) ?,
409
410
) ;
410
411
let scheme_file = SchemeFile :: new ( file. path ( ) . as_path ( ) ) . ok ( ) ?;
411
- return Some ( ( name, scheme_file) ) ;
412
+
413
+ Some ( ( name, scheme_file) )
412
414
} )
413
415
. collect :: < HashMap < String , SchemeFile > > ( ) ;
414
416
scheme_files. extend ( files) ;
0 commit comments