[DEV] change dev version win .1 version and call .island/release.bash

This commit is contained in:
Edouard DUPIN 2024-06-25 13:44:39 +02:00
parent d09b88c67a
commit 7413a8da19
2 changed files with 112 additions and 28 deletions

View File

@ -59,14 +59,22 @@ def execute(_arguments):
debug.info("find destination branch name: '" + elem.get_arg() + "'")
argument_to = elem.get_arg()
else:
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
debug.error(
"Wrong argument: '"
+ elem.get_option_name()
+ "' '"
+ elem.get_arg()
+ "'"
)
# check system is OK
manifest.check_island_is_init()
configuration = config.get_unique_config()
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
file_source_manifest = os.path.join(
env.get_island_path_manifest(), configuration.get_manifest_name()
)
if os.path.exists(file_source_manifest) is False:
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
@ -80,7 +88,9 @@ def execute(_arguments):
destination_branch = argument_to
all_project = mani.get_all_configs()
debug.info("Check if all project are on master: " + str(len(all_project)) + " projects")
debug.info(
"Check if all project are on master: " + str(len(all_project)) + " projects"
)
id_element = 0
deliver_available = True
for elem in all_project:
@ -107,9 +117,13 @@ def execute(_arguments):
for elem in all_project:
id_element += 1
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
debug.info("deliver: ========================================================================")
debug.info(
"deliver: ========================================================================"
)
debug.info("deliver: == " + base_display)
debug.info("deliver: ========================================================================")
debug.info(
"deliver: ========================================================================"
)
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
# Check the validity of the version,
@ -152,17 +166,31 @@ def execute(_arguments):
version_path_file = os.path.join(git_repo_path, "version.txt")
# update version file:
tools.file_write_data(version_path_file, tools.version_to_string(new_version_description) + "\n")
commands.add_file(git_repo_path, version_path_file)
tools.file_write_data(
version_path_file, tools.version_to_string(new_version_description) + "\n"
)
if commands.call_island_release_script(git_repo_path):
commands.add_all(git_repo_path)
else:
commands.add_file(git_repo_path, version_path_file)
commands.commit_all(
git_repo_path,
"[RELEASE] Release v" + tools.version_to_string(new_version_description),
)
commands.tag(git_repo_path, "v" + tools.version_to_string(new_version_description))
commands.tag(
git_repo_path, "v" + tools.version_to_string(new_version_description)
)
commands.checkout(git_repo_path, source_branch)
commands.reset_hard(git_repo_path, destination_branch)
# add a 1 at the version (development mode is to prevent the system to min consider snapshot as official versions)
new_version_description[2] += 1
new_version_description.append("dev")
tools.file_write_data(version_path_file, tools.version_to_string(new_version_description) + "\n")
commands.add_file(git_repo_path, version_path_file)
tools.file_write_data(
version_path_file, tools.version_to_string(new_version_description) + "\n"
)
if commands.call_island_release_script(git_repo_path):
commands.add_all(git_repo_path)
else:
commands.add_file(git_repo_path, version_path_file)
commands.commit_all(git_repo_path, status.default_update_message)
commands.checkout(git_repo_path, destination_branch)

View File

