Skip to contentSkip to conversation

Allow per LayerBranch update disable

PATCH New Tim Orling 1 participant 3 messages Oct 17, 2023

lore
Share & tools
lore

Tim Orling

author
#0 lore raw

cover Allow per LayerBranch update disable

Some layers have branches which match the stable release branch names, but fail to update for some reason. Rather than completely disable updates for a LayerItem, allow for a LayerBranch to have updates disabled.

Before this change, we only had the option to completely disable updates for a layer (Change from "Published" to "No Update" state) or completely disable a Branch for all layers. These hammers are too heavy and needed a little nuance.

Tim Orling (2):
models.py: add updates_enabled to LayerBranch update.py: skip unless layerbranch.updates_enabled

 .../0047_layerbranch_updates_enabled.py        | 18 ++++++++++++++++++
 layerindex/models.py                           |  2 +-
 layerindex/update.py                           |  5 +++++
 3 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100644 layerindex/migrations/0047_layerbranch_updates_enabled.py
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/2 models.py: add updates_enabled to LayerBranch

Especially since LTS branches have become more popular as the only active branch, we need to be able to turn off updates on a LayerBranch basis rather than the current Layer or Branch heavier hammers.

---
 .../0047_layerbranch_updates_enabled.py        | 18 ++++++++++++++++++
 layerindex/models.py                           |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 layerindex/migrations/0047_layerbranch_updates_enabled.py
layerindex/migrations/0047_layerbranch_updates_enabled.py new file +18 -0
new file mode 100644
index 0000000..44e07ee
@@ -0,0 +1,18 @@
+# Generated by Django 4.2.6 on 2023-10-07 19:39
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('layerindex', '0046_alter_patch_status'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='layerbranch',
+            name='updates_enabled',
+            field=models.BooleanField(default=True, help_text='Enable automatically updating layer metadata for this layer:branch via the update script', verbose_name='Enable updates'),
+        ),
+    ]
layerindex/models.py +1 -1
index 5ae60c3..397425a 100644
@@ -241,7 +241,7 @@ class LayerBranch(models.Model):
     actual_branch = models.CharField('Actual Branch', max_length=80, blank=True, help_text='Name of the actual branch in the repository matching the core branch')
     yp_compatible_version = models.ForeignKey(YPCompatibleVersion, verbose_name='Yocto Project Compatible version', null=True, blank=True, on_delete=models.SET_NULL, help_text='Which version of the Yocto Project Compatible program has this layer been approved for for?')
     local_path = models.CharField(max_length=255, blank=True, help_text='Local subdirectory where layer data can be found')
-
+    updates_enabled = models.BooleanField('Enable updates', default=True, help_text='Enable automatically updating layer metadata for this layer:branch via the update script')
     updated = models.DateTimeField(auto_now=True)
 
     class Meta:
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH 2/2 update.py: skip unless layerbranch.updates_enabled

In reply to Tim Orling

If layerbranch.updates_enabled is false, skip the update.

---
 layerindex/update.py | 5 +++++
 1 file changed, 5 insertions(+)
layerindex/update.py +5 -0
index 7de9c0d..e7e5c63 100755
@@ -375,6 +375,11 @@ def main():
                         if layerbranch_source:
                             layerbranch.vcs_subdir = layerbranch_source.vcs_subdir
 
+                    layerbranch_updates_enabled = LayerBranch.objects.filter(layer=layer, branch=branchobj.id, updates_enabled=True)
+                    if not layerbranch_updates_enabled:
+                        logger.info("Skipping update of layer %s  branch %s - updates disabled" % (layer.name, branchname))
+                        continue
+
                     # Collect repo info
                     urldir = layer.get_fetch_dir()
                     repodir = os.path.join(fetchdir, urldir)
Signature · 1 line
2.34.1