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 2022/05/23 15:57:26 UTC
[allura] 01/03: [#8431] avoid errors when a directory changes to file (blob) or symlink
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch db/8431
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 5334d906c7dccd90946704267f3f081cd0779ee9
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Fri May 20 13:08:09 2022 -0400
[#8431] avoid errors when a directory changes to file (blob) or symlink
---
Allura/allura/controllers/repository.py | 4 +++-
Allura/allura/model/repository.py | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 933b6f378..ad26a9fc5 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -896,9 +896,11 @@ class FileBrowser(BaseController):
:return:
'''
try:
- path, filename = os.path.split(self._blob.path())
a_ci = c.app.repo.commit(prev_commit)
a = a_ci.get_path(prev_file or self._blob.path())
+ if not isinstance(a, M.repository.Blob):
+ # could be a Tree (directory) in the previous commit, can't diff that!
+ raise TypeError()
apath = a.path()
except Exception:
# prev commit doesn't have the file
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index ddedc1cc3..71878952b 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -1362,6 +1362,9 @@ class Tree(MappedClass, RepoObject):
path = path.split('/')
obj = self
for p in path:
+ if isinstance(obj, Blob): # normally is Tree
+ # can get a Blob (incl git symlink in past) if it changed type in a commit
+ return None
try:
obj = obj[p]
except KeyError:
@@ -1478,7 +1481,6 @@ class Tree(MappedClass, RepoObject):
class Blob:
-
'''Lightweight object representing a file in the repo'''
def __init__(self, tree, name, _id):