aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--repositories.txt1
-rw-r--r--reposync.py32
2 files changed, 21 insertions, 12 deletions
diff --git a/repositories.txt b/repositories.txt
new file mode 100644
index 0000000..9c558e3
--- /dev/null
+++ b/repositories.txt
@@ -0,0 +1 @@
+.
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()