forked from gooberinc/goober
fuckass git
This commit is contained in:
parent
d3f3e64a96
commit
ee4f294b36
7 changed files with 52 additions and 89 deletions
|
@ -3,7 +3,8 @@ from modules.globalvars import *
|
|||
import requests
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger("goober")
|
||||
launched = False
|
||||
|
||||
# Run a shell command and return its output
|
||||
|
@ -27,11 +28,11 @@ def auto_update(branch='main', remote='origin'):
|
|||
if is_remote_ahead(branch, remote):
|
||||
print(_( "remote_ahead").format(remote=remote, branch=branch))
|
||||
pull_result = run_cmd(f'git pull {remote} {branch}')
|
||||
print(pull_result)
|
||||
print(_( "please_restart"))
|
||||
logger.info(pull_result)
|
||||
logger.info(_( "please_restart"))
|
||||
sys.exit(0)
|
||||
else:
|
||||
print(_( "local_ahead").format(remote=remote, branch=branch))
|
||||
logger.info(_( "local_ahead").format(remote=remote, branch=branch))
|
||||
|
||||
# Fetch the latest version info from the update server
|
||||
def get_latest_version_info():
|
||||
|
@ -40,10 +41,10 @@ def get_latest_version_info():
|
|||
if response.status_code == 200:
|
||||
return response.json()
|
||||
else:
|
||||
print(f"{RED}{_( 'version_error')} {response.status_code}{RESET}")
|
||||
logger.error(f"{RED}{_( 'version_error')} {response.status_code}{RESET}")
|
||||
return None
|
||||
except requests.RequestException as e:
|
||||
print(f"{RED}{_( 'version_error')} {e}{RESET}")
|
||||
logger.error(f"{RED}{_( 'version_error')} {e}{RESET}")
|
||||
return None
|
||||
|
||||
# Check if an update is available and perform update if needed
|
||||
|
@ -54,7 +55,7 @@ def check_for_update():
|
|||
|
||||
latest_version_info = get_latest_version_info()
|
||||
if not latest_version_info:
|
||||
print(f"{_('fetch_update_fail')}")
|
||||
logger.error(f"{_('fetch_update_fail')}")
|
||||
return None, None
|
||||
|
||||
latest_version = latest_version_info.get("version")
|
||||
|
@ -62,25 +63,25 @@ def check_for_update():
|
|||
download_url = latest_version_info.get("download_url")
|
||||
|
||||
if not latest_version or not download_url:
|
||||
print(f"{RED}{_(LOCALE, 'invalid_server')}{RESET}")
|
||||
logger.error(f"{RED}{_(LOCALE, 'invalid_server')}{RESET}")
|
||||
return None, None
|
||||
|
||||
# Check if local_version is valid
|
||||
if local_version == "0.0.0" or None:
|
||||
print(f"{RED}{_('cant_find_local_version')}{RESET}")
|
||||
logger.error(f"{RED}{_('cant_find_local_version')}{RESET}")
|
||||
return
|
||||
|
||||
# Compare local and latest versions
|
||||
if local_version < latest_version:
|
||||
print(f"{YELLOW}{_('new_version').format(latest_version=latest_version, local_version=local_version)}{RESET}")
|
||||
print(f"{YELLOW}{_('changelog').format(VERSION_URL=VERSION_URL)}{RESET}")
|
||||
logger.info(f"{YELLOW}{_('new_version').format(latest_version=latest_version, local_version=local_version)}{RESET}")
|
||||
logger.info(f"{YELLOW}{_('changelog').format(VERSION_URL=VERSION_URL)}{RESET}")
|
||||
auto_update()
|
||||
elif beta == True:
|
||||
print(f"{YELLOW}You are running an \"unstable\" version of Goober, do not expect it to work properly.\nVersion {local_version}{RESET}")
|
||||
logger.warning(f"You are running an \"unstable\" version of Goober, do not expect it to work properly.\nVersion {local_version}{RESET}")
|
||||
elif local_version > latest_version:
|
||||
print(f"{YELLOW}{_('modification_warning')}{RESET}")
|
||||
logger.warning(f"{_('modification_warning')}")
|
||||
elif local_version == latest_version:
|
||||
print(f"{GREEN}{_('latest_version')} {local_version}{RESET}")
|
||||
print(f"{_('latest_version2').format(VERSION_URL=VERSION_URL)}\n\n")
|
||||
logger.info(f"{_('latest_version')} {local_version}")
|
||||
logger.info(f"{_('latest_version2').format(VERSION_URL=VERSION_URL)}\n\n")
|
||||
launched = True
|
||||
return latest_version
|
Loading…
Add table
Add a link
Reference in a new issue