[yocto] [patchwork][PATCH] patchwork.models: Include first patch's name in series name

Jose Lamego jose.a.lamego at linux.intel.com
Thu Nov 24 15:00:09 PST 2016


Patch Series created without a cover letter are named using a
non-descriptive generic string.

This change names the series using the first 30 characters in
patch #1 and the remaining patches number.

[Yocto #10625]

Signed-off-by: Jose Lamego <jose.a.lamego at linux.intel.com>
---
 patchwork/models.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/patchwork/models.py b/patchwork/models.py
index 3f531e6..fecf5cc 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -1042,6 +1042,19 @@ def _series_supersede_previous_patches(series):
 def _on_revision_complete(sender, revision, **kwargs):
     series = revision.series
 
+    # Now we know how many patches are in the revision,
+    # so we can update the name for series without a cover letter
+    if series.name == SERIES_DEFAULT_NAME:
+        try:
+            name = series.latest_revision().ordered_patches()[0].name
+            n = re.compile(r'(\[\d+\/\d+\]\s?)')
+            name = n.sub('', name)
+            c = len(series.latest_revision().ordered_patches()) - 1
+            series.name = "\"%s...\" and %s more" % (name[:30],
+                          c)
+        except:
+            pass
+
     # update series.last_revision
     series.last_revision = series.latest_revision()
     series.save()
-- 
1.9.1




More information about the yocto mailing list