mirror of
https://gitlab.wikimedia.org/ladsgroup/Phabricator-maintenance-bot
synced 2024-11-09 13:42:38 +01:00
Merge pull request #22 from supertassu/project-grouper
Add project grouper
This commit is contained in:
commit
2be5178df9
4 changed files with 42 additions and 0 deletions
|
@ -4,4 +4,5 @@ Source for https://phabricator.wikimedia.org/p/Maintenance_bot/
|
||||||
Report issues and bugs: https://phabricator.wikimedia.org/project/board/5124/
|
Report issues and bugs: https://phabricator.wikimedia.org/project/board/5124/
|
||||||
|
|
||||||
* `column_mover.py` is a script that can move columns of a task when some actions happens on it. E.g. Moving a task in workboard #user-ladsgroup from column "incoming" to column "done" when someone changes the task's status to "done"
|
* `column_mover.py` is a script that can move columns of a task when some actions happens on it. E.g. Moving a task in workboard #user-ladsgroup from column "incoming" to column "done" when someone changes the task's status to "done"
|
||||||
|
* `project_grouper.py` adds tasks in configured projects to other configured projects
|
||||||
* `patchforreview_remover.py` is an automatic script that removes the "patch_for_review" tag when all patches have been merged or abandoned
|
* `patchforreview_remover.py` is an automatic script that removes the "patch_for_review" tag when all patches have been merged or abandoned
|
||||||
|
|
1
cron
1
cron
|
@ -1,4 +1,5 @@
|
||||||
15 * * * * jsub -once -N column_mover python3 /data/project/phabbot/phabbot/column_mover.py /data/project/phabbot/phabbot/creds.json 3600 >/dev/null 2>&1
|
15 * * * * jsub -once -N column_mover python3 /data/project/phabbot/phabbot/column_mover.py /data/project/phabbot/phabbot/creds.json 3600 >/dev/null 2>&1
|
||||||
|
45 * * * * jsub -once -N column_mover python3 /data/project/phabbot/phabbot/project_grouper.py /data/project/phabbot/phabbot/creds.json 3600 >/dev/null 2>&1
|
||||||
10 * * * * jsub -once -N patch_for_review python3 /data/project/phabbot/phabbot/patchforreview_remover.py /data/project/phabbot/phabbot/creds.json 3600 >/dev/null 2>&1
|
10 * * * * jsub -once -N patch_for_review python3 /data/project/phabbot/phabbot/patchforreview_remover.py /data/project/phabbot/phabbot/creds.json 3600 >/dev/null 2>&1
|
||||||
5 * * * * jlocal bash /data/project/phabbot/phabbot/updater.sh >/dev/null 2>&1
|
5 * * * * jlocal bash /data/project/phabbot/phabbot/updater.sh >/dev/null 2>&1
|
||||||
10 22,4,10,16 * * * jsub -once -N new_wikis_handler bash /data/project/phabbot/phabbot/new_wikis_handler.sh >/dev/null 2>&1
|
10 22,4,10,16 * * * jsub -once -N new_wikis_handler bash /data/project/phabbot/phabbot/new_wikis_handler.sh >/dev/null 2>&1
|
||||||
|
|
9
lib.py
9
lib.py
|
@ -71,6 +71,15 @@ class Client(object):
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def addTaskProject(self, task_phid, project_phid):
|
||||||
|
self.post('maniphest.edit', {
|
||||||
|
'objectIdentifier': task_phid,
|
||||||
|
'transactions': [{
|
||||||
|
'type': 'projects.add',
|
||||||
|
'value': [project_phid],
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
def createSubtask(self, desc, project_phids, parent_phid, title):
|
def createSubtask(self, desc, project_phids, parent_phid, title):
|
||||||
self.post('maniphest.edit', {
|
self.post('maniphest.edit', {
|
||||||
'objectIdentifier': '',
|
'objectIdentifier': '',
|
||||||
|
|
31
project_grouper.py
Normal file
31
project_grouper.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
"""
|
||||||
|
Adds tasks in configured projects to other configured projects
|
||||||
|
"""
|
||||||
|
|
||||||
|
from lib import Client
|
||||||
|
|
||||||
|
rules = [
|
||||||
|
{
|
||||||
|
# current H175 - see T136921
|
||||||
|
'add': 'Design',
|
||||||
|
'in': ['WMF-Design', 'WMDE-Design'],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
client = Client.newFromCreds()
|
||||||
|
|
||||||
|
for rule in rules:
|
||||||
|
handled_tasks = []
|
||||||
|
|
||||||
|
wanted_project_phid = client.lookupPhid('#' + rule['add'])
|
||||||
|
for project_name in rule['in']:
|
||||||
|
project_phid = client.lookupPhid('#' + project_name)
|
||||||
|
for task_phid in client.getTasksWithProject(project_phid):
|
||||||
|
# if a task is in multiple 'in' projects, still only process it once
|
||||||
|
if task_phid in handled_tasks:
|
||||||
|
continue
|
||||||
|
handled_tasks.append(task_phid)
|
||||||
|
|
||||||
|
task = client.taskDetails(task_phid)
|
||||||
|
if wanted_project_phid not in task['projectPHIDs']:
|
||||||
|
client.addTaskProject(task_phid, wanted_project_phid)
|
Loading…
Reference in a new issue