@ -12,6 +12,7 @@ import fnmatch
import os
import shutil
import stat
from pathlib import Path
# Local import
from realog import debug
@ -45,7 +46,9 @@ def get_list_branch_meta(path_repository):
cmd = "git branch -a"
debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "get_list_branch_meta", error_only=True)
multiprocess.generic_display_error(
return_value, "get_list_branch_meta", error_only=True
)
ret_branch = return_value
list_branch = ret_branch[1].split("\n")
out = []
@ -117,7 +120,9 @@ def get_current_tracking_branch(path_repository):
if return_value[1] == "@{u}":
debug.warning("in '" + path_repository + "' no tracking branch is specify")
return None
multiprocess.generic_display_error(return_value, "get_current_tracking_branch", error_only=True)
multiprocess.generic_display_error(
return_value, "get_current_tracking_branch", error_only=True
)
return return_value[1]
@ -125,7 +130,9 @@ def get_revision_list_to_branch(path_repository, branch):
cmd = "git rev-list " + branch
debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "get_revision_list_to_branch", error_only=True)
multiprocess.generic_display_error(
return_value, "get_revision_list_to_branch", error_only=True
)
return return_value[1].split("\n")
@ -135,7 +142,9 @@ def get_specific_commit_message(path_repository, sha_1):
cmd = "git log --format=%B -n 1 " + sha_1
debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "get_specific_commit_message", error_only=True)
multiprocess.generic_display_error(
return_value, "get_specific_commit_message", error_only=True
)
return return_value[1].split("\n")[0]
@ -145,7 +154,9 @@ def get_sha1_for_branch(path_repository, branch_name):
cmd = "git rev-parse " + branch_name
debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "get_sha1_for_branch", error_only=True)
multiprocess.generic_display_error(
return_value, "get_sha1_for_branch", error_only=True
)
return return_value[1].split("\n")[0]
@ -153,7 +164,9 @@ def get_tags_current(path_repository):
cmd = "git tag --points-at"
debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "get_tags_current", error_only=True)
multiprocess.generic_display_error(
return_value, "get_tags_current", error_only=True
)
list_tags = []
for elem in return_value[1].split("\n"):
if elem != "":
@ -203,30 +216,69 @@ def get_tracking_branch(path_repository, remote_name, select_branch):
if remote_name == "" or remote_name == None:
return get_current_tracking_branch(path_repository)
list_branch_remote = get_list_branch_remote(path_repository)
debug.extreme_verbose("check if exist " + remote_name + "/" + select_branch + " in " + str(list_branch_remote))
debug.extreme_verbose(
"check if exist "
+ remote_name
+ "/"
+ select_branch
+ " in "
+ str(list_branch_remote)
)
if remote_name + "/" + select_branch not in list_branch_remote:
debug.debug(" ==> can not get remote branch")
return None
return remote_name + "/" + select_branch
def merge_branch_on_master(path_repository, branch_name, merge_force=True, branch_destination="master"):
def merge_branch_on_master(
path_repository, branch_name, merge_force=True, branch_destination="master"
):
if branch_name == None or branch_name == "":
raise "Missing branch name"
cmd = "git merge "
if merge_force is True:
cmd += "--no-ff "
cmd += branch_name + " --message \"Merge branch '" + branch_name + "' into '" + branch_destination + "'\""
cmd += (
branch_name
+ " --message \"Merge branch '"
+ branch_name
+ "' into '"
+ branch_destination
+ "'\""
)
debug.verbose("execute : " + cmd)
# TODO: check if the command work correctly
return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "merge_branch_on_master", error_only=True)
multiprocess.generic_display_error(
return_value, "merge_branch_on_master", error_only=True
)
return return_value
def call_island_release_script(path_repository: str) -> bool:
cmd = ".island/release.bash"
file_path = Path(path_repository) / ".island/release.bash"
if not file_path.exists():
return False
debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command_direct(cmd, cwd=path_repository)
multiprocess.generic_display_error(
return_value, "call_island_release_script", error_only=True
)
return True
def add_all(path_repository):
cmd = "git add -u"
debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "add_all", error_only=True)
return return_value
def add_file(path_repository, file_path):
if file_path == None or file_path == "":
raise "Missing file_path name"
if not file_path:
raise IOError("Missing file_path name")
cmd = "git add " + file_path
debug.verbose("execute : " + cmd)
# TODO: check if the command work correctly
@ -236,8 +288,8 @@ def add_file(path_repository, file_path):
def commit_all(path_repository, comment):
if comment == None or comment == "":
raise "Missing comment description"
if not comment:
raise IOError("Missing comment description")
cmd = 'git commit -a --message "' + comment + '"'
debug.verbose("execute : " + cmd)
# TODO: check if the command work correctly
@ -247,8 +299,8 @@ def commit_all(path_repository, comment):
def tag(path_repository, tag_name):
if tag_name == None or tag_name == "":
raise "Missing tag name"
if not tag_name:
raise IOError("Missing tag name")
tag_name = tag_name.replace(" ", "_")
cmd = "git tag " + tag_name + ' --message "[TAG] create tag ' + tag_name + '"'
debug.verbose("execute : " + cmd)
@ -368,7 +420,9 @@ def get_forward(path_repository, branch_name):
raise "get_fast_forward: Missing branch_name"
select_branch = get_current_branch(path_repository)
# get tracking branch
ret_current_branch_sha1 = get_revision_list_to_branch(path_repository, select_branch)
ret_current_branch_sha1 = get_revision_list_to_branch(
path_repository, select_branch
)
ret_track_branch_sha1 = get_revision_list_to_branch(path_repository, branch_name)
# count the number of commit fast forward
forward_count = 0
@ -387,7 +441,9 @@ def get_behind(path_repository, branch_name):
raise "get_fast_forward: Missing branch_name"
select_branch = get_current_branch(path_repository)
# get tracking branch
ret_current_branch_sha1 = get_revision_list_to_branch(path_repository, select_branch)
ret_current_branch_sha1 = get_revision_list_to_branch(
path_repository, select_branch
)
ret_track_branch_sha1 = get_revision_list_to_branch(path_repository, branch_name)
# count the number of commit behind
behind_count = 0