diff options
Diffstat (limited to 'meta/lib/patchtest/patchtest_patterns.py')
-rw-r--r-- | meta/lib/patchtest/patchtest_patterns.py | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/meta/lib/patchtest/patchtest_patterns.py b/meta/lib/patchtest/patchtest_patterns.py new file mode 100644 index 0000000000..8c2e192fc9 --- /dev/null +++ b/meta/lib/patchtest/patchtest_patterns.py | |||
@@ -0,0 +1,96 @@ | |||
1 | # common pyparsing variables | ||
2 | # | ||
3 | # Copyright (C) 2016 Intel Corporation | ||
4 | # | ||
5 | # SPDX-License-Identifier: GPL-2.0-only | ||
6 | |||
7 | import pyparsing | ||
8 | import re | ||
9 | |||
10 | # general | ||
11 | colon = pyparsing.Literal(":") | ||
12 | line_start = pyparsing.LineStart() | ||
13 | line_end = pyparsing.LineEnd() | ||
14 | lessthan = pyparsing.Literal("<") | ||
15 | greaterthan = pyparsing.Literal(">") | ||
16 | inappropriate = pyparsing.CaselessLiteral("Inappropriate") | ||
17 | submitted = pyparsing.CaselessLiteral("Submitted") | ||
18 | |||
19 | # word related | ||
20 | nestexpr = pyparsing.nestedExpr(opener='[', closer=']') | ||
21 | inappropriateinfo = pyparsing.Literal("Inappropriate") + nestexpr | ||
22 | submittedinfo = pyparsing.Literal("Submitted") + nestexpr | ||
23 | word = pyparsing.Word(pyparsing.alphas) | ||
24 | worddot = pyparsing.Word(pyparsing.alphas+".") | ||
25 | |||
26 | # metadata | ||
27 | |||
28 | metadata_lic = 'LICENSE' | ||
29 | invalid_license = 'PATCHTESTINVALID' | ||
30 | metadata_chksum = 'LIC_FILES_CHKSUM' | ||
31 | license_var = 'LICENSE' | ||
32 | closed = 'CLOSED' | ||
33 | lictag_re = pyparsing.AtLineStart("License-Update:") | ||
34 | lic_chksum_added = pyparsing.AtLineStart("+" + metadata_chksum) | ||
35 | lic_chksum_removed = pyparsing.AtLineStart("-" + metadata_chksum) | ||
36 | add_mark = pyparsing.Regex('\\+ ') | ||
37 | patch_max_line_length = 200 | ||
38 | metadata_src_uri = "SRC_URI" | ||
39 | metadata_summary = "SUMMARY" | ||
40 | cve_check_ignore_var = "CVE_CHECK_IGNORE" | ||
41 | cve_status_var = "CVE_STATUS" | ||
42 | endcommit_messages_regex = re.compile( | ||
43 | r"\(From \w+-\w+ rev:|(?<!\S)Signed-off-by|(?<!\S)---\n" | ||
44 | ) | ||
45 | patchmetadata_regex = re.compile( | ||
46 | r"-{3} \S+|\+{3} \S+|@{2} -\d+,\d+ \+\d+,\d+ @{2} \S+" | ||
47 | ) | ||
48 | |||
49 | # mbox | ||
50 | auh_email = 'auh@yoctoproject.org' | ||
51 | |||
52 | invalid_submitters = [pyparsing.Regex("^Upgrade Helper.+"), | ||
53 | pyparsing.Regex(auh_email), | ||
54 | pyparsing.Regex("uh@not\.set"), | ||
55 | pyparsing.Regex("\S+@example\.com")] | ||
56 | |||
57 | mbox_bugzilla = pyparsing.Regex('\[\s?YOCTO.*\]') | ||
58 | mbox_bugzilla_validation = pyparsing.Regex('\[(\s?YOCTO\s?#\s?(\d+)\s?,?)+\]') | ||
59 | mbox_revert_shortlog_regex = pyparsing.Regex('Revert\s+".*"') | ||
60 | mbox_shortlog_maxlength = 90 | ||
61 | |||
62 | # patch | ||
63 | |||
64 | cve = pyparsing.Regex("CVE\-\d{4}\-\d+") | ||
65 | cve_payload_tag = pyparsing.Regex("\+CVE:(\s+CVE\-\d{4}\-\d+)+") | ||
66 | upstream_status_regex = pyparsing.AtLineStart("+" + "Upstream-Status") | ||
67 | |||
68 | # shortlog | ||
69 | |||
70 | shortlog_target = pyparsing.OneOrMore(pyparsing.Word(pyparsing.printables.replace(':',''))) | ||
71 | shortlog_summary = pyparsing.OneOrMore(pyparsing.Word(pyparsing.printables)) | ||
72 | shortlog = line_start + shortlog_target + colon + shortlog_summary + line_end | ||
73 | |||
74 | # signed-off-bys | ||
75 | |||
76 | email_pattern = pyparsing.Regex(r"(?P<user>[A-Za-z0-9._%+-]+)@(?P<hostname>[A-Za-z0-9.-]+)\.(?P<domain>[A-Za-z]{2,})") | ||
77 | |||
78 | signed_off_by_prefix = pyparsing.Literal("Signed-off-by:") | ||
79 | signed_off_by_name = pyparsing.Regex('\S+.*(?= <)') | ||
80 | signed_off_by_email = lessthan + email_pattern + greaterthan | ||
81 | signed_off_by = pyparsing.AtLineStart(signed_off_by_prefix + signed_off_by_name + signed_off_by_email) | ||
82 | patch_signed_off_by = pyparsing.AtLineStart("+" + signed_off_by_prefix + signed_off_by_name + signed_off_by_email) | ||
83 | |||
84 | # upstream-status | ||
85 | |||
86 | upstream_status_literal_valid_status = ["Pending", "Backport", "Denied", "Inappropriate", "Submitted"] | ||
87 | upstream_status_nonliteral_valid_status = ["Pending", "Backport", "Denied", "Inappropriate [reason]", "Submitted [where]"] | ||
88 | |||
89 | upstream_status_valid_status = pyparsing.Or( | ||
90 | [pyparsing.Literal(status) for status in upstream_status_literal_valid_status] | ||
91 | ) | ||
92 | |||
93 | upstream_status_prefix = pyparsing.Literal("Upstream-Status") | ||
94 | upstream_status = line_start + upstream_status_prefix + colon + upstream_status_valid_status | ||
95 | upstream_status_inappropriate_info = line_start + upstream_status_prefix + colon + inappropriateinfo | ||
96 | upstream_status_submitted_info = line_start + upstream_status_prefix + colon + submittedinfo | ||