Remove submodule changed

This commit is contained in:
alesapin 2022-03-29 19:50:06 +02:00
parent 999558f00f
commit 1a8b2c9637
2 changed files with 16 additions and 3 deletions

View File

@ -61,6 +61,13 @@ def post_commit_status_to_file(file_path, description, state, report_url):
out.writerow([state, report_url, description])
def remove_labels(gh, pr_info, labels_names):
repo = gh.get_repo(GITHUB_REPOSITORY)
pull_request = repo.get_pull(pr_info.number)
for label in labels_names:
pull_request.remove_from_labels(label)
def post_labels(gh, pr_info, labels_names):
repo = gh.get_repo(GITHUB_REPOSITORY)
pull_request = repo.get_pull(pr_info.number)

View File

@ -8,7 +8,7 @@ from github import Github
from env_helper import GITHUB_RUN_URL, GITHUB_REPOSITORY, GITHUB_SERVER_URL
from pr_info import PRInfo
from get_robot_token import get_best_robot_token
from commit_status_helper import get_commit, post_labels
from commit_status_helper import get_commit, post_labels, remove_labels
NAME = "Run Check (actions)"
@ -235,12 +235,18 @@ if __name__ == "__main__":
description_report, category = check_pr_description(pr_info)
pr_labels = []
if category in MAP_CATEGORY_TO_LABEL:
if (
category in MAP_CATEGORY_TO_LABEL
and MAP_CATEGORY_TO_LABEL[category] not in pr_info.labels
):
pr_labels.append(MAP_CATEGORY_TO_LABEL[category])
if pr_info.has_changes_in_submodules():
pr_labels.append(SUBMODULE_CHANGED_LABEL)
elif SUBMODULE_CHANGED_LABEL in pr_info.labels:
remove_labels(gh, pr_info, [SUBMODULE_CHANGED_LABEL])
if pr_labels:
post_labels(gh, pr_info, pr_labels)
if description_report:
print("::notice ::Cannot run, description does not match the template")