From 717f9ebc7d4fb83f68234ea8e1c00a45a9655f88 Mon Sep 17 00:00:00 2001 From: Amir Sarabadani Date: Tue, 29 Jun 2021 17:25:44 +0200 Subject: [PATCH] Make sure project grouper work with milestones --- lib.py | 5 +++++ project_grouper.py | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib.py b/lib.py index c172eca..2fa035b 100755 --- a/lib.py +++ b/lib.py @@ -45,6 +45,11 @@ class Client(object): raise Exception('No object found for %s' % label) return self.phid_cache[label] + def getSubprojects(self, phid): + """Lookup information on a Phab object by name.""" + r = self.post('project.search', {'constraints': {'isMilestone': True, 'ancestors': [phid]}}) + return [i['phid'] for i in r['data']] + def getColumns(self, project_phid): if not self.column_cache.get(project_phid): self.column_cache[project_phid] = self.post( diff --git a/project_grouper.py b/project_grouper.py index 75fa61a..8b33f42 100644 --- a/project_grouper.py +++ b/project_grouper.py @@ -282,7 +282,8 @@ client = Client.newFromCreds() for rule in rules: handled_tasks = [] - wanted_project_phid = client.lookupPhid('#' + rule['add']) + wanted_project_phid = client.lookupPhid('#' + rule['add'].replace(' ', '_')) + subprojects = set(client.getSubprojects(wanted_project_phid) + [wanted_project_phid]) for project_name in rule['in']: project_name = project_name.replace(' ', '_') try: @@ -294,7 +295,7 @@ for rule in rules: if task_phid in handled_tasks: continue task = client.taskDetails(task_phid) - if wanted_project_phid in task['projectPHIDs']: + if subprojects.intersection(set(task['projectPHIDs'])): continue if rule.get('once') == True: is_already_added = False