mirror of
https://github.com/ail-project/ail-framework.git
synced 2025-01-18 16:36:13 +00:00
chg: [updater] use tag subversion, ex:v6.0.1
This commit is contained in:
parent
8404f1fdb5
commit
76369d71b4
1 changed files with 106 additions and 90 deletions
194
bin/Update.py
194
bin/Update.py
|
@ -38,7 +38,7 @@ def auto_update_enabled(cfg):
|
||||||
# check if files are modify locally
|
# check if files are modify locally
|
||||||
def check_if_files_modified():
|
def check_if_files_modified():
|
||||||
# return True
|
# return True
|
||||||
process = subprocess.run(['git', 'ls-files' ,'-m'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(['git', 'ls-files', '-m'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
modified_files = process.stdout
|
modified_files = process.stdout
|
||||||
if modified_files:
|
if modified_files:
|
||||||
|
@ -50,7 +50,7 @@ def check_if_files_modified():
|
||||||
if l_modified_files:
|
if l_modified_files:
|
||||||
print('Modified Files:')
|
print('Modified Files:')
|
||||||
for modified_file in l_modified_files:
|
for modified_file in l_modified_files:
|
||||||
print('{}{}{}'.format(TERMINAL_BLUE, modified_file, TERMINAL_DEFAULT))
|
print(f'{TERMINAL_BLUE}{modified_file}{TERMINAL_DEFAULT}')
|
||||||
print()
|
print()
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
@ -58,7 +58,7 @@ def check_if_files_modified():
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
print(f'{TERMINAL_RED}{process.stderr.decode()}{TERMINAL_DEFAULT}')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def repo_is_fork():
|
def repo_is_fork():
|
||||||
|
@ -68,8 +68,8 @@ def repo_is_fork():
|
||||||
|
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
res = process.stdout.decode()
|
res = process.stdout.decode()
|
||||||
if 'origin {}'.format(AIL_REPO) in res:
|
if f'origin {AIL_REPO}' in res:
|
||||||
print(' This repository is a {}clone of {}{}'.format(TERMINAL_BLUE, AIL_REPO, TERMINAL_DEFAULT))
|
print(f' This repository is a {TERMINAL_BLUE}clone of {AIL_REPO}{TERMINAL_DEFAULT}')
|
||||||
return False
|
return False
|
||||||
elif 'origin {}'.format(OLD_AIL_REPO) in res:
|
elif 'origin {}'.format(OLD_AIL_REPO) in res:
|
||||||
print(' old AIL repository, Updating remote origin...')
|
print(' old AIL repository, Updating remote origin...')
|
||||||
|
@ -79,11 +79,11 @@ def repo_is_fork():
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print(' This repository is a {}fork{}'.format(TERMINAL_BLUE, TERMINAL_DEFAULT))
|
print(f' This repository is a {TERMINAL_BLUE}fork{TERMINAL_DEFAULT}')
|
||||||
print()
|
print()
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
print(f'{TERMINAL_RED}{process.stderr.decode()}{TERMINAL_DEFAULT}')
|
||||||
aborting_update()
|
aborting_update()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
@ -96,12 +96,12 @@ def is_upstream_created(upstream):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
print(f'{TERMINAL_RED}{process.stderr.decode()}{TERMINAL_DEFAULT}')
|
||||||
aborting_update()
|
aborting_update()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def create_fork_upstream(upstream):
|
def create_fork_upstream(upstream):
|
||||||
print('{}... Creating upstream ...{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
print(f'{TERMINAL_YELLOW}... Creating upstream ...{TERMINAL_DEFAULT}')
|
||||||
print('git remote add {} {}'.format(upstream, AIL_REPO))
|
print('git remote add {} {}'.format(upstream, AIL_REPO))
|
||||||
process = subprocess.run(['git', 'remote', 'add', upstream, AIL_REPO],
|
process = subprocess.run(['git', 'remote', 'add', upstream, AIL_REPO],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
@ -109,51 +109,51 @@ def create_fork_upstream(upstream):
|
||||||
print(process.stdout.decode())
|
print(process.stdout.decode())
|
||||||
if is_upstream_created(upstream):
|
if is_upstream_created(upstream):
|
||||||
print('Fork upstream created')
|
print('Fork upstream created')
|
||||||
print('{}... ...{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
print(f'{TERMINAL_YELLOW}... ...{TERMINAL_DEFAULT}')
|
||||||
else:
|
else:
|
||||||
print('Fork not created')
|
print('Fork not created')
|
||||||
aborting_update()
|
aborting_update()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
print(f'{TERMINAL_RED}{process.stderr.decode()}{TERMINAL_DEFAULT}')
|
||||||
aborting_update()
|
aborting_update()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def update_fork():
|
def update_fork():
|
||||||
print('{}... Updating fork ...{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
print(f'{TERMINAL_YELLOW}... Updating fork ...{TERMINAL_DEFAULT}')
|
||||||
if cfg.get('Update', 'update-fork') == 'True' or cfg.get('Update', 'update-fork') == 'true':
|
if cfg.get('Update', 'update-fork') == 'True' or cfg.get('Update', 'update-fork') == 'true':
|
||||||
upstream = cfg.get('Update', 'upstream')
|
upstream = cfg.get('Update', 'upstream')
|
||||||
if not is_upstream_created(upstream):
|
if not is_upstream_created(upstream):
|
||||||
create_fork_upstream(upstream)
|
create_fork_upstream(upstream)
|
||||||
print('{}git fetch {}:{}'.format(TERMINAL_YELLOW, upstream, TERMINAL_DEFAULT))
|
print(f'{TERMINAL_YELLOW}git fetch {upstream}:{TERMINAL_DEFAULT}')
|
||||||
process = subprocess.run(['git', 'fetch', upstream], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(['git', 'fetch', upstream], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
print(process.stdout.decode())
|
print(process.stdout.decode())
|
||||||
print('{}git checkout master:{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
print(f'{TERMINAL_YELLOW}git checkout master:{TERMINAL_DEFAULT}')
|
||||||
process = subprocess.run(['git', 'checkout', 'master'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(['git', 'checkout', 'master'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
print(process.stdout.decode())
|
print(process.stdout.decode())
|
||||||
print('{}git merge {}/master:{}'.format(TERMINAL_YELLOW, upstream, TERMINAL_DEFAULT))
|
print(f'{TERMINAL_YELLOW}git merge {upstream}/master:{TERMINAL_DEFAULT}')
|
||||||
process = subprocess.run(['git', 'merge', '{}/master'.format(upstream)],
|
process = subprocess.run(['git', 'merge', f'{upstream}/master'],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
print(process.stdout.decode())
|
print(process.stdout.decode())
|
||||||
print('{}... ...{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
print(f'{TERMINAL_YELLOW}... ...{TERMINAL_DEFAULT}')
|
||||||
else:
|
else:
|
||||||
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
print(f'{TERMINAL_RED}{process.stderr.decode()}{TERMINAL_DEFAULT}')
|
||||||
aborting_update()
|
aborting_update()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
print(f'{TERMINAL_RED}{process.stderr.decode()}{TERMINAL_DEFAULT}')
|
||||||
aborting_update()
|
aborting_update()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
print(f'{TERMINAL_RED}{process.stderr.decode()}{TERMINAL_DEFAULT}')
|
||||||
aborting_update()
|
aborting_update()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print('{}Fork Auto-Update disabled in config file{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
print(f'{TERMINAL_YELLOW}Fork Auto-Update disabled in config file{TERMINAL_YELLOW}')
|
||||||
aborting_update()
|
aborting_update()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
@ -169,36 +169,74 @@ def get_git_current_tag(path_current_version):
|
||||||
|
|
||||||
version = version.replace(" ", "").splitlines()[0]
|
version = version.replace(" ", "").splitlines()[0]
|
||||||
if version[0] != 'v':
|
if version[0] != 'v':
|
||||||
version = 'v{}'.format(version)
|
version = f'v{version}'
|
||||||
return version
|
return version
|
||||||
|
|
||||||
def get_git_upper_tags_remote(current_tag, is_fork):
|
def _sort_version_tags(versions, current_version):
|
||||||
# keep only first dot
|
tags = {}
|
||||||
nb_dot = current_tag.count('.')
|
rcurrent_version = current_version.split('.')
|
||||||
if nb_dot > 0:
|
if len(rcurrent_version) == 2:
|
||||||
nb_dot = nb_dot - 1
|
curr_version, curr_subversion = rcurrent_version
|
||||||
current_tag_val = current_tag.rsplit('.', nb_dot)
|
curr_sub_release = None
|
||||||
current_tag_val = ''.join(current_tag_val)
|
else: # len(rcurrent_version) == 3
|
||||||
|
curr_version, curr_subversion, curr_sub_release = rcurrent_version
|
||||||
|
curr_sub_release = int(curr_sub_release)
|
||||||
|
curr_version = int(curr_version[1:])
|
||||||
|
curr_subversion = int(curr_subversion)
|
||||||
|
|
||||||
|
for v in versions:
|
||||||
|
ver = v.split('.')
|
||||||
|
if len(ver) == 2:
|
||||||
|
version, subversion = ver
|
||||||
|
sub_release = None
|
||||||
|
elif len(ver) == 3:
|
||||||
|
version, subversion, sub_release = ver
|
||||||
|
sub_release = int(sub_release)
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
version = int(version[1:])
|
||||||
|
subversion = int(subversion)
|
||||||
|
if version not in tags:
|
||||||
|
tags[version] = {}
|
||||||
|
if subversion not in tags[version]:
|
||||||
|
tags[version][subversion] = set()
|
||||||
|
if sub_release is not None:
|
||||||
|
tags[version][subversion].add(sub_release)
|
||||||
|
|
||||||
|
sorted_versions = []
|
||||||
|
for version in sorted(tags.keys()):
|
||||||
|
if version < curr_version:
|
||||||
|
continue
|
||||||
|
for subversion in sorted(tags[version].keys()):
|
||||||
|
if version == curr_version and subversion < curr_subversion:
|
||||||
|
continue
|
||||||
|
if tags[version][subversion]:
|
||||||
|
r_tag = f'v{version}.{subversion}'
|
||||||
|
if r_tag in versions:
|
||||||
|
if version != curr_version and subversion != curr_subversion:
|
||||||
|
sorted_versions.append(r_tag)
|
||||||
|
for sub_release in sorted(tags[version][subversion]):
|
||||||
|
if curr_sub_release:
|
||||||
|
if version == curr_version and subversion == curr_subversion and sub_release < curr_sub_release:
|
||||||
|
continue
|
||||||
|
sorted_versions.append(f'v{version}.{subversion}.{sub_release}')
|
||||||
|
else:
|
||||||
|
sorted_versions.append(f'v{version}.{subversion}')
|
||||||
|
if sorted_versions[0] == current_version:
|
||||||
|
sorted_versions = sorted_versions[1:]
|
||||||
|
return sorted_versions
|
||||||
|
|
||||||
|
|
||||||
|
def get_git_upper_tags_remote(current_tag, is_fork):
|
||||||
if is_fork:
|
if is_fork:
|
||||||
process = subprocess.run(['git', 'tag'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(['git', 'tag'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
list_all_tags = process.stdout.decode().splitlines()
|
list_all_tags = process.stdout.decode().splitlines()
|
||||||
|
|
||||||
list_upper_tags = []
|
list_upper_tags = _sort_version_tags(list_all_tags, current_tag)
|
||||||
if list_all_tags[-1][1:] == current_tag:
|
|
||||||
list_upper_tags.append((list_all_tags[-1], None))
|
|
||||||
# force update order
|
|
||||||
list_upper_tags.sort()
|
|
||||||
return list_upper_tags
|
|
||||||
for tag in list_all_tags:
|
|
||||||
if float(tag[1:]) >= float(current_tag_val):
|
|
||||||
list_upper_tags.append((tag, None))
|
|
||||||
# force update order
|
|
||||||
list_upper_tags.sort()
|
|
||||||
return list_upper_tags
|
return list_upper_tags
|
||||||
else:
|
else:
|
||||||
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
print(f'{TERMINAL_RED}{process.stderr.decode()}{TERMINAL_DEFAULT}')
|
||||||
aborting_update()
|
aborting_update()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
|
@ -222,48 +260,27 @@ def get_git_upper_tags_remote(current_tag, is_fork):
|
||||||
|
|
||||||
tag = tag.replace('^{}', '')
|
tag = tag.replace('^{}', '')
|
||||||
# remove 'v' version
|
# remove 'v' version
|
||||||
tag = tag.replace('v', '')
|
|
||||||
# keep only first dot
|
|
||||||
nb_dot = tag.count('.')
|
|
||||||
if nb_dot > 0:
|
|
||||||
nb_dot = nb_dot - 1
|
|
||||||
tag_val = tag.rsplit('.', nb_dot)
|
|
||||||
tag_val = ''.join(tag_val)
|
|
||||||
|
|
||||||
# check if tag is float
|
|
||||||
try:
|
|
||||||
tag_val = float(tag_val)
|
|
||||||
except ValueError:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if float(current_tag) < 5.0:
|
|
||||||
# add tag with last commit
|
|
||||||
if float(current_tag_val) <= float(tag_val) < float(5.0):
|
|
||||||
dict_tags_commit[tag] = commit
|
dict_tags_commit[tag] = commit
|
||||||
else:
|
|
||||||
# add tag with last commit
|
sorted_tags = _sort_version_tags(dict_tags_commit.keys(), current_tag)
|
||||||
if float(tag_val) >= float(current_tag_val):
|
list_upper_tags = [(key, dict_tags_commit[key]) for key in sorted_tags]
|
||||||
dict_tags_commit[tag] = commit
|
|
||||||
list_upper_tags = [('v{}'.format(key), dict_tags_commit[key]) for key in dict_tags_commit]
|
|
||||||
# force update order
|
|
||||||
list_upper_tags.sort()
|
|
||||||
return list_upper_tags
|
return list_upper_tags
|
||||||
else:
|
else:
|
||||||
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
print(f'{TERMINAL_RED}{process.stderr.decode()}{TERMINAL_DEFAULT}')
|
||||||
aborting_update()
|
aborting_update()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def update_submodules():
|
def update_submodules():
|
||||||
print('{}git submodule update:{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
print(f'{TERMINAL_YELLOW}git submodule update:{TERMINAL_DEFAULT}')
|
||||||
process = subprocess.run(['git', 'submodule', 'update'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(['git', 'submodule', 'update'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
print(process.stdout.decode())
|
print(process.stdout.decode())
|
||||||
print()
|
print()
|
||||||
else:
|
else:
|
||||||
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
print(f'{TERMINAL_RED}{process.stderr.decode()}{TERMINAL_DEFAULT}')
|
||||||
|
|
||||||
def update_ail(current_tag, list_upper_tags_remote, current_version_path, is_fork):
|
def update_ail(current_tag, list_upper_tags_remote, current_version_path, is_fork):
|
||||||
print('{}git checkout master:{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
print(f'{TERMINAL_YELLOW}git checkout master:{TERMINAL_DEFAULT}')
|
||||||
process = subprocess.run(['git', 'checkout', 'master'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(['git', 'checkout', 'master'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
# process = subprocess.run(['ls'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
# process = subprocess.run(['ls'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
|
@ -281,14 +298,14 @@ def update_ail(current_tag, list_upper_tags_remote, current_version_path, is_for
|
||||||
roll_back_update('2c65194b94dab95df9b8da19c88d65239f398355')
|
roll_back_update('2c65194b94dab95df9b8da19c88d65239f398355')
|
||||||
pulled = True
|
pulled = True
|
||||||
else:
|
else:
|
||||||
print('{}git pull:{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
print(f'{TERMINAL_YELLOW}git pull:{TERMINAL_DEFAULT}')
|
||||||
process = subprocess.run(['git', 'pull'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(['git', 'pull'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
output = process.stdout.decode()
|
output = process.stdout.decode()
|
||||||
print(output)
|
print(output)
|
||||||
pulled = True
|
pulled = True
|
||||||
else:
|
else:
|
||||||
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
print(f'{TERMINAL_RED}{process.stderr.decode()}{TERMINAL_DEFAULT}')
|
||||||
aborting_update()
|
aborting_update()
|
||||||
pulled = False
|
pulled = False
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -340,7 +357,7 @@ def update_ail(current_tag, list_upper_tags_remote, current_version_path, is_for
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
print(f'{TERMINAL_RED}{process.stderr.decode()}{TERMINAL_DEFAULT}')
|
||||||
aborting_update()
|
aborting_update()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
@ -368,15 +385,15 @@ def launch_update_version(version, roll_back_commit, current_version_path, is_fo
|
||||||
with open(current_version_path, 'w') as version_content:
|
with open(current_version_path, 'w') as version_content:
|
||||||
version_content.write(version)
|
version_content.write(version)
|
||||||
|
|
||||||
print('{}-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'.format(TERMINAL_YELLOW))
|
print(f'{TERMINAL_YELLOW}-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --')
|
||||||
print('- Successfully Updated: {}{}{} -'.format(TERMINAL_BLUE, version, TERMINAL_YELLOW))
|
print(f'- Successfully Updated: {TERMINAL_BLUE}{version}{TERMINAL_YELLOW} -')
|
||||||
print('------------------------------------------------------------------{}'.format(TERMINAL_DEFAULT))
|
print(f'------------------------------------------------------------------{TERMINAL_DEFAULT}')
|
||||||
print()
|
print()
|
||||||
else:
|
else:
|
||||||
# print(process.stdout.read().decode())
|
# print(process.stdout.read().decode())
|
||||||
print('{}{}{}'.format(TERMINAL_RED, process.stderr.read().decode(), TERMINAL_DEFAULT))
|
print(f'{TERMINAL_RED}{process.stderr.read().decode()}{TERMINAL_DEFAULT}')
|
||||||
print('------------------------------------------------------------------')
|
print('------------------------------------------------------------------')
|
||||||
print(' {}Update Error: {}{}{}'.format(TERMINAL_RED, TERMINAL_BLUE, version, TERMINAL_DEFAULT))
|
print(f' {TERMINAL_RED}Update Error: {TERMINAL_BLUE}{version}{TERMINAL_DEFAULT}')
|
||||||
print('------------------------------------------------------------------')
|
print('------------------------------------------------------------------')
|
||||||
if not is_fork:
|
if not is_fork:
|
||||||
roll_back_update(roll_back_commit)
|
roll_back_update(roll_back_commit)
|
||||||
|
@ -385,7 +402,7 @@ def launch_update_version(version, roll_back_commit, current_version_path, is_fo
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def roll_back_update(roll_back_commit):
|
def roll_back_update(roll_back_commit):
|
||||||
print('Rolling back to safe commit: {}{}{}'.format(TERMINAL_BLUE, roll_back_commit, TERMINAL_DEFAULT))
|
print(f'Rolling back to safe commit: {TERMINAL_BLUE}{roll_back_commit}{TERMINAL_DEFAULT}')
|
||||||
process = subprocess.run(['git', 'checkout', roll_back_commit], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(['git', 'checkout', roll_back_commit], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
output = process.stdout
|
output = process.stdout
|
||||||
|
@ -398,10 +415,10 @@ def roll_back_update(roll_back_commit):
|
||||||
|
|
||||||
def aborting_update():
|
def aborting_update():
|
||||||
print()
|
print()
|
||||||
print('{}Aborting ...{}'.format(TERMINAL_RED, TERMINAL_DEFAULT))
|
print(f'{TERMINAL_RED}Aborting ...{TERMINAL_DEFAULT}')
|
||||||
print('{}******************************************************************'.format(TERMINAL_RED))
|
print(f'{TERMINAL_RED}******************************************************************')
|
||||||
print('* AIL Not Updated *')
|
print('* AIL Not Updated *')
|
||||||
print('******************************************************************{}'.format(TERMINAL_DEFAULT))
|
print(f'******************************************************************{TERMINAL_DEFAULT}')
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
@ -426,9 +443,9 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
current_version_path = os.path.join(os.environ['AIL_HOME'], 'update/current_version')
|
current_version_path = os.path.join(os.environ['AIL_HOME'], 'update/current_version')
|
||||||
|
|
||||||
print('{}******************************************************************'.format(TERMINAL_YELLOW))
|
print(f'{TERMINAL_YELLOW}******************************************************************')
|
||||||
print('* Updating AIL ... *')
|
print('* Updating AIL ... *')
|
||||||
print('******************************************************************{}'.format(TERMINAL_DEFAULT))
|
print(f'******************************************************************{TERMINAL_DEFAULT}')
|
||||||
|
|
||||||
# manual updates
|
# manual updates
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
@ -444,7 +461,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
current_tag = get_git_current_tag(current_version_path)
|
current_tag = get_git_current_tag(current_version_path)
|
||||||
print()
|
print()
|
||||||
print('Current Version: {}{}{}'.format(TERMINAL_YELLOW, current_tag, TERMINAL_DEFAULT))
|
print(f'Current Version: {TERMINAL_YELLOW}{current_tag}{TERMINAL_DEFAULT}')
|
||||||
print()
|
print()
|
||||||
list_upper_tags_remote = get_git_upper_tags_remote(current_tag.replace('v', ''), is_fork)
|
list_upper_tags_remote = get_git_upper_tags_remote(current_tag.replace('v', ''), is_fork)
|
||||||
# new release
|
# new release
|
||||||
|
@ -452,10 +469,10 @@ if __name__ == "__main__":
|
||||||
print('New Releases:')
|
print('New Releases:')
|
||||||
if is_fork:
|
if is_fork:
|
||||||
for upper_tag in list_upper_tags_remote:
|
for upper_tag in list_upper_tags_remote:
|
||||||
print(' {}{}{}'.format(TERMINAL_BLUE, upper_tag[0], TERMINAL_DEFAULT))
|
print(f' {TERMINAL_BLUE}{upper_tag[0]}{TERMINAL_DEFAULT}')
|
||||||
else:
|
else:
|
||||||
for upper_tag in list_upper_tags_remote:
|
for upper_tag in list_upper_tags_remote:
|
||||||
print(' {}{}{}: {}'.format(TERMINAL_BLUE, upper_tag[0], TERMINAL_DEFAULT, upper_tag[1]))
|
print(f' {TERMINAL_BLUE}{upper_tag[0]}{TERMINAL_DEFAULT}: {upper_tag[1]}')
|
||||||
print()
|
print()
|
||||||
update_ail(current_tag, list_upper_tags_remote, current_version_path, is_fork)
|
update_ail(current_tag, list_upper_tags_remote, current_version_path, is_fork)
|
||||||
|
|
||||||
|
@ -464,10 +481,9 @@ if __name__ == "__main__":
|
||||||
aborting_update()
|
aborting_update()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
print(' {}AIL Auto update is disabled{}'.format(TERMINAL_RED, TERMINAL_DEFAULT))
|
print(f' {TERMINAL_RED}AIL Auto update is disabled{TERMINAL_DEFAULT}')
|
||||||
aborting_update()
|
aborting_update()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
# r = get_git_upper_tags_remote('4.1', False)
|
||||||
# r = get_git_upper_tags_remote('4.2.1', False)
|
|
||||||
# print(r)
|
# print(r)
|
||||||
|
|
Loading…
Add table
Reference in a new issue