[extensions-web] Start adding a changelog view



commit 9a2659327cef3900b75861f1e9fb0282f155f40d
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Jun 26 14:16:29 2012 -0400

    Start adding a changelog view
    
    XXX

 sweettooth/review/views.py |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/sweettooth/review/views.py b/sweettooth/review/views.py
index ebae1b1..3cf2b7a 100644
--- a/sweettooth/review/views.py
+++ b/sweettooth/review/views.py
@@ -181,6 +181,21 @@ def ajax_get_file_diff_view(request, version):
                 oldlines=oldlines,
                 newlines=newlines)
 
+def get_changelog(old_version, new_version, filename='CHANGELOG'):
+    old_zipfile, new_zipfile = get_zipfiles(old_version, new_version)
+    oldlines, newlines = grab_lines(old_zipfile, filename), grab_lines(new_zipfile, filename)
+    chunks = get_chunks(oldlines, newlines)
+
+    contents = []
+    for chunk in chunks:
+        if chunk['operation'] != 'insert':
+            continue
+
+        content = '\n'.join(newlines[line['newindex']] for line in chunk['lines'])
+        contents.append(content)
+
+    return '\n\n'.join(contents)
+
 
 @ajax_view
 @model_view(models.ExtensionVersion)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]