File: check_pr_title.py

package info (click to toggle)
pypdf 6.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 18,184 kB
  • sloc: python: 48,595; makefile: 35
file content (33 lines) | stat: -rw-r--r-- 893 bytes parent folder | download | duplicates (3)
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
"""Check that all PR titles follow the desired scheme."""  # noqa: INP001

import os
import sys

KNOWN_PREFIXES = (
    "SEC: ",
    "BUG: ",
    "ENH: ",
    "DEP: ",
    "PI: ",
    "ROB: ",
    "DOC: ",
    "TST: ",
    "DEV: ",
    "STY: ",
    "MAINT: ",
    "REL: ",  # For internal use only.
)
PR_TITLE = os.getenv("PR_TITLE", "")

if not PR_TITLE.startswith(KNOWN_PREFIXES) or not PR_TITLE.split(": ", maxsplit=1)[1]:
    sys.stderr.write(
        f"The PR title '{PR_TITLE}' does not follow the projects naming scheme: "
        "https://pypdf.readthedocs.io/en/latest/dev/intro.html#commit-messages\n",
    )
    sys.stderr.write(
        "If you do not know which one to choose or if multiple apply, make a best guess. "
        "Nobody will complain if it does not quite fit :-)\n",
    )
    sys.exit(1)
else:
    sys.stdout.write(f"PR title '{PR_TITLE}' appears to be valid.\n")