]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
script/ptl-tool.py: Label Validation
authorJos Collin <jcollin@redhat.com>
Thu, 5 Oct 2017 01:52:32 +0000 (07:22 +0530)
committerJos Collin <jcollin@redhat.com>
Thu, 5 Oct 2017 01:52:38 +0000 (07:22 +0530)
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 <jcollin@redhat.com>
src/script/ptl-tool.py

index 0ffb76aef0ce529e4ea2fb08c7f18cde2e297668..cb754101e3fde6a2c105b1e4603bd52b20060b63 100755 (executable)
@@ -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-<name>-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