[IMP] runbot_merge: prune repo during maintenance

The weekly maintenance would not prune refs. This is not an issue on
odoo/odoo because development branches are in a separate repository,
thus never fetched (we push to them but only using local commits and
remote refs).

However on repos like odoo/documentation the reference and development
branches are collocated, the lack of pruning thus keeps every
development branch alive locally, even years after the branch has been
deleted in the repository.

By pruning remote-tracking refs before GC-ing, we should have cleaner
local clones, and better packing.
This commit is contained in:
Xavier Morel 2024-08-05 09:03:39 +02:00
parent 8131271a9c
commit ec01523875

View File

@ -29,9 +29,16 @@ class GC(models.TransientModel):
continue
_gc.info('Running maintenance on %s', repo.name)
r = repo_git\
.stdout(True)\
.with_config(stderr=subprocess.STDOUT, text=True, check=False)\
.remote('prune', 'origin')
if r.returncode:
_gc.warning("Prune failure (status=%d):\n%s", r.returncode, r.stdout)
r = repo_git\
.stdout(True)\
.with_config(stderr=subprocess.STDOUT, text=True, check=False)\
.gc('--prune=now', aggressive=True)
if r.returncode:
_gc.warning("Maintenance failure (status=%d):\n%s", r.returncode, r.stdout)
_gc.warning("GC failure (status=%d):\n%s", r.returncode, r.stdout)