blob: 7cf156a4d7b8ae35f1ae941cd50d7a080ca9d9e0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
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
# 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")
else:
print("Repository must not be bare!")
|