diff --git a/utils/deactivate_repo.py b/utils/deactivate_repo.py new file mode 100755 index 0000000..f00f40c --- /dev/null +++ b/utils/deactivate_repo.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 + +from phabricator import Phabricator + +phab = Phabricator(host='https://c4science.ch/api/') +phab.update_interfaces() + +#phab.diffusion.repository.edit( +# objectIdentifier = phid, +# transactions = [ +# {'type': 'status', 'value': 'inactive'}, +# ], +#) + +repos = open('/tmp/repo-id', 'r').read().split('\n') + +ids = [] +callsigns = [] + +# Parse file for IDs +for r in repos: + if len(r) ==0: + continue + + if r[0] == 'R': + ids.append(int(r[1:])) + else: + callsigns.append(r[1:]) + +# Deactivate repo +def deactivate(phid): + phab.diffusion.repository.edit( + objectIdentifier = phid, + transactions = [ + {'type': 'status', 'value': 'inactive'}, + ], + ) + +# Search repo +def search(constraints): + after = 0 + while after != None: + search = phab.diffusion.repository.search(after=after, constraints=constraints) + after = search['cursor']['after'] + for s in search['data']: + state = s['fields']['status'] + print((s['id']), state) + deactivate(s['phid']) + + +for i in ids: + # for some reasons it doesn't work in batch for ids but for callsigns.... + search({'ids': [i]}) +search({'callsigns': callsigns}) + +