Skip to content

Commit

Permalink
Update updater.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Avinash Reddy authored Dec 16, 2019
1 parent 277f9fb commit 85b6a76
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions userbot/modules/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
This module updates the userbot based on Upstream revision
"""

from os import remove, execle, path
from os import remove, execle, path, makedirs
from shutil import rmtree
import asyncio
import sys

Expand Down Expand Up @@ -66,10 +67,15 @@ async def upstream(ups):
f'`[WARNING] Directory {error} does not seems to be a git repository.\
\nTry force-updating the userbot using .update now.`')
return
repo = Repo.init(basedir)
origin = repo.create_remote('master', UPSTREAM_REPO_URL)
repo.git.reset('--hard')
origin.pull('master')
if os.path.exists(f"{basepath}\.git")
repo = Repo.init(basedir)
repo.git.fetch(UPSTREAM_REPO_URL)
repo_worker.git.reset('--hard')
repo_worker.git.clean('-fdx')
else:
rmtree(basedir, ignore_errors=True)
makedirs(basedir)
Repo.clone_from(UPSTREAM_REPO_URL, basedir)
reqs_upgrade = await update_requirements()
await ups.edit(
'`Updated succesfully, check the commit history for changelog.\n'
Expand Down

0 comments on commit 85b6a76

Please sign in to comment.