-
Notifications
You must be signed in to change notification settings - Fork 0
/
pusher.py
44 lines (38 loc) · 1.27 KB
/
pusher.py
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
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
#####################################################################################################################
#
# Copyright (c) 2020 Bernhard Flühmann. All rights reserved.
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
#
######################################################################################################################
from datetime import date
from datetime import datetime
import time
import json
import logging
import git
# TODO: Improve logging
# TODO: Improve comments
### Git Repository
class Pusher():
def setup(self, git_dir):
# Load Repo
self.repo = git.Repo(git_dir)
# Get current state
self.current = self.repo.head.commit
self.repo.remotes.origin.pull()
if self.current == self.repo.head.commit:
logging.info("Git Pusher setup: Git Repository up to date")
else:
logging.info("Git Pusher setup: Git Repository updated")
def run(self):
git = self.repo.git
#git.add('Sheet_4_(d)_Full_Data_data.csv')
#git.add('foph_covid19_data_converted_unix.csv')
#git.add('last_update.txt')
git.add('data/*')
commit_message = "Data updated: "
self.repo.index.commit(commit_message)
git.push()