[DEV] add manifest access and tags

This commit is contained in:
Edouard DUPIN 2019-08-27 22:07:02 +02:00
parent 7e0a7fe45b
commit 06c671996f
4 changed files with 379 additions and 0 deletions

View File

@ -0,0 +1,72 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license MPL v2.0 (see license file)
##
from realog import debug
from island import tools
from island import env
from island import config
from island import multiprocess
from island import manifest
from island import commands
import status
import os
##
## @brief Get the global description of the current action
## @return (string) the description string (fist line if reserved for the overview, all is for the specific display)
##
def help():
return "Manifest Ckeckout a specific branch of repository"
##
## @brief Add argument to the specific action
## @param[in,out] my_args (death.Arguments) Argument manager
## @param[in] section Name of the currect action
##
def add_specific_arguments(my_args, section):
my_args.add("r", "remote", haveParam=True, desc="Name of the remote server")
my_args.add_arg("branch", optionnal=False, desc="Branch to checkout (if '__TAG__' ==> checkout specific repository tags)")
##
## @brief Execute the action required.
##
## @return error value [0 .. 50] the <0 value is reserved system ==> else, what you want.
## None : No error (return program out 0)
## -10 : ACTION is not existing
## -11 : ACTION execution system error
## -12 : ACTION Wrong parameters
##
def execute(_arguments):
argument_remote_name = ""
branch_to_checkout = ""
for elem in _arguments:
if elem.get_option_name() == "remote":
debug.info("find remote name: '" + elem.get_arg() + "'")
argument_remote_name = elem.get_arg()
elif elem.get_option_name() == "branch":
branch_to_checkout = elem.get_arg()
else:
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
# check system is OK
manifest.check_lutin_is_init()
configuration = config.get_unique_config()
elem = configuration.get_manifest_config()
base_display = tools.get_list_base_display(0, 0, elem)
if status.checkout_elem(elem, argument_remote_name, branch_to_checkout, base_display) == False:
return env.ret_action_fail

View File

