@@ -20,12 +20,22 @@ def approve_tests(polarion_project_id: str, added_ids: list[str]) -> dict[str, l
2020
2121
2222def remove_approved_tests (
23- polarion_project_id : str , branch : str , added_ids : list [str ] | None = None
23+ polarion_project_id : str ,
24+ branch : str | None = None ,
25+ previous_commit : str | None = None ,
26+ current_commit : str | None = None ,
27+ added_ids : list [str ] | None = None ,
2428) -> dict [str , list [str ]]:
2529 removed_polarions = {}
2630 added_ids = added_ids or []
2731 if removed_ids := set (
28- find_polarion_ids (polarion_project_id = polarion_project_id , string_to_match = "removed" , branch = branch )
32+ find_polarion_ids (
33+ polarion_project_id = polarion_project_id ,
34+ string_to_match = "removed" ,
35+ branch = branch ,
36+ previous_commit = previous_commit ,
37+ current_commit = current_commit ,
38+ )
2939 ) - set (added_ids ):
3040 LOGGER .info (f"Following polarion ids were removed: { removed_ids } " )
3141 removed_polarions = update_polarion_ids (
@@ -43,9 +53,12 @@ def remove_approved_tests(
4353 default = os .path .expanduser ("~/.config/python-utility-scripts/config.yaml" ),
4454)
4555@click .option ("--project-id" , "-p" , help = "Provide the polarion project id" )
46- @click .option ("--branch" , "-b" , help = "Provide the github remote branch to run against" , default = "origin/main" )
56+ @click .option ("--previous-commit" , "-p" , help = "Provide previous-commit to compare against" , required = True )
57+ @click .option ("--current-commit" , "-c" , help = "Provide current-commit to compare with" , required = True )
4758@click .option ("--verbose" , default = False , is_flag = True )
48- def polarion_approve_automate (config_file_path : str , project_id : str , branch : str , verbose : bool ) -> None :
59+ def polarion_approve_automate (
60+ config_file_path : str , project_id : str , previous_commit : str , current_commit : str , verbose : bool
61+ ) -> None :
4962 if verbose :
5063 LOGGER .setLevel (logging .DEBUG )
5164 # since the utilities are in apps.polarion.polarion_utils, we need to change log level
@@ -56,12 +69,21 @@ def polarion_approve_automate(config_file_path: str, project_id: str, branch: st
5669 config_file_path = config_file_path , util_name = "pyutils-polarion-set-automated"
5770 )
5871 added_polarions = {}
59- if added_ids := find_polarion_ids (polarion_project_id = polarion_project_id , string_to_match = "added" , branch = branch ):
72+ if added_ids := find_polarion_ids (
73+ polarion_project_id = polarion_project_id ,
74+ string_to_match = "added" ,
75+ branch = None ,
76+ previous_commit = previous_commit ,
77+ current_commit = current_commit ,
78+ ):
6079 added_polarions = approve_tests (polarion_project_id = polarion_project_id , added_ids = added_ids )
6180 LOGGER .debug (f"Following polarion ids were marked automated and approved: { added_polarions .get ('updated' )} " )
6281
6382 removed_polarions = remove_approved_tests (
64- polarion_project_id = polarion_project_id , added_ids = added_ids , branch = branch
83+ polarion_project_id = polarion_project_id ,
84+ added_ids = added_ids ,
85+ previous_commit = previous_commit ,
86+ current_commit = current_commit ,
6587 )
6688 if removed_polarions .get ("failed" ) or added_polarions .get ("failed" ):
6789 error = "Following polarion ids updates failed."
0 commit comments