diff options
| -rw-r--r-- | reposync.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/reposync.py b/reposync.py index 9e0524b..f520e47 100644 --- a/reposync.py +++ b/reposync.py @@ -1,5 +1,6 @@ from git import Repo from datetime import datetime +import os repoFile = open("repositories.txt", "r") @@ -8,18 +9,23 @@ while(True): if not line: break - repo = Repo(line.strip()) + line = line.strip() + now = datetime.now().strftime("[%H:%M:%S] ") + if not os.path.isdir(line): + print("\033[0;31m%s\033[0;0m \033[0;34m%s\033[0;0m is not a directory!"%(now, line)) + continue + + repo = Repo(line) if not repo.bare: - now = datetime.now().strftime("[%H:%M:%S] ") branch = repo.active_branch # Thanks to https://stackoverflow.com/a/65535263/12036073 if list(repo.iter_commits(f'{branch}..{branch}@{{u}}')): - print(now + line.strip() + "'s origin was updated, pulling...") + print("\033[0;31m%s\033[0;34m%s\033[0;0m\'s origin was updated, pulling..."%(now, line)) repo.remotes.origin.pull() else: - print(now + line.strip() + " is up to date") + print("\033[0;32m%s\033[0;34m%s\033[0;0m is up to date"%(now, line)) else: - print("Repository must not be bare!") + print("\033[0;31m%s\033[0;0m Repository \033[0;34m%s\033[0;0m must not be bare!"%(now, line)) repoFile.close() |
