blob: 6aaf47d5799be3df40efdb975e0b8f03822c66e9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/usr/bin/python3
from git import Repo
from datetime import datetime
import os
repoFile = open("repositories.txt", "r")
while(True):
line = repoFile.readline().strip()
if not line:
break
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:
branch = repo.active_branch
# Thanks to https://stackoverflow.com/a/65535263/12036073
if list(repo.iter_commits(f'{branch}..{branch}@{{u}}')):
print(f'\033[0;31m{now}\033[0;34m{line}\033[0;0m\'s origin was updated, pulling...')
repo.remotes.origin.pull()
else:
print(f'\033[0;32m{now}\033[0;34m{line}\033[0;0m is up to date')
else:
print(f'\033[0;31m{now}\033[0;0m Repository \033[0;34m{line}\033[0;0m must not be bare!')
repoFile.close()
|