@@ -18,29 +18,29 @@ def ensure_somef_configured():
1818 return False
1919 return True
2020
21- def run_somef (repo_url , output_file , threshold ):
21+ def run_somef (repo_url , output_file , threshold , branch = None ):
2222 """Run SoMEF on a given repository and save results."""
23+ cmd = ["somef" , "describe" , "-r" , repo_url , "-o" , output_file , "-t" , str (threshold )]
24+ if branch :
25+ cmd .extend (["-b" , branch ])
2326 try :
24- subprocess .run (
25- ["somef" , "describe" , "-r" , repo_url , "-o" , output_file , "-t" , str (threshold )],
26- check = True
27- )
27+ subprocess .run (cmd , check = True )
2828 print (f"SoMEF finished for: { repo_url } " )
2929 return True
3030 except subprocess .CalledProcessError as e :
3131 print (f"Error running SoMEF for { repo_url } : { e } " )
3232 return False
3333
34- def run_somef_single (repo_url , output_dir = "somef_outputs" , threshold = 0.8 ):
34+ def run_somef_single (repo_url , output_dir = "somef_outputs" , threshold = 0.8 , branch = None ):
3535 """Run SoMEF for a single repository."""
3636 os .makedirs (output_dir , exist_ok = True )
3737 output_file = os .path .join (output_dir , "output_1.json" )
3838
3939 print (f"Running SoMEF for { repo_url } ..." )
40- success = run_somef (repo_url , output_file , threshold )
40+ success = run_somef (repo_url , output_file , threshold , branch )
4141 return output_dir if success else None
4242
43- def run_somef_batch (json_file , output_dir = "somef_outputs" , threshold = 0.8 ):
43+ def run_somef_batch (json_file , output_dir = "somef_outputs" , threshold = 0.8 , branch = None ):
4444 """Run SoMEF for all repositories listed in a JSON file."""
4545 os .makedirs (output_dir , exist_ok = True )
4646
@@ -58,7 +58,7 @@ def run_somef_batch(json_file, output_dir="somef_outputs", threshold=0.8):
5858 for idx , repo_url in enumerate (repos , start = 1 ):
5959 output_file = os .path .join (output_dir , f"{ base_name } _output_{ idx } .json" )
6060 print (f"[{ idx } /{ len (repos )} ] { repo_url } " )
61- run_somef (repo_url , output_file , threshold )
61+ run_somef (repo_url , output_file , threshold , branch )
6262
6363 print (f"Completed SoMEF for { base_name } . Results in { output_dir } " )
6464 return True
0 commit comments