From 58c56883fd14692c25aee1e5e2c153fec3a85db0 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Thu, 29 Mar 2018 16:09:35 +1300 Subject: rrs_maintainer_history: add --fullreload option Add an option that deletes all maintainer history records for the current layer branch so that they can then be reloaded from scratch. Signed-off-by: Paul Eggleton --- rrs/migrations/0009_rmh_layerbranch.py | 20 ++++++++++++++++++++ rrs/models.py | 1 + rrs/tools/rrs_maintainer_history.py | 10 ++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 rrs/migrations/0009_rmh_layerbranch.py diff --git a/rrs/migrations/0009_rmh_layerbranch.py b/rrs/migrations/0009_rmh_layerbranch.py new file mode 100644 index 0000000000..b2a7b862f2 --- /dev/null +++ b/rrs/migrations/0009_rmh_layerbranch.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('layerindex', '0010_add_dependencies'), + ('rrs', '0008_upgrade_info'), + ] + + operations = [ + migrations.AddField( + model_name='recipemaintainerhistory', + name='layerbranch', + field=models.ForeignKey(blank=True, null=True, to='layerindex.LayerBranch'), + ), + ] diff --git a/rrs/models.py b/rrs/models.py index 2833a23078..536f3b1329 100644 --- a/rrs/models.py +++ b/rrs/models.py @@ -210,6 +210,7 @@ class RecipeMaintainerHistory(models.Model): date = models.DateTimeField(db_index=True) author = models.ForeignKey(Maintainer) sha1 = models.CharField(max_length=64, unique=True) + layerbranch = models.ForeignKey(LayerBranch, blank=True, null=True) @staticmethod def get_last(): diff --git a/rrs/tools/rrs_maintainer_history.py b/rrs/tools/rrs_maintainer_history.py index 19559ec69d..72681be107 100755 --- a/rrs/tools/rrs_maintainer_history.py +++ b/rrs/tools/rrs_maintainer_history.py @@ -88,6 +88,8 @@ def maintainer_history(options, logger): for maintplan in maintplans: for item in maintplan.maintenanceplanlayerbranch_set.all(): layerbranch = item.layerbranch + if options.fullreload and not options.dry_run: + RecipeMaintainerHistory.objects.filter(layerbranch=layerbranch).delete() urldir = str(layerbranch.layer.get_fetch_dir()) repodir = os.path.join(fetchdir, urldir) layerdir = os.path.join(repodir, layerbranch.vcs_subdir) @@ -115,7 +117,7 @@ def maintainer_history(options, logger): author = Maintainer.create_or_update(author_name, author_email) rms = RecipeMaintainerHistory(title=title, date=date, author=author, - sha1=commit) + sha1=commit, layerbranch=layerbranch) rms.save() utils.runcmd("git checkout %s -f" % commit, @@ -176,7 +178,11 @@ def maintainer_history(options, logger): if __name__=="__main__": parser = optparse.OptionParser(usage = """%prog [options]""") - + + parser.add_option("--fullreload", + help="Reload upgrade data from scratch", + action="store_true", dest="fullreload", default=False) + parser.add_option("-d", "--debug", help = "Enable debug output", action="store_const", const=logging.DEBUG, dest="loglevel", -- cgit 1.2.3-korg