From 292c5dd7304aac487ddd3d35b08da1bab7730f63 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Wed, 24 Apr 2019 11:47:22 +0200 Subject: [PATCH 1/2] backport_pr: add doc tests for _get_labels() --- dist/tools/backport_pr/backport_pr.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dist/tools/backport_pr/backport_pr.py b/dist/tools/backport_pr/backport_pr.py index ce474766af22..0cd9928f3b5c 100755 --- a/dist/tools/backport_pr/backport_pr.py +++ b/dist/tools/backport_pr/backport_pr.py @@ -33,6 +33,14 @@ def _get_labels(pr): + """ + >>> _get_labels({'labels': [{'name': 'test'}, {'name': 'abcd'}]}) + ['Process: release backport', 'abcd', 'test'] + >>> _get_labels({'labels': [{'name': 'Process: release backport'}]}) + ['Process: release backport'] + >>> _get_labels({'labels': [{'name': 'Process: needs backport'}]}) + ['Process: release backport'] + """ labels = {label['name'] for label in pr['labels']} for remove in LABELS_REMOVE: labels.discard(remove) From e3a99c40f66649a8d93a8095bee76a1e88945c0a Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Wed, 24 Apr 2019 11:47:49 +0200 Subject: [PATCH 2/2] backport_pr: exclude 'Reviewed' labels from backport --- dist/tools/backport_pr/backport_pr.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dist/tools/backport_pr/backport_pr.py b/dist/tools/backport_pr/backport_pr.py index 0cd9928f3b5c..5434366c8535 100755 --- a/dist/tools/backport_pr/backport_pr.py +++ b/dist/tools/backport_pr/backport_pr.py @@ -26,7 +26,7 @@ RELEASE_PREFIX = "" RELEASE_SUFFIX = "-branch" -LABELS_REMOVE = ['Process: needs backport'] +LABELS_REMOVE = ['Process: needs backport', 'Reviewed: '] LABELS_ADD = ['Process: release backport'] BACKPORT_BRANCH = 'backport/{release}/{origbranch}' @@ -36,14 +36,16 @@ def _get_labels(pr): """ >>> _get_labels({'labels': [{'name': 'test'}, {'name': 'abcd'}]}) ['Process: release backport', 'abcd', 'test'] + >>> _get_labels({'labels': [{'name': 'Reviewed: what'}, {'name': 'Reviewed: 3-testing'}]}) + ['Process: release backport'] >>> _get_labels({'labels': [{'name': 'Process: release backport'}]}) ['Process: release backport'] >>> _get_labels({'labels': [{'name': 'Process: needs backport'}]}) ['Process: release backport'] """ - labels = {label['name'] for label in pr['labels']} - for remove in LABELS_REMOVE: - labels.discard(remove) + labels = set(label['name'] for label in pr['labels'] + if all(not label['name'].startswith(remove) + for remove in LABELS_REMOVE)) labels.update(LABELS_ADD) return sorted(list(labels))