| 14 | |
| 15 | |
| 16 | class JiraSmartCz(BaseCommitizen): |
| 17 | def questions(self) -> list[CzQuestion]: |
| 18 | return [ |
| 19 | { |
| 20 | "type": "input", |
| 21 | "name": "message", |
| 22 | "message": "Git commit message (required):\n", |
| 23 | # 'validate': RequiredValidator, |
| 24 | "filter": lambda x: x.strip(), |
| 25 | }, |
| 26 | { |
| 27 | "type": "input", |
| 28 | "name": "issues", |
| 29 | "message": "Jira Issue ID(s) separated by spaces (required):\n", |
| 30 | # 'validate': RequiredValidator, |
| 31 | "filter": lambda x: x.strip(), |
| 32 | }, |
| 33 | { |
| 34 | "type": "input", |
| 35 | "name": "workflow", |
| 36 | "message": "Workflow command (testing, closed, etc.) (optional):\n", |
| 37 | "filter": lambda x: "#" + x.strip().replace(" ", "-") if x else "", |
| 38 | }, |
| 39 | { |
| 40 | "type": "input", |
| 41 | "name": "time", |
| 42 | "message": "Time spent (i.e. 3h 15m) (optional):\n", |
| 43 | "filter": lambda x: "#time " + x if x else "", |
| 44 | }, |
| 45 | { |
| 46 | "type": "input", |
| 47 | "name": "comment", |
| 48 | "message": "Jira comment (optional):\n", |
| 49 | "filter": lambda x: "#comment " + x if x else "", |
| 50 | }, |
| 51 | ] |
| 52 | |
| 53 | def message(self, answers: Mapping[str, str]) -> str: |
| 54 | return " ".join( |
| 55 | x |
| 56 | for k in ("message", "issues", "workflow", "time", "comment") |
| 57 | if (x := answers.get(k)) |
| 58 | ) |
| 59 | |
| 60 | def example(self) -> str: |
| 61 | return ( |
| 62 | "JRA-34 #comment corrected indent issue\n" |
| 63 | "JRA-35 #time 1w 2d 4h 30m Total work logged\n" |
| 64 | "JRA-123 JRA-234 JRA-345 #resolve\n" |
| 65 | "JRA-123 JRA-234 JRA-345 #resolve #time 2d 5h #comment Task completed " |
| 66 | "ahead of schedule" |
| 67 | ) |
| 68 | |
| 69 | def schema(self) -> str: |
| 70 | return "<ignored text> <ISSUE_KEY> <ignored text> #<COMMAND> <optional COMMAND_ARGUMENTS>" |
| 71 | |
| 72 | def schema_pattern(self) -> str: |
| 73 | return r".*[A-Z]{2,}\-[0-9]+( #| .* #).+( #.+)*" |
no outgoing calls