@@ -98,24 +98,30 @@ pub async fn bulk_check_hash_exists(
9898 mongo_uri : & str ,
9999) -> Result < HashSet < String > , Box < dyn std:: error:: Error > > {
100100 let client = connect_to_mongodb ( mongo_uri, "code-security-open-source" ) . await ?;
101- let existing_hashes = find_messages_in_hashes ( & client, hashes) . await ?;
101+ // let existing_hashes = find_messages_in_hashes(&client, hashes).await?;
102+ // returb blank HashSet if no hashes found
103+ let existing_hashes = HashSet :: new ( ) ;
104+ let blank_hashset = HashSet :: new ( ) ;
105+ if existing_hashes. is_empty ( ) {
106+ return Ok ( blank_hashset) ;
107+ }
102108 Ok ( existing_hashes)
103109}
104110
105111pub async fn register_hash ( message : & str , mongo_uri : & str ) {
106112 let hashed_message = hash_text ( message) ;
107- match connect_to_mongodb ( mongo_uri, "code-security-open-source" ) . await {
108- Ok ( client) => {
109- let collection = client
110- . database ( "code-security-open-source" )
111- . collection ( "hashes" ) ;
112- let document = doc ! { "message" : hashed_message } ;
113- collection. insert_one ( document, None ) . await . unwrap ( ) ;
114- }
115- Err ( e) => {
116- print_error ( & format ! ( "Error: {}" , e. to_string( ) ) , 101 ) ;
117- }
118- }
113+ // match connect_to_mongodb(mongo_uri, "code-security-open-source").await {
114+ // Ok(client) => {
115+ // let collection = client
116+ // .database("code-security-open-source")
117+ // .collection("hashes");
118+ // let document = doc! { "message": hashed_message };
119+ // collection.insert_one(document, None).await.unwrap();
120+ // }
121+ // Err(e) => {
122+ // print_error(&format!("Error: {}", e.to_string()), 101);
123+ // }
124+ // }
119125}
120126pub fn print_error ( error : & str , error_code : i32 ) {
121127 if error. to_lowercase ( ) . starts_with ( "warning" ) {
@@ -411,13 +417,38 @@ fn save_pr_branch_files(
411417 Ok ( ( ) )
412418}
413419
420+ fn set_git_user_config ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
421+ let email_output = Command :: new ( "git" )
422+ . args ( & [ "config" , "--get" , "user.email" ] )
423+ . output ( ) ?;
424+ if !email_output. status . success ( ) {
425+ // Set default email if not already configured
426+ Command :: new ( "git" )
427+ . args ( & [ "config" , "--local" , "user.email" , "[email protected] " ] ) 428+ . output ( ) ?;
429+ }
430+
431+ let name_output = Command :: new ( "git" )
432+ . args ( & [ "config" , "--get" , "user.name" ] )
433+ . output ( ) ?;
434+ if !name_output. status . success ( ) {
435+ // Set default name if not already configured
436+ Command :: new ( "git" )
437+ . args ( & [ "config" , "--local" , "user.name" , "Temporary User" ] )
438+ . output ( ) ?;
439+ }
440+
441+ Ok ( ( ) )
442+ }
443+
414444pub fn checkout (
415445 clone_url : & str ,
416446 clone_path : & str ,
417447 base_branch : Option < & str > ,
418448 pr_branch : Option < & str > ,
419449) -> Result < ( ) , Box < dyn std:: error:: Error > > {
420450 // Step 1: Clone the repository
451+ set_git_user_config ( ) ?;
421452 let mut clone_cmd = Command :: new ( "git" ) ;
422453 clone_cmd. arg ( "clone" ) . arg ( clone_url) . arg ( clone_path) ;
423454 if let Some ( branch) = base_branch {
0 commit comments