You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by he...@apache.org on 2016/02/25 17:23:33 UTC

allura git commit: Remove .ts from list of known binary extensions; allow repo settings to override binary blacklist

Repository: allura
Updated Branches:
  refs/heads/master 30dcfe44f -> 091f1976f


Remove .ts from list of known binary extensions; allow repo settings to override binary blacklist


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/091f1976
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/091f1976
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/091f1976

Branch: refs/heads/master
Commit: 091f1976fe6d7192fbf2dd358443ae2b29ee5fe3
Parents: 30dcfe4
Author: Dave Brondsema <da...@brondsema.net>
Authored: Mon Feb 1 16:11:12 2016 -0500
Committer: Heith Seewald <he...@gmail.com>
Committed: Thu Feb 25 11:20:20 2016 -0500

----------------------------------------------------------------------
 Allura/allura/model/repository.py     |  5 +++--
 Allura/allura/tests/unit/test_repo.py | 15 +++++++++++----
 2 files changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/091f1976/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 75ed2dc..b39532b 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -88,7 +88,7 @@ BINARY_EXTENSIONS = frozenset([
     ".mp4", ".mp4a", ".mpeg", ".mpg", ".mpga", ".mxu", ".nef", ".npx", ".o", ".oga", ".ogg", ".ogv", ".otf", ".pbm",
     ".pcx", ".pdf", ".pea", ".pgm", ".pic", ".png", ".pnm", ".ppm", ".psd", ".pya", ".pyc", ".pyo", ".pyv", ".qt",
     ".rar", ".ras", ".raw", ".rgb", ".rip", ".rlc", ".rz", ".s3m", ".s7z", ".scpt", ".sgi", ".shar", ".sil", ".smv",
-    ".so", ".sub", ".swf", ".tar", ".tbz2", ".tga", ".tgz", ".tif", ".tiff", ".tlz", ".ts", ".ttf", ".uvh", ".uvi",
+    ".so", ".sub", ".swf", ".tar", ".tbz2", ".tga", ".tgz", ".tif", ".tiff", ".tlz", ".ttf", ".uvh", ".uvi",
     ".uvm", ".uvp", ".uvs", ".uvu", ".viv", ".vob", ".war", ".wav", ".wax", ".wbmp", ".wdp", ".weba", ".webm", ".webp",
     ".whl", ".wm", ".wma", ".wmv", ".wmx", ".woff", ".woff2", ".wvx", ".xbm", ".xif", ".xm", ".xpi", ".xpm", ".xwd",
     ".xz", ".z", ".zip", ".zipx"
@@ -1485,12 +1485,13 @@ class Blob(object):
         Return true if file is a text file that can be displayed.
         :return: boolean
         '''
+        if self.extension in self.repo._additional_viewable_extensions:
+            return True
         if self.extension in BINARY_EXTENSIONS:
             return False
         if (self.content_type.startswith('text/') or
                 self.extension in VIEWABLE_EXTENSIONS or
                 self.extension in PYPELINE_EXTENSIONS or
-                self.extension in self.repo._additional_viewable_extensions or
                 utils.is_text_file(self.text)):
             return True
         return False

http://git-wip-us.apache.org/repos/asf/allura/blob/091f1976/Allura/allura/tests/unit/test_repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_repo.py b/Allura/allura/tests/unit/test_repo.py
index 2e52ebe..f3e0a25 100644
--- a/Allura/allura/tests/unit/test_repo.py
+++ b/Allura/allura/tests/unit/test_repo.py
@@ -153,16 +153,16 @@ class TestTree(unittest.TestCase):
 class TestBlob(unittest.TestCase):
 
     def test_pypeline_view(self):
-        blob = M.repository.Blob(Mock(), 'INSTALL.mdown', 'blob1')
+        blob = M.repository.Blob(MagicMock(), 'INSTALL.mdown', 'blob1')
         assert_equal(blob.has_pypeline_view, True)
 
     def test_has_html_view_text_mime(self):
-        blob = M.repository.Blob(Mock(), 'INSTALL', 'blob1')
+        blob = M.repository.Blob(MagicMock(), 'INSTALL', 'blob1')
         blob.content_type = 'text/plain'
         assert_equal(blob.has_html_view, True)
 
     def test_has_html_view_text_ext(self):
-        blob = M.repository.Blob(Mock(), 'INSTALL.txt', 'blob1')
+        blob = M.repository.Blob(MagicMock(), 'INSTALL.txt', 'blob1')
         blob.content_type = 'foo/bar'
         assert_equal(blob.has_html_view, True)
 
@@ -173,7 +173,7 @@ class TestBlob(unittest.TestCase):
         assert_equal(blob.has_html_view, True)
 
     def test_has_html_view_bin_ext(self):
-        blob = M.repository.Blob(Mock(), 'INSTALL.zip', 'blob1')
+        blob = M.repository.Blob(MagicMock(), 'INSTALL.zip', 'blob1')
         assert_equal(blob.has_html_view, False)
 
     def test_has_html_view_bin_content(self):
@@ -182,6 +182,13 @@ class TestBlob(unittest.TestCase):
         blob.text = '\0\0\0\0'
         assert_equal(blob.has_html_view, False)
 
+    def test_has_html_view__local_setting_override_bin(self):
+        blob = M.repository.Blob(MagicMock(), 'myfile.dat', 'blob1')
+        blob.content_type = 'whatever'
+        blob.text = '\0\0\0\0'
+        blob.repo._additional_viewable_extensions = ['.dat']
+        assert_equal(blob.has_html_view, True)
+
 
 class TestCommit(unittest.TestCase):