@@ -20,12 +20,22 @@ def approve_tests(polarion_project_id: str, added_ids: list[str]) -> dict[str, l
20
20
21
21
22
22
def 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 ,
24
28
) -> dict [str , list [str ]]:
25
29
removed_polarions = {}
26
30
added_ids = added_ids or []
27
31
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
+ )
29
39
) - set (added_ids ):
30
40
LOGGER .info (f"Following polarion ids were removed: { removed_ids } " )
31
41
removed_polarions = update_polarion_ids (
@@ -43,9 +53,12 @@ def remove_approved_tests(
43
53
default = os .path .expanduser ("~/.config/python-utility-scripts/config.yaml" ),
44
54
)
45
55
@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 )
47
58
@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 :
49
62
if verbose :
50
63
LOGGER .setLevel (logging .DEBUG )
51
64
# 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
56
69
config_file_path = config_file_path , util_name = "pyutils-polarion-set-automated"
57
70
)
58
71
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
+ ):
60
79
added_polarions = approve_tests (polarion_project_id = polarion_project_id , added_ids = added_ids )
61
80
LOGGER .debug (f"Following polarion ids were marked automated and approved: { added_polarions .get ('updated' )} " )
62
81
63
82
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 ,
65
87
)
66
88
if removed_polarions .get ("failed" ) or added_polarions .get ("failed" ):
67
89
error = "Following polarion ids updates failed."
0 commit comments