File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed
Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -274,14 +274,14 @@ pub fn get_git_modified_files(
274274 let files = output_result ( git. args ( [ "diff-index" , "--name-status" , merge_base. trim ( ) ] ) ) ?
275275 . lines ( )
276276 . filter_map ( |f| {
277- let ( status, name) = f. trim ( ) . split_once ( char:: is_whitespace) . unwrap ( ) ;
277+ let ( status, name) = f. trim ( ) . split_once ( char:: is_whitespace) ?
278278 if status == "D" {
279279 None
280280 } else if Path :: new ( name) . extension ( ) . map_or ( extensions. is_empty ( ) , |ext| {
281281 // If there is no extension, we allow the path if `extensions` is empty
282282 // If there is an extension, we allow it if `extension` is empty or it contains the
283283 // extension.
284- extensions. is_empty ( ) || extensions . contains ( & ext. to_str ( ) . unwrap ( ) )
284+ extensions. is_empty ( ) || ext. to_str ( ) . map_or ( false , |ext_str| extensions . contains ( & ext_str ) )
285285 } ) {
286286 Some ( name. to_owned ( ) )
287287 } else {
Original file line number Diff line number Diff line change @@ -39,7 +39,13 @@ pub fn parse_stage0_file() -> Stage0 {
3939 continue ;
4040 }
4141
42- let ( key, value) = line. split_once ( '=' ) . unwrap ( ) ;
42+ let ( key, value) = match line. split_once ( '=' ) {
43+ Some ( ( k, v) ) => ( k, v) ,
44+ None => {
45+ println ! ( "Warning: Skipping malformed config line {}" , line) ;
46+ continue ;
47+ }
48+ } ;
4349
4450 match key {
4551 "dist_server" => stage0. config . dist_server = value. to_owned ( ) ,
Original file line number Diff line number Diff line change @@ -64,7 +64,13 @@ pub fn parse_gitmodules(target_dir: &Path) -> Vec<String> {
6464 let gitmodules = target_dir. join ( ".gitmodules" ) ;
6565 assert ! ( gitmodules. exists( ) , "'{}' file is missing." , gitmodules. display( ) ) ;
6666
67- let file = File :: open ( gitmodules) . unwrap ( ) ;
67+ let file = match File :: open ( & gitmodules) {
68+ Ok ( f) => f,
69+ Err ( _) => {
70+ eprintln ! ( "Warning: Could not open .gitmodules file at {}" , gitmodules. display( ) ) ;
71+ return Vec :: new ( ) ;
72+ }
73+ } ;
6874
6975 let mut submodules_paths = vec ! [ ] ;
7076 for line in BufReader :: new ( file) . lines ( ) . map_while ( Result :: ok) {
You can’t perform that action at this time.
0 commit comments