|
3 | 3 |
|
4 | 4 | from patchwork.logger import logger |
5 | 5 | from patchwork.step import Step, StepStatus |
| 6 | +from patchwork.steps.PreparePR.typed import PreparePRInputs, PreparePROutputs |
6 | 7 |
|
7 | 8 |
|
8 | | -class PreparePR(Step): |
9 | | - required_keys = {"modified_code_files"} |
| 9 | +class PreparePR(Step, input_class=PreparePRInputs, output_class=PreparePROutputs): |
10 | 10 |
|
11 | 11 | def __init__(self, inputs: dict): |
12 | 12 | super().__init__(inputs) |
13 | | - if not all(key in inputs.keys() for key in self.required_keys): |
14 | | - raise ValueError(f'Missing required data: "{self.required_keys}"') |
15 | | - |
16 | | - if len(inputs["modified_code_files"]) < 1: |
17 | | - logger.warning("No modified files to prepare a PR for.") |
18 | 13 | self.modified_code_files = inputs["modified_code_files"] |
| 14 | + if len(self.modified_code_files) < 1: |
| 15 | + logger.warning("No modified files to prepare a PR for.") |
19 | 16 |
|
20 | | - self.header = f"This pull request from patched fixes {len(self.modified_code_files)} issues." |
21 | | - if "pr_header" in inputs.keys(): |
22 | | - self.header = inputs["pr_header"] |
| 17 | + issue_url = inputs.get("issue_url") |
| 18 | + self.header = inputs.get("header") |
| 19 | + if self.header is None and issue_url is None: |
| 20 | + self.header = f"This pull request from patched fixes {len(self.modified_code_files)} issues." |
| 21 | + elif self.header is None and issue_url is not None: |
| 22 | + self.header = f"This pull request from patched fixes [issue]({issue_url})." |
23 | 23 |
|
24 | 24 | def run(self) -> dict: |
25 | 25 | if len(self.modified_code_files) == 0: |
|
0 commit comments