@ -0,0 +1,67 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license MPL v2.0 (see license file)
##
from realog import debug
from island import tools
from island import env
from island import config
from island import multiprocess
from island import manifest
from island import commands
import status
import os
##
## @brief Get the global description of the current action
## @return (string) the description string (fist line if reserved for the overview, all is for the specific display)
##
def help():
return "Push the manifest delivery"
##
## @brief Add argument to the specific action
## @param[in,out] my_args (death.Arguments) Argument manager
## @param[in] section Name of the currect action
##
def add_specific_arguments(my_args, section):
pass
##
## @brief Execute the action required.
##
## @return error value [0 .. 50] the <0 value is reserved system ==> else, what you want.
## None : No error (return program out 0)
## -10 : ACTION is not existing
## -11 : ACTION execution system error
## -12 : ACTION Wrong parameters
##
def execute(_arguments):
for elem in _arguments:
debug.error("pull Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
# check system is OK
manifest.check_lutin_is_init()
configuration = config.get_unique_config()
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
if os.path.exists(file_source_manifest) == False:
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
elem = configuration.get_manifest_config()
# Check the manifest is up to date ...
base_display = tools.get_list_base_display(0, 0, elem)
status.deliver_push(elem, "origin", "master", "develop", base_display)

View File

@ -0,0 +1,177 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license MPL v2.0 (see license file)
##
from realog import debug
from island import tools
from island import env
from island import config
from island import multiprocess
from island import manifest
from island import commands
import status
import os
##
## @brief Get the global description of the current action
## @return (string) the description string (fist line if reserved for the overview, all is for the specific display)
##
def help():
return "Deliver the manifest (merge develop vertion and create a branch with the specific current tags)"
##
## @brief Add argument to the specific action
## @param[in,out] my_args (death.Arguments) Argument manager
## @param[in] section Name of the currect action
##
def add_specific_arguments(my_args, section):
pass
# must be on the branch we choice to merge ...
##
## @brief Execute the action required.
##
## @return error value [0 .. 50] the <0 value is reserved system ==> else, what you want.
## None : No error (return program out 0)
## -10 : ACTION is not existing
## -11 : ACTION execution system error
## -12 : ACTION Wrong parameters
##
def execute(_arguments):
argument_remote_name = ""
destination_branch = "master"
source_branch = "develop"
for elem in _arguments:
debug.error("pull Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
# check system is OK
manifest.check_lutin_is_init()
configuration = config.get_unique_config()
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
if os.path.exists(file_source_manifest) == False:
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
elem = configuration.get_manifest_config()
# Check the manifest is up to date ...
base_display = tools.get_list_base_display(0, 0, elem)
debug.verbose("deliver-ckeck: " + base_display)
if status.deliver_check(elem, argument_remote_name, 0, base_display, source_branch, destination_branch) == False:
debug.error("Can not deliver a MANIFEST that is not ready to merge", crash=False)
return env.ret_action_fail
mani = manifest.Manifest(file_source_manifest)
all_tags = check_all_tags(mani)
if all_tags == None:
debug.error("Need the Tags are set in sub-repository", crash=False)
return env.ret_action_fail
# deliver the manifest (if Needed ...)
base_display = tools.get_list_base_display(0, 0, elem)
debug.info("manifest-deliver: ========================================================================")
debug.info("manifest-deliver: == " + base_display)
debug.info("manifest-deliver: ========================================================================")
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
# Check the validity of the version,
version_description, add_in_version_management = status.get_current_version_repo(git_repo_path)
if version_description == None:
return env.ret_action_fail
debug.info("manifest-deliver: ==> version: " + str(version_description))
# go to the dev branch
select_branch = commands.get_current_branch(git_repo_path)
# Checkout destination branch:
commands.checkout(git_repo_path, destination_branch)
# create new repo tag
new_version_description = status.create_new_version_repo(git_repo_path, version_description, add_in_version_management, source_branch, destination_branch)
debug.info("new version: " + str(version_description))
# merge branch
commands.checkout(git_repo_path, destination_branch)
commands.merge_branch_on_master(git_repo_path, source_branch)
manifest.tag_manifest(file_source_manifest, all_tags);
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(version_description))
commands.add_file(git_repo_path, version_path_file)
commands.commit_all(git_repo_path, "[RELEASE] Release v" + tools.version_to_string(version_description))
commands.tag(git_repo_path, "v" + tools.version_to_string(version_description))
commands.checkout(git_repo_path, "develop")
commands.reset_hard(git_repo_path, "master")
version_description.append("dev")
manifest.tag_clear(file_source_manifest);
tools.file_write_data(version_path_file, tools.version_to_string(version_description))
commands.add_file(git_repo_path, version_path_file)
commands.commit_all(git_repo_path, status.default_update_message)
commands.checkout(git_repo_path, "master")
debug.info("manifest-deliver: ==> DONE")
def check_all_tags(mani):
all_project = mani.get_all_configs()
debug.info("Check all: " + str(len(all_project)) + " projects have a current tag ...")
id_element = 0
check_have_error = False
list_tags = []
for elem in all_project:
id_element += 1
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
if elem.volatile == True:
debug.info(base_display + "\r\t\t\t\t\t\t\t\t\t" + " (Not Managed)")
continue
tags_comment = ""
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
if os.path.exists(git_repo_path) == False:
debug.error(base_display + volatile + "\r\t\t\t\t\t\t\t\t\t" + " (not download)", crash=False)
check_have_error = True
continue
ret_current_tags = commands.get_tags_current(git_repo_path)
debug.verbose("tags found: " + str(ret_current_tags))
if len(ret_current_tags) == 0:
list_tags.append({
"name":elem.name,
"tag":""
})
else:
list_tags.append({
"name":elem.name,
"tag":ret_current_tags[0]
})
for elem_tag in ret_current_tags:
if len(tags_comment) != 0:
tags_comment += ","
tags_comment += elem_tag
if len(ret_current_tags) == 0:
debug.error(base_display + "\r\t\t\t\t\t\t\t\t\t" + " (NO TAG DETECTED)", crash=False)
check_have_error = True
continue
else:
debug.info(base_display + "\r\t\t\t\t\t\t\t\t\t" + " " + tags_comment)
if check_have_error == True:
return None
return list_tags

View File

@ -0,0 +1,63 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license MPL v2.0 (see license file)
##
from realog import debug
from island import tools
from island import env
from island import config
from island import multiprocess
from island import manifest
from island import commands
import status
import os
##
## @brief Get the global description of the current action
## @return (string) the description string (fist line if reserved for the overview, all is for the specific display)
##
def help():
return "Display status spécifically of the manifest"
##
## @brief Add argument to the specific action
## @param[in,out] my_args (death.Arguments) Argument manager
## @param[in] section Name of the currect action
##
def add_specific_arguments(_my_args, _section):
_my_args.add("t", "tags", haveParam=False, desc="Display if the commit is on a tag (and display it)")
##
## @brief Execute the action required.
##
## @return error value [0 .. 50] the <0 value is reserved system ==> else, what you want.
## None : No error (return program out 0)
## -10 : ACTION is not existing
## -11 : ACTION execution system error
## -12 : ACTION Wrong parameters
##
def execute(_arguments):
argument_remote_name = ""
argument_display_tag = False
for elem in _arguments:
if elem.get_option_name() == "tags":
argument_display_tag = True
else:
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
# check system is OK
manifest.check_lutin_is_init()
configuration = config.get_unique_config()
elem = configuration.get_manifest_config()
base_display = tools.get_list_base_display(0, 0, elem)
ret = status.display_status(elem, argument_remote_name, argument_display_tag, 0, base_display)
if ret != None:
return env.ret_action_need_updtate