-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathupdate.py
More file actions
29 lines (21 loc) · 1 KB
/
update.py
File metadata and controls
29 lines (21 loc) · 1 KB
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
from subprocess import run as srun
import logging
from os import path as ospath
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[logging.FileHandler('log.txt'), logging.StreamHandler()],
level=logging.INFO)
UPSTREAM_REPO = 'https://github.com/abhinai2244/Encoding-Bot.git'
UPSTREAM_BRANCH = 'master'
if UPSTREAM_REPO is not None:
if ospath.exists('.git'):
srun(["rm", "-rf", ".git"])
update = srun([f"git init -q \
&& git add . \
&& git commit -sm update -q \
&& git remote add origin {UPSTREAM_REPO} \
&& git fetch origin -q \
&& git reset --hard origin/{UPSTREAM_BRANCH} -q"], shell=True)
if update.returncode == 0:
logging.info('Successfully updated with latest commit from UPSTREAM_REPO')
else:
logging.error('Something went wrong while updating, check UPSTREAM_REPO if valid or not!')