1
0
Fork 0
mirror of https://gitlab.wikimedia.org/ladsgroup/Phabricator-maintenance-bot synced 2024-11-28 15:02:39 +01:00

Make sure project grouper work with milestones

This commit is contained in:
Amir Sarabadani 2021-06-29 17:25:44 +02:00
parent 9eb22d24b9
commit 717f9ebc7d
2 changed files with 8 additions and 2 deletions

5
lib.py
View file

@ -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(

View file

@ -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