[11] add branch detection

This commit is contained in:
meisnate12 2023-01-19 14:38:55 -05:00
parent 220e7020c7
commit f5993e36be
4 changed files with 25 additions and 5 deletions

View file

@ -1 +1 @@
1.18.3-develop10
1.18.3-develop11

View file

@ -103,6 +103,20 @@ parental_labels = [f"{t.capitalize()}:{v}" for t in parental_types for v in pare
previous_time = None
start_time = None
def guess_branch(version, env_version, git_branch):
if git_branch:
return git_branch
elif env_version in ["nightly", "develop"]:
return env_version
elif version[2] > 0:
dev_version = get_develop()
if version[1] != dev_version[1] or version[2] <= dev_version[2]:
return "develop"
else:
return "nightly"
else:
return "master"
def current_version(version, env_version=None, nightly=False):
if nightly or env_version == "nightly":
return get_nightly()

View file

@ -6,6 +6,7 @@ from modules.logs import MyLogger
try:
import plexapi, requests, schedule
from git import Repo, InvalidGitRepositoryError
from PIL import ImageFile
from plexapi import server
from plexapi.exceptions import NotFound
@ -80,6 +81,10 @@ def get_arg(env_str, default, arg_bool=False, arg_int=False):
else:
return default
try:
git_branch = Repo(path=".").head.ref.name
except InvalidGitRepositoryError:
git_branch = None
env_version = get_arg("BRANCH_NAME", "master")
is_docker = get_arg("PMM_DOCKER", False, arg_bool=True)
is_linuxserver = get_arg("PMM_LINUXSERVER", False, arg_bool=True)
@ -163,6 +168,8 @@ with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "VERSION")) a
if len(line) > 0:
version = util.parse_version(line)
break
branch = util.guess_branch(version, env_version, git_branch)
version = (version[0].replace("develop", branch), version[1].replace("develop", branch), version[2])
uuid_file = os.path.join(default_dir, "UUID")
uuid_num = None
@ -196,9 +203,7 @@ def start(attrs):
logger.info_center("|_| |_|\\___/_/\\_\\ |_| |_|\\___|\\__\\__,_| |_| |_|\\__,_|_| |_|\\__,_|\\__, |\\___|_| ")
logger.info_center(" |___/ ")
system_ver = "Docker" if is_docker else "Linuxserver" if is_linuxserver else f"Python {platform.python_version()}"
logger.info(f" Version: {version[0]} ({system_ver})")
logger.trace(f"BRANCH_NAME: {test_value}")
logger.trace(f"env_version: {env_version}")
logger.info(f" Version: {version[0]} ({system_ver}){f' (Git: {git_branch})' if git_branch else ''}")
latest_version = util.current_version(version, env_version=env_version)
new_version = latest_version[0] if latest_version and (version[1] != latest_version[1] or (version[2] and version[2] < latest_version[2])) else None
if new_version:

View file

@ -10,4 +10,5 @@ retrying==1.3.4
pathvalidate==2.5.2
pillow==9.4.0
num2words==0.5.12
psutil==5.9.4
psutil==5.9.4
GitPython==3.1.30