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