aboutsummaryrefslogtreecommitdiff
path: root/reposync.py
blob: c78e8ea996b8426a0cc90dc0e9ac93a0eb18c53c (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...")
        # logic
    else:
        print(now + "Up to date")

else:
    print("Error")