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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env python3
# Copyright (C) 2026 Tencent. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Validate the title of a pull request.
This mirrors the convention used by projects such as Apache Fluss: every
merged commit is a *squash* of the PR, and GitHub automatically appends the
PR number to the squashed commit title, e.g.::
[sdk] Reduce log verbosity in SplitGenerator (#3700)
^^^^^^^^
GitHub adds this on squash-merge
So the only thing we need to enforce is the PR *title* format. When the PR is
squash-merged, GitHub turns the title into a commit that links back to the PR
via ``(#NNNN)``. A title of the form ``[area] Short summary`` therefore yields
a commit that links to its PR, exactly like Fluss.
Allowed formats
---------------
* ``[area] Short summary`` (one area tag, e.g. ``[sdk]``)
* ``[area][area2] Short summary`` (multiple area tags, e.g. ``[sdk][py]``)
The area tag is a lowercase identifier: ``[a-z0-9]`` plus ``/`` ``-`` ``_``
and single spaces between words.
* Exceptions that need no area tag:
``Revert ...``, ``Release ...``, ``Bump ...``, ``Merge ...``,
``Initial ...``, ``chore(release): ...``.
Usage
-----
python3 scripts/ci/pr_title_check.py "PR title here"
# or read from $PR_TITLE (used by GitHub Actions)
"""
# One or more "[area]" tags followed by a non-empty summary.
# Area tag: starts with lowercase letter/digit, may contain lowercase
# letters, digits and the separators "/", "-", "_", and single spaces -- but
# each separator must occur *between* non-empty alphanumeric segments
# (e.g. "sdk", "sdk/py", "sdk-py"), so malformed tags like "[sdk ]",
# "[sdk py ]" or "[sdk//py]" are rejected.
=
# Titles that are allowed without an [area] tag.
=
=
return False
return True
return
=
=
return 0
return 1