def browse_revision(self, name, sha, path): """List folder or read file of given revision.""" repo = GitTools.load_repo(name) if not repo: return output("NOT_EXIST") # Load revision try: tree = git.Commit(repo, sha.decode("hex")).tree except: return output("BAD_REVISION") # Load path node = Revisions.navigate_path(tree, path) if node is None: return output("BAD_PATH") # List content of folder if node.type == "tree": data = Revisions.list_folder(node) # Read syntax-highlighted file else: data = Revisions.show_file(node) return output(data=data)
def revisions(self, name): """Return last revisions of given project.""" repo = GitTools.load_repo(name) if not repo: return output("NOT_EXIST") revs = Revisions.list(repo) return output(data=revs)