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 <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2018-03-29 16:09:35 +13:00
parent 4b268a08b8
commit 58c56883fd
3 changed files with 29 additions and 2 deletions

View File

@ -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'),
),
]

View File

@ -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():

View File

@ -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,
@ -177,6 +179,10 @@ 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",