def make_template_context(self, repo, rev, path): try: repo = current_app.repo_map[repo] except KeyError: raise NotFound("No such repository %r" % repo) if rev is None: rev = repo.get_default_branch() if rev is None: raise NotFound("Empty repository") try: commit = repo.get_commit(rev) except KeyError: raise NotFound("No such commit %r" % rev) try: blob_or_tree = repo.get_blob_or_tree(commit, path) except KeyError: raise NotFound("File not found") self.context = { 'view': self.view_name, 'repo': repo, 'rev': rev, 'commit': commit, 'branches': repo.get_branch_names(exclude=rev), 'tags': repo.get_tag_names(), 'path': path, 'blob_or_tree': blob_or_tree, 'subpaths': list(subpaths(path)) if path else None, }
def make_template_context(self, repo, rev, path): repo, rev, path, commit = _get_repo_and_rev(repo, rev, path) try: submodule_rev = tree_lookup_path( repo.__getitem__, commit.tree, encode_for_git(path))[1] except KeyError: raise NotFound("Parent path for submodule missing") try: (submodule_url, submodule_path) = _get_submodule( repo, commit, encode_for_git(path)) except KeyError: submodule_url = None submodule_path = None # TODO(jelmer): Rather than printing an information page, # redirect to the page in klaus for the repository at # submodule_path, revision submodule_rev. self.context = { 'view': self.view_name, 'repo': repo, 'rev': rev, 'commit': commit, 'branches': repo.get_branch_names(exclude=rev), 'tags': repo.get_tag_names(), 'path': path, 'subpaths': list(subpaths(path)) if path else None, 'submodule_url': force_unicode(submodule_url), 'submodule_path': force_unicode(submodule_path), 'submodule_rev': force_unicode(submodule_rev), 'base_href': None, }
def make_template_context(self, repo, namespace, rev, path): repo, rev, path, commit = _get_repo_and_rev(repo, namespace, rev, path) try: submodule_rev = tree_lookup_path(repo.__getitem__, commit.tree, encode_for_git(path))[1] except KeyError: raise NotFound("Parent path for submodule missing") try: (submodule_url, submodule_path) = _get_submodule(repo, commit, encode_for_git(path)) except KeyError: submodule_url = None submodule_path = None # TODO(jelmer): Rather than printing an information page, # redirect to the page in klaus for the repository at # submodule_path, revision submodule_rev. self.context = { "view": self.view_name, "repo": repo, "rev": rev, "commit": commit, "branches": repo.get_branch_names(exclude=rev), "tags": repo.get_tag_names(), "path": path, "subpaths": list(subpaths(path)) if path else None, "submodule_url": force_unicode(submodule_url), "submodule_path": force_unicode(submodule_path), "submodule_rev": force_unicode(submodule_rev), "base_href": None, }
def make_template_context(self, repo, rev, path): repo, rev, path, commit = _get_repo_and_rev(repo, rev, path) try: submodule_rev = tree_lookup_path(repo.__getitem__, commit.tree, encode_for_git(path))[1] except KeyError: raise NotFound("Parent path for submodule missing") try: (submodule_url, submodule_path) = _get_submodule(repo, commit, encode_for_git(path)) except KeyError: submodule_url = None submodule_path = None # TODO(jelmer): Rather than printing an information page, # redirect to the page in klaus for the repository at # submodule_path, revision submodule_rev. self.context = { 'view': self.view_name, 'repo': repo, 'rev': rev, 'commit': commit, 'branches': repo.get_branch_names(exclude=rev), 'tags': repo.get_tag_names(), 'path': path, 'subpaths': list(subpaths(path)) if path else None, 'submodule_url': force_unicode(submodule_url), 'submodule_path': force_unicode(submodule_path), 'submodule_rev': force_unicode(submodule_rev), 'base_href': None, }
def make_template_context(self, repo, rev, path): try: repo = current_app.repos[repo] except KeyError: raise NotFound("No such repository %r" % repo) if rev is None: rev = repo.get_default_branch() if rev is None: raise NotFound("Empty repository") try: commit = repo.get_commit(rev) except KeyError: raise NotFound("No such commit %r" % rev) try: blob_or_tree = repo.get_blob_or_tree(commit, path) except KeyError: raise NotFound("File not found") self.context = { "view": self.view_name, "repo": repo, "rev": rev, "commit": commit, "branches": repo.get_branch_names(exclude=rev), "tags": repo.get_tag_names(), "path": path, "blob_or_tree": blob_or_tree, "subpaths": list(subpaths(path)) if path else None, }
def make_template_context(self, repo, rev, path): repo, rev, commit = _get_repo_and_rev(repo, rev) try: blob_or_tree = repo.get_blob_or_tree(commit, path) except KeyError: raise NotFound("File not found") self.context = { 'view': self.view_name, 'repo': repo, 'rev': rev, 'commit': commit, 'branches': repo.get_branch_names(exclude=rev), 'tags': repo.get_tag_names(), 'path': path, 'blob_or_tree': blob_or_tree, 'subpaths': list(subpaths(path)) if path else None, }
def make_context(self, repo, commit_id, path): try: repo = current_app.repo_map[repo] if commit_id is None: commit_id = repo.get_default_branch() commit = repo.get_ref_or_commit(commit_id) except KeyError: raise NotFound self.context = { 'view': self.view_name, 'repo': repo, 'commit_id': commit_id, 'commit': commit, 'branches': repo.get_branch_names(exclude=commit_id), 'tags': repo.get_tag_names(), 'path': path, 'subpaths': list(subpaths(path)) if path else None, }
def make_template_context(self, repo, namespace, rev, path): repo, rev, path, commit = _get_repo_and_rev(repo, namespace, rev, path) try: blob_or_tree = repo.get_blob_or_tree(commit, path) except KeyError: raise NotFound("File not found") self.context = { "view": self.view_name, "repo": repo, "namespace": namespace, "rev": rev, "commit": commit, "branches": repo.get_branch_names(exclude=rev), "tags": repo.get_tag_names(), "path": path, "blob_or_tree": blob_or_tree, "subpaths": list(subpaths(path)) if path else None, "base_href": None, }
def make_context(self, repo, commit_id, path): try: repo = current_app.repo_map[repo] if commit_id is None: commit_id = repo.get_default_branch() commit = repo.get_ref_or_commit(commit_id) except KeyError: raise NotFound readme = repo.get_tree(commit, "/README.html") self.context = { 'view': self.view_name, 'repo': repo, 'commit_id': commit_id, 'commit': commit, 'branches': repo.get_branch_names(exclude=commit_id), 'tags': repo.get_tag_names(), 'path': path, 'subpaths': list(subpaths(path)) if path else None, 'header': readme.data if hasattr(readme, 'data') else "", }
def get_context_data(self, **ctx): context = super(BaseRepoView, self).get_context_data(**ctx) repo = RepoManager.get_repo(self.kwargs['repo']) rev = self.kwargs.get('rev') path = self.kwargs.get('path') if isinstance(path, unicode): path = path.encode("utf-8") if isinstance(rev, unicode): rev = rev.encode("utf-8") if rev is None: rev = repo.get_default_branch() if rev is None: raise RepoException("Empty repository") try: commit = repo.get_commit(rev) except KeyError: raise RepoException("No such commit %r" % rev) try: blob_or_tree = repo.get_blob_or_tree(commit, path) except KeyError: raise RepoException("File not found") context.update({ 'view': self.view_name, 'repo': repo, 'rev': rev, 'commit': commit, 'branches': repo.get_branch_names(exclude=rev), 'tags': repo.get_tag_names(), 'path': path, 'blob_or_tree': blob_or_tree, 'subpaths': list(subpaths(path)) if path else None, }) return context
def get_context_data(self, **ctx): context = super(BaseRepoView, self).get_context_data(**ctx) repo = RepoManager.get_repo(self.kwargs['repo']) rev = self.kwargs.get('rev') path = self.kwargs.get('path') if isinstance(path, unicode): path = path.encode("utf-8") if rev is None: rev = repo.get_default_branch() if rev is None: raise RepoException("Empty repository") try: commit = repo.get_commit(rev) except KeyError: raise RepoException("No such commit %r" % rev) try: blob_or_tree = repo.get_blob_or_tree(commit, path) except KeyError: raise RepoException("File not found") context.update({ 'view': self.view_name, 'repo': repo, 'rev': rev, 'commit': commit, 'branches': repo.get_branch_names(exclude=rev), 'tags': repo.get_tag_names(), 'path': path, 'blob_or_tree': blob_or_tree, 'subpaths': list(subpaths(path)) if path else None, }) return context