yihua commented on code in PR #13883:
URL: https://github.com/apache/hudi/pull/13883#discussion_r2342346880
##########
scripts/pr_compliance.py:
##########
@@ -28,10 +29,43 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# Allowed PR title prefixes - can be updated to add/remove prefixes as needed
+ALLOWED_PREFIXES = [
+ r"\[HUDI-[0-9]{1,}\]", # HUDI JIRA issue format
+ r"\[MINOR\]", # Minor changes
+ r"\(feat\)", # A new feature
+ r"\(fix\)", # A bug fix
+ r"\(docs\)", # Documentation changes only
+ r"\(style\)", # Code style, formatting, or lint-only changes (no logic
impact)
+ r"\(refactor\)", # Code changes that neither fix a bug nor add a feature
(e.g., cleanups, restructuring)
+ r"\(perf\)", # Performance improvements
+ r"\(test\)", # Adding or correcting tests
+ r"\(chore\)", # Tooling, build system, CI/CD, or maintenance tasks
+ r"\(improvement\)", # Enhancements to existing functionality (aligns with
past JIRA usage)
+ r"\(blocker\)", # Critical issues that block a release (rare, reserved
use)
+ r"\(security\)", # Security-related fixes or improvements
+ r"\(breaking\)" # Use alongside others (e.g., (feat) or (refactor)) to
indicate a breaking change
+]
#validator for titles
def validate_title(title: str):
- return len(re.findall(r'(\[HUDI\-[0-9]{1,}\]|\[MINOR\])',title)) == 1
+ # Create regex pattern from allowed prefixes (without capture groups to
avoid tuples)
+ pattern = r'(?:' + '|'.join(ALLOWED_PREFIXES) + r')'
+ matches = re.findall(pattern, title)
+
+ # Allow exactly one prefix, OR allow combinations with (breaking)
+ if len(matches) == 1:
+ # Don't allow standalone (breaking)
+ return "(breaking)" not in matches
+ elif len(matches) == 2:
+ # Check if one of the matches is (breaking) and the other is (feat) or
(refactor)
+ has_breaking = "(breaking)" in matches
+ has_feat = "(feat)" in matches
+ has_refactor = "(refactor)" in matches
+
+ return has_breaking and (has_feat or has_refactor)
Review Comment:
Yes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]