def _move_root(forward, prefix=''): root = GitRoot.ROOT container = GitRoot.root_container() roots = sorted(File.each(path=container, select=GitRoot.select(prefix))) if roots: try: index = roots.index(root) except ValueError: print(roots[0] if forward else roots[-1]) return index += (1 if forward else -1) path = roots[index % len(roots)] sub = os.path.join(path, os.path.relpath(os.getcwd(), root)) print((sub if os.path.exists(sub) else path) or '.') else: print('.')