Fix the __nonzero__ method for WikiPage

This commit is contained in:
Chase Sterling 2016-07-05 20:29:01 -04:00
rodič 7a20135d55
revize 2e6db650f2
1 změnil soubory, kde provedl 9 přidání a 3 odebrání

Zobrazit soubor

@ -5,8 +5,9 @@ import ghdiff
import gittle.utils
import yaml
from gittle import Gittle
from dulwich.object_store import tree_lookup_path
from dulwich.repo import NotGitRepository
from realms.lib.util import to_canonical, cname_to_filename, filename_to_cname
from realms.lib.util import cname_to_filename, filename_to_cname
from realms import cache
from realms.lib.hook import HookMixin
@ -311,5 +312,10 @@ class WikiPage(object):
return ghdiff.diff(old.data, self.data)
def __nonzero__(self):
# TODO: Check if page is in index of self.sha
return bool(self.data)
# Verify this file is in the tree for the given commit sha
try:
tree_lookup_path(self.wiki.repo.get_object, self.wiki.repo[self.sha].tree, self.filename)
except KeyError:
# We'll get a KeyError if self.sha isn't in the repo, or if self.filename isn't in the tree of our commit
return False
return True