diff --git a/raycast/repos-list-clcreative.py b/raycast/repos-list-clcreative.py index a85e48c..38ce4e5 100755 --- a/raycast/repos-list-clcreative.py +++ b/raycast/repos-list-clcreative.py @@ -14,7 +14,9 @@ from dotenv import load_dotenv import os +from pathlib import Path from github import Github +from git import Repo load_dotenv() @@ -30,11 +32,27 @@ ignored_folders = [ if __name__ == "__main__": try: repos = g.get_organization('clcreative').get_repos() + missing_repos = [] - for repo in repos: - print(repo.name) + if repos is not None: + for repo in repos: + # set repo path on local workstation + repo_path = f'{ Path.home() }/projects/{repo.owner.login}/{repo.name}' - print(f"Total repos: {repos.totalCount}") + current_repo = Repo(f"{ Path.home() }/projects/{repo.owner.login}/{repo.name}") + + # when repo is not existing + if not os.path.exists(repo_path): + missing_repos.append(repo.name) + print(f"\033[0;31m○\033[0m {repo.name}") + else: + # check if repo has untracked files + if current_repo.untracked_files: + print(f"\033[0;33m●\033[0m {repo.name} (untracked files)") + elif current_repo.is_dirty(): + print(f"\033[0;33m●\033[0m {repo.name} (dirty))") + else: + print(f"\033[0;32m●\033[0m {repo.name}") except Exception as e: print(f"error: {e}") diff --git a/testing/git-repos.py b/testing/git-repos.py new file mode 100644 index 0000000..0b44aef --- /dev/null +++ b/testing/git-repos.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 + +from dotenv import load_dotenv +import os +from pathlib import Path +from github import Github +from git import Repo + + +load_dotenv() + +g = Github(os.getenv("GITHUB_TOKEN")) + +ignored_folders = [ + '.git', + '.DS_Store', + '.obsidian', +] + +if __name__ == "__main__": + try: + repos = g.get_organization('clcreative').get_repos() + + if repos is not None: + for repo in repos: + # check if repo has updates + # set repo path on local workstation + repo_path = f'{ Path.home() }/projects/{repo.owner.login}/{repo.name}' + + current_repo = Repo(f"{ Path.home() }/projects/{repo.owner.login}/{repo.name}") + + # when repo is not existing + if not os.path.exists(repo_path): + print(f"\033[0;31m○\033[0m {repo.name}") + else: + # check if repo has untracked files + if current_repo.untracked_files: + print(f"\033[0;33m●\033[0m {repo.name} (untracked files)") + elif current_repo.is_dirty(): + print(f"\033[0;33m●\033[0m {repo.name} (dirty))") + else: + print(f"\033[0;32m●\033[0m {repo.name}") + + except Exception as e: + print(f"error: {e}")