diff --git a/landoapi/cli.py b/landoapi/cli.py index 5065b3a5..525f7c38 100644 --- a/landoapi/cli.py +++ b/landoapi/cli.py @@ -107,6 +107,20 @@ def run_post_deploy_sequence(): ) +@cli.command(name="clean-landing-job-patches") +def clean_landing_job_patches(): + """Iterate over all landed jobs and delete their patches.""" + from landoapi.models.landing_job import LandingJob, LandingJobStatus + from landoapi.storage import db, db_subsystem + + db_subsystem.ensure_ready() + jobs = LandingJob.query.filter(LandingJob.status == LandingJobStatus.LANDED).all() + for job in jobs: + for revision in job.revisions: + revision.patch_bytes = b"" + db.session.commit() + + @cli.command(context_settings={"ignore_unknown_options": True}) @click.argument("celery_arguments", nargs=-1, type=click.UNPROCESSED) def celery(celery_arguments): diff --git a/landoapi/workers/landing_worker.py b/landoapi/workers/landing_worker.py index 67ef99e4..4e69265a 100644 --- a/landoapi/workers/landing_worker.py +++ b/landoapi/workers/landing_worker.py @@ -439,6 +439,11 @@ def run_job( LandingJobAction.LAND, commit_id=commit_id, commit=True, db=db ) + # Patches are no longer necessary, delete them. + for revision in job.revisions: + revision.patch_bytes = b"" + db.session.commit() + mots_path = Path(hgrepo.path) / "mots.yaml" if mots_path.exists(): logger.info(f"{mots_path} found, setting reviewer data.")