-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.py
More file actions
59 lines (56 loc) · 1.85 KB
/
common.py
File metadata and controls
59 lines (56 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
commit_types: dict[str, str] = {
"build": "updating build configuration, development tools",
"chore": "updating grunt tasks etc.",
"ci": "updating deployment configuration",
"docs": "changes to documentation",
"fix": "patching a bug in the codebase",
"feat": "adding a new feature to the code",
"feat!": "adding a new feature that introduces breaking API change",
"hotfix": "updating a bug in production",
"perf": "updating code to make performance enhancements",
"refactor": "updating code without any functional change",
"revert": "updating code to earlier change",
"style": "formatting changes, missing semicolons, etc.",
"test": "for adding missing tests, refactoring tests; no production code change",
}
commit_types_title: str = "Valid conventional commit types are:"
commit_types_block: str = "\t" + "\n\t".join(
[f"{k.ljust(10)}{v}" for k, v in commit_types.items()]
)
commit_types_doc: str = f"""
{commit_types_title}
{commit_types_block}
"""
commit_types_doc_commented: str = "\n".join(
[
f"# {commit_types_title}",
"#" + commit_types_block.replace("\n", "\n#"),
]
)
commit_type_regex: str = f"(?:{'|'.join(commit_types.keys())})"
teams: list[str] = [
"T",
"L2",
"DAE",
"PDEV"
]
linear_ref: str = (
"(?:"
f"{'|'.join(t for t in teams)}"
"|"
r"[A-Z]{1,4}"
"|"
f"{'|'.join(t.lower() for t in teams)}"
"|"
r"[a-z]{1,4}"
")-[0-9]{1,5}"
)
valid_commit_regex: str = (
f"^{linear_ref}/{commit_type_regex}!?: |Merge .+|Revert .+|Bump version .+"
)
partial_branch_regex: str = f"({linear_ref})[-|_](.*)"
branch_regex: str = f"^(.*)/{partial_branch_regex}"
commit_msg_title_regex: str = f"^({commit_type_regex}!?):? (.*)"
commit_msg_issue_regex: str = f"^({linear_ref})/(.*)"
issue_regex: str = f"^{linear_ref}$"
prefix_regex: str = f"^({commit_type_regex})"