def get_git_object_type(self, tree, path): """ Returns the filemode of the git object with the relative path <path>. :param tree: a `pygit2.Tree` instance :param path: the relative path of the object :type entry_name: str :returns: the filemode for the entry in case of success (which can be one of the following) or None otherwise. 0 (0000000) GIT_FILEMODE_NEW 16384 (0040000) GIT_FILEMODE_TREE 33188 (0100644) GIT_FILEMODE_BLOB 33261 (0100755) GIT_FILEMODE_BLOB_EXECUTABLE 40960 (0120000) GIT_FILEMODE_LINK 57344 (0160000) GIT_FILEMODE_COMMIT :rtype: int, None """ path_components = split_path_into_components(path) try: return self._get_git_object(tree, path_components[-1], path_components, lambda entry: entry.filemode) except: return GIT_FILEMODE_TREE
def get_git_object(self, tree, path): """ Returns the git object with the relative path <path>. :param tree: a `pygit2.Tree` instance :param path: the relative path of the object :type path: str :returns: an instance corresponding to the object that is being searched for in case of success, or None else. :rtype: one of the following: an intance of `pygit2.Tree` an intance of `pygit2.Blob` None """ # It acts as a proxy for the _get_git_object method, which # does the actual searching. path_components = split_path_into_components(path) return self._get_git_object(tree, path_components[-1], path_components, lambda entry: self._repo[entry.id])