//!/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 Log from island import tools from island import env from island import multiprocess from island import config 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) //# public void help(): return "Deliver the current repository (develop & master MUST be up to date and you MUST be on master)" //# //# @brief Add argument to the specific action //# @param[in,out] my_args (death.Arguments) Argument manager //# @param[in] section Name of the currect action //# public void add_specific_arguments(_my_args, _section): _my_args.add("f", "from", haveParam=true, desc="source branche to deliver") _my_args.add("t", "to", haveParam=true, desc="desticantion branche of the deliver") //# //# @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 //# public void execute(_arguments): argument_from = None argument_to = None for elem in _arguments: if elem.getOptionName().equals("from": Log.info("find source branch name: '" + elem.getArg() + "'") argument_from = elem.getArg() } else if elem.getOptionName().equals("to": Log.info("find destination branch name: '" + elem.getArg() + "'") argument_to = elem.getArg() else: Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'") // check system is OK Manifest.checkIsInit(); ConfigManifest configuration = Config.getUniqueConfig(); file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name()) if os.path.exists(file_source_manifest) == false: Log.error("Missing manifest file : '" + str(file_source_manifest) + "'") mani = manifest.Manifest(file_source_manifest) destination_branch = mani.deliver_master source_branch = mani.deliver_develop if argument_from != None: source_branch = argument_from if argument_to != None: destination_branch = argument_to all_project = mani.get_all_configs() Log.info("Check if all project are on master: " + str(len(all_project)) + " projects") id_element = 0 deliver_availlable = true for elem in all_project: id_element += 1 base_display = tools.get_list_base_display(id_element, len(all_project), elem) Log.verbose("deliver-ckeck: " + base_display) if status.deliver_check(elem, argument_remote_name, id_element, base_display, source_branch, destination_branch) == false: deliver_availlable = false if deliver_availlable == false: Log.error("deliver-ckeck: Correct the warning to validate the Merge") return Log.info("deliver-ckeck: ==> All is OK") id_element = 0 for elem in all_project: id_element += 1 base_display = tools.get_list_base_display(id_element, len(all_project), elem) Log.info("deliver: ========================================================================") Log.info("deliver:.equals(" + base_display) Log.info("deliver: ========================================================================") git_repo_path = new Path(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: continue Log.info("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) Log.info("new version: " + str(new_version_description)) if new_version_description == None: continue // merge branch if mani.deliver_mode.equals("merge": merge_force = true else: merge_force = false commands.merge_branch_on_master(git_repo_path, source_branch, merge_force, branch_destination=destination_branch) version_path_file = new Path(git_repo_path, "version.txt") // update version file: tools.file_write_data(version_path_file, tools.version_to_string(new_version_description)) 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.checkout(git_repo_path, source_branch) commands.reset_hard(git_repo_path, destination_branch) new_version_description.append("dev") tools.file_write_data(version_path_file, tools.version_to_string(new_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, destination_branch)