You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2019/11/19 21:20:49 UTC
[allura] branch master updated: [#8341] fix for when diffing on a
file's first appearance
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/master by this push:
new 25cbf9a [#8341] fix for when diffing on a file's first appearance
25cbf9a is described below
commit 25cbf9a8b0c6da32f2e1a46a5c437fc1ac76e2d3
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Tue Nov 19 16:20:38 2019 -0500
[#8341] fix for when diffing on a file's first appearance
---
Allura/allura/controllers/repository.py | 4 ++--
Allura/allura/model/repository.py | 18 ++++++++++++++++++
ForgeGit/forgegit/tests/functional/test_controllers.py | 10 ++++++++++
3 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 0b8e87c..cc05da3 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -892,9 +892,9 @@ class FileBrowser(BaseController):
a_ci = c.app.repo.commit(prev_commit)
a = a_ci.get_path(prev_file or self._blob.path())
apath = a.path()
- except:
+ except Exception:
# prev commit doesn't have the file
- a = []
+ a = M.repository.EmptyBlob()
apath = ''
b = self._blob
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 203e3ef..3151b5a 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -1523,6 +1523,24 @@ class Blob(object):
return self.open().read()
+class EmptyBlob(Blob):
+ def __init__(self):
+ pass
+
+ def open(self):
+ return ''
+
+ @property
+ def size(self):
+ return 0
+
+ def __nonzero__(self):
+ return False
+
+ def __bool__(self):
+ return False
+
+
class LastCommit(RepoObject):
def __repr__(self):
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index 4b0c079..61b821d 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -307,6 +307,16 @@ class TestRootController(_TestCase):
assert fn + '&diformat=regular">Switch to unified view</a>' in r
assert '<table class="side-by-side-diff">' in r
+ def test_diff_view_mode_first_commit_of_file(self):
+ ci = self._get_ci()
+ fn = 'tree/README?diff=9a7df788cf800241e3bb5a849c8870f2f8259d98'
+ r = self.app.get(ci + fn + '&diformat=regular')
+ assert fn + '&diformat=sidebyside">Switch to side-by-side view</a>' in r
+
+ r = self.app.get(ci + fn + '&diformat=sidebyside')
+ assert fn + '&diformat=regular">Switch to unified view</a>' in r
+ assert '<table class="side-by-side-diff">' in r
+
def test_file_force_display(self):
ci = self._get_ci()
resp = self.app.get(ci + 'tree/README?force=True')