From 0cd54201cfb867e4cfd5c769fa9cc2a0f1ee2436 Mon Sep 17 00:00:00 2001 From: Jos Collin Date: Thu, 5 Oct 2017 07:22:32 +0530 Subject: [PATCH] script/ptl-tool.py: Label Validation Validated the label and verified the existence of the label at the beginning of build_branch(). This will avoid: * Assigning invalid testing labels like 'abcd' and other existing labels like 'bug', 'cleanup' etc; as testing labels * Stops spamming the Label list in the Ceph repo by creating new (invalid format) labels everytime. The labels can be created manually in github and ptl-tool only uses them. Signed-off-by: Jos Collin --- src/script/ptl-tool.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/script/ptl-tool.py b/src/script/ptl-tool.py index 0ffb76aef0c..cb754101e3f 100755 --- a/src/script/ptl-tool.py +++ b/src/script/ptl-tool.py @@ -109,6 +109,18 @@ def build_branch(args): branch = args.branch label = args.label + if label and label != '-': + #Check the label format + if re.search(r'\bwip-(.*?)-testing\b', label) is None: + log.error("Unknown Label '{lblname}'. Label Format: wip--testing".format(lblname=label)) + sys.exit(1) + + #Check if the Label exist in the repo + res = requests.get("https://api.github.com/repos/ceph/ceph/labels/{lblname}".format(lblname=label), auth=(USER, PASSWORD)) + if res.status_code != 200: + log.error("Label '{lblname}' not found in the repo".format(lblname=label)) + sys.exit(1) + G = git.Repo(args.git) # First get the latest base branch and PRs from BASE_REMOTE -- 2.39.5