diff mbox series

[layerindex-web,3/4] BranchComparison: add CSV output option

Message ID 20260211195536.10278-3-tim.orling@konsulko.com
State New
Headers show
Series [layerindex-web,1/4] requirements: bump to fix vulnerabilities | expand

Commit Message

Tim Orling Feb. 11, 2026, 7:55 p.m. UTC
Add a new template, URL and button for CSV text file output.
This makes it easier to consume the BranchComparison for automation
or other usage, such as in a spreadsheet.

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
 layerindex/urls.py                         |  5 +++++
 templates/layerindex/branchcompare.html    |  1 +
 templates/layerindex/branchcompare_csv.txt | 11 +++++++++++
 3 files changed, 17 insertions(+)
 create mode 100644 templates/layerindex/branchcompare_csv.txt
diff mbox series

Patch

diff --git a/layerindex/urls.py b/layerindex/urls.py
index 3b95a88..7555907 100644
--- a/layerindex/urls.py
+++ b/layerindex/urls.py
@@ -200,6 +200,11 @@  urlpatterns = [
             content_type='text/plain; charset=utf-8',
             template_name='layerindex/branchcompare_rst.txt'),
         name='branch_comparison_rst'),
+    re_path(r'^branch_comparison_csv/$',
+        BranchCompareView.as_view(
+            content_type='text/csv; charset=utf-8',
+            template_name='layerindex/branchcompare_csv.txt'),
+        name='branch_comparison_csv'),
     re_path(r'^recipe_deps/$',
         RecipeDependenciesView.as_view(
             template_name='layerindex/recipedeps.html'),
diff --git a/templates/layerindex/branchcompare.html b/templates/layerindex/branchcompare.html
index 93ac801..83561fd 100644
--- a/templates/layerindex/branchcompare.html
+++ b/templates/layerindex/branchcompare.html
@@ -152,6 +152,7 @@ 
     <span class="pull-right">
     <a class="btn btn-default" href="{% url 'branch_comparison_plain' %}?{{ request.GET.urlencode }}"><i class="glyphicon glyphicon-file"></i> Plain text</a>
     <a class="btn btn-default" href="{% url 'branch_comparison_rst' %}?{{ request.GET.urlencode }}"><i class="glyphicon glyphicon-file"></i> rST</a>
+    <a class="btn btn-default" href="{% url 'branch_comparison_csv' %}?{{ request.GET.urlencode }}"><i class="glyphicon glyphicon-file"></i> CSV text</a>
     </span>
 
 
diff --git a/templates/layerindex/branchcompare_csv.txt b/templates/layerindex/branchcompare_csv.txt
new file mode 100644
index 0000000..d407ae3
--- /dev/null
+++ b/templates/layerindex/branchcompare_csv.txt
@@ -0,0 +1,11 @@ 
+{# Header #}
+recipe.pn,recipe.pv.{{from_branch}},recipe.pv.{{to_branch}}
+{# Added #}
+{% for recipe in added %}{{ recipe.pn }},,{% for rv in recipe.to_versions %}{{ rv.pv }}{% if not forloop.last %}{% endif %}{% endfor %}
+{% endfor %}
+{# Changed #}
+{% for recipe in changed %}{% with pv_changed=recipe.pv_changed %}{{ recipe.pn }},{% for rv in recipe.from_versions %}{{ rv.pv }}{% if rv.srcrev and not pv_changed %},({{ rv.srcrev|truncatechars:13 }}){% endif %}{% if not forloop.last %}, {% endif %}{% endfor %} -> {% for rv in recipe.to_versions %}{{ rv.pv }}{% if rv.srcrev and not pv_changed %} ({{ rv.srcrev|truncatechars:13 }}){% endif %}{% if not forloop.last %}, {% endif %}{% endfor %}
+{% endwith %}{% endfor %}
+{# Removed #}
+{% for recipe in removed %}{{ recipe.pn }},,
+{% endfor %}