From dc67a9a7c6d93dd3a6a9b2cb2e001b11698432ba Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 20 May 2021 11:15:08 +0300 Subject: Moved repository paths to a file --- reposync.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'reposync.py') diff --git a/reposync.py b/reposync.py index 7cf156a..9e0524b 100644 --- a/reposync.py +++ b/reposync.py @@ -1,17 +1,25 @@ from git import Repo from datetime import datetime -repo = Repo("./") -if not repo.bare: - now = datetime.now().strftime("[%H:%M:%S] ") - branch = repo.active_branch +repoFile = open("repositories.txt", "r") - # Thanks to https://stackoverflow.com/a/65535263/12036073 - if list(repo.iter_commits(f'{branch}..{branch}@{{u}}')): - print(now + "Remote changes detected, pulling...") - repo.remotes.origin.pull() - else: - print(now + "Up to date") +while(True): + line = repoFile.readline() + if not line: + break -else: - print("Repository must not be bare!") + repo = Repo(line.strip()) + 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...") + repo.remotes.origin.pull() + else: + print(now + line.strip() + " is up to date") + else: + print("Repository must not be bare!") + +repoFile.close() -- cgit v1.2.3