You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by je...@apache.org on 2022/08/04 18:17:40 UTC
[airflow] branch main updated: Validate newsfragment types (#25536)
This is an automated email from the ASF dual-hosted git repository.
jedcunningham pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new cda40836ca Validate newsfragment types (#25536)
cda40836ca is described below
commit cda40836ca55702c543391367d0829ed231c1b35
Author: Jed Cunningham <66...@users.noreply.github.com>
AuthorDate: Thu Aug 4 11:17:23 2022 -0700
Validate newsfragment types (#25536)
We should validate the a type is provided, and that it is a supported type.
---
scripts/ci/pre_commit/pre_commit_newsfragments.py | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/scripts/ci/pre_commit/pre_commit_newsfragments.py b/scripts/ci/pre_commit/pre_commit_newsfragments.py
index e0504273e7..cb8d3b07ad 100755
--- a/scripts/ci/pre_commit/pre_commit_newsfragments.py
+++ b/scripts/ci/pre_commit/pre_commit_newsfragments.py
@@ -22,6 +22,9 @@ Check things about newsfragments:
"""
import sys
+from pathlib import Path
+
+VALID_CHANGE_TYPES = {"significant", "feature", "improvement", "bugfix", "doc", "misc"}
files = sys.argv[1:]
@@ -31,20 +34,32 @@ for filename in files:
lines = [line.strip() for line in f.readlines()]
num_lines = len(lines)
- if "significant" not in filename:
+ name_parts = Path(filename).name.split('.')
+ if len(name_parts) != 3:
+ print(f"Newsfragment {filename} has an unexpected filename. Should be {{pr_number}}.{{type}}.rst.")
+ failed = True
+ continue
+
+ change_type = name_parts[1]
+ if change_type not in VALID_CHANGE_TYPES:
+ print(f"Newsfragment {filename} has an unexpected type. Should be one of {VALID_CHANGE_TYPES}.")
+ failed = True
+ continue
+
+ if change_type != "significant":
if num_lines != 1:
- print(f"Newsfragement {filename} can only have a single line.")
+ print(f"Newsfragment {filename} can only have a single line.")
failed = True
else:
# significant newsfragment
if num_lines == 1:
continue
if num_lines == 2:
- print(f"Newsfragement {filename} can have 1, or 3+ lines.")
+ print(f"Newsfragment {filename} can have 1, or 3+ lines.")
failed = True
continue
if lines[1] != "":
- print(f"Newsfragement {filename} must have an empty second line.")
+ print(f"Newsfragment {filename} must have an empty second line.")
failed = True
continue