@@ -98,24 +98,30 @@ pub async fn bulk_check_hash_exists(
98
98
mongo_uri : & str ,
99
99
) -> Result < HashSet < String > , Box < dyn std:: error:: Error > > {
100
100
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
+ }
102
108
Ok ( existing_hashes)
103
109
}
104
110
105
111
pub async fn register_hash ( message : & str , mongo_uri : & str ) {
106
112
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
+ // }
119
125
}
120
126
pub fn print_error ( error : & str , error_code : i32 ) {
121
127
if error. to_lowercase ( ) . starts_with ( "warning" ) {
@@ -411,13 +417,38 @@ fn save_pr_branch_files(
411
417
Ok ( ( ) )
412
418
}
413
419
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
+
414
444
pub fn checkout (
415
445
clone_url : & str ,
416
446
clone_path : & str ,
417
447
base_branch : Option < & str > ,
418
448
pr_branch : Option < & str > ,
419
449
) -> Result < ( ) , Box < dyn std:: error:: Error > > {
420
450
// Step 1: Clone the repository
451
+ set_git_user_config ( ) ?;
421
452
let mut clone_cmd = Command :: new ( "git" ) ;
422
453
clone_cmd. arg ( "clone" ) . arg ( clone_url) . arg ( clone_path) ;
423
454
if let Some ( branch) = base_branch {
0 commit comments