mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Fix the PR body check for Reverts #number
This commit is contained in:
parent
1130904697
commit
79d49a006c
@ -323,7 +323,9 @@ def main(event):
|
|||||||
|
|
||||||
if action == "edited":
|
if action == "edited":
|
||||||
print("PR is edited, check if the body is correct")
|
print("PR is edited, check if the body is correct")
|
||||||
error, category = check_pr_description(pull_request["body"])
|
error, _ = check_pr_description(
|
||||||
|
pull_request["body"], pull_request["base"]["repo"]["full_name"]
|
||||||
|
)
|
||||||
if error:
|
if error:
|
||||||
print(
|
print(
|
||||||
f"The PR's body is wrong, is going to comment it. The error is: {error}"
|
f"The PR's body is wrong, is going to comment it. The error is: {error}"
|
||||||
|
@ -101,7 +101,7 @@ LABELS = {
|
|||||||
CATEGORY_TO_LABEL = {c: lb for lb, categories in LABELS.items() for c in categories}
|
CATEGORY_TO_LABEL = {c: lb for lb, categories in LABELS.items() for c in categories}
|
||||||
|
|
||||||
|
|
||||||
def check_pr_description(pr_body: str) -> Tuple[str, str]:
|
def check_pr_description(pr_body: str, repo_name: str) -> Tuple[str, str]:
|
||||||
"""The function checks the body to being properly formatted according to
|
"""The function checks the body to being properly formatted according to
|
||||||
.github/PULL_REQUEST_TEMPLATE.md, if the first returned string is not empty,
|
.github/PULL_REQUEST_TEMPLATE.md, if the first returned string is not empty,
|
||||||
then there is an error."""
|
then there is an error."""
|
||||||
@ -109,11 +109,7 @@ def check_pr_description(pr_body: str) -> Tuple[str, str]:
|
|||||||
lines = [re.sub(r"\s+", " ", line) for line in lines]
|
lines = [re.sub(r"\s+", " ", line) for line in lines]
|
||||||
|
|
||||||
# Check if body contains "Reverts ClickHouse/ClickHouse#36337"
|
# Check if body contains "Reverts ClickHouse/ClickHouse#36337"
|
||||||
if [
|
if [True for line in lines if re.match(rf"\AReverts {repo_name}#[\d]+\Z", line)]:
|
||||||
True
|
|
||||||
for line in lines
|
|
||||||
if re.match(r"\AReverts {GITHUB_REPOSITORY}#[\d]+\Z", line)
|
|
||||||
]:
|
|
||||||
return "", LABELS["pr-not-for-changelog"][0]
|
return "", LABELS["pr-not-for-changelog"][0]
|
||||||
|
|
||||||
category = ""
|
category = ""
|
||||||
|
@ -108,7 +108,7 @@ def main():
|
|||||||
gh = Github(get_best_robot_token(), per_page=100)
|
gh = Github(get_best_robot_token(), per_page=100)
|
||||||
commit = get_commit(gh, pr_info.sha)
|
commit = get_commit(gh, pr_info.sha)
|
||||||
|
|
||||||
description_error, category = check_pr_description(pr_info.body)
|
description_error, category = check_pr_description(pr_info.body, GITHUB_REPOSITORY)
|
||||||
pr_labels_to_add = []
|
pr_labels_to_add = []
|
||||||
pr_labels_to_remove = []
|
pr_labels_to_remove = []
|
||||||
if (
|
if (
|
||||||
|
Loading…
Reference in New Issue
Block a user