From 4073946a4baf07fada629e7eec7faf486a45e4c1 Mon Sep 17 00:00:00 2001 From: "Jose R. Gonzalez" Date: Tue, 17 Oct 2023 12:52:38 -0500 Subject: [PATCH] Configure more locations to use the submission regex matchers Signed-off-by: Jose R. Gonzalez --- scripts/src/chartprreview/chartprreview.py | 3 ++- scripts/src/chartrepomanager/chartrepomanager.py | 14 +++++++++++++- scripts/src/metrics/metrics.py | 5 ++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/scripts/src/chartprreview/chartprreview.py b/scripts/src/chartprreview/chartprreview.py index 23604b7d..dcf4e38e 100644 --- a/scripts/src/chartprreview/chartprreview.py +++ b/scripts/src/chartprreview/chartprreview.py @@ -23,6 +23,7 @@ from report import verifier_report from signedchart import signedchart from pullrequest import prartifact +from reporegex import matchers from tools import gitutils @@ -58,7 +59,7 @@ def get_modified_charts(directory, api_url): """ print("[INFO] Get modified charts. %s" % directory) files = prartifact.get_modified_files(api_url) - pattern = re.compile(r"charts/(\w+)/([\w-]+)/([\w-]+)/([\w\.\-+]+)/.*") + pattern = re.compile(matchers.submission_path_matcher() + r"/.*") for file_path in files: m = pattern.match(file_path) if m: diff --git a/scripts/src/chartrepomanager/chartrepomanager.py b/scripts/src/chartrepomanager/chartrepomanager.py index 63b10e10..5fd6f6f9 100644 --- a/scripts/src/chartrepomanager/chartrepomanager.py +++ b/scripts/src/chartrepomanager/chartrepomanager.py @@ -24,12 +24,24 @@ from chartrepomanager import indexannotations from signedchart import signedchart from pullrequest import prartifact +from reporegex import matchers from tools import gitutils def get_modified_charts(api_url): + """Reads a PR's modified files to get submission details and exits if none are found. + + Args: + api_url: URL to the API representation of a pull request. + E.g. https://api.github.com/repos/openshift-helm-charts/charts/pulls/1 + + Returns: + The category, organization, chart name, and version. + """ files = prartifact.get_modified_files(api_url) - pattern = re.compile(r"charts/(\w+)/([\w-]+)/([\w-]+)/([\w\.-]+)/.*") + pattern = re.compile( + matchers.submission_path_matcher(strict_categories=False) + r"/.*" + ) for file_path in files: m = pattern.match(file_path) if m: diff --git a/scripts/src/metrics/metrics.py b/scripts/src/metrics/metrics.py index c2a289d8..00e96aa8 100644 --- a/scripts/src/metrics/metrics.py +++ b/scripts/src/metrics/metrics.py @@ -11,8 +11,11 @@ from indexfile import index from pullrequest import prepare_pr_comment as pr_comment from collections import OrderedDict +from reporegex import matchers -file_pattern = re.compile(r"charts/([\w-]+)/([\w-]+)/([\w\.-]+)/([\w\.-]+)/.*") +file_pattern = re.compile( + matchers.submission_path_matcher(strict_categories=False) + r"/.*" +) chart_downloads_event = "Chart Downloads v1.0" ignore_users = [ "zonggen",