mirror of
https://github.com/ChristianLempa/scripts.git
synced 2026-11-11 02:00:06 +01:00
fix list repos
This commit is contained in:
1 parent
f6aacd1e3d
commit
2f92dc3068
2 files changed
+66
-3
No files matched your search
@@ -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}")
|
||||
@@ -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}")
|
||||
Reference in new issue
Block a user