6 Commits

31 changed files with 468 additions and 415 deletions

1
.gitignore vendored
View File

@@ -4,6 +4,7 @@
# Setuptools distribution folder.
/dist/
/build/
/.venv/
# Python egg metadata, regenerated from source files by setuptools.
/*.egg-info

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"cSpell.words": ["realog"]
}

View File

@@ -1,32 +1,16 @@
Lutin
=====
`island` is a generic source downloader and syncronizer is a FREE software tool.
`island` is a generic source downloader and synchronizer is a FREE software tool.
It is compatible with basic format of repo-git manifest. This project is created to be easyest to read with simple interface
It is compatible with basic format of repo-git manifest. This project is created to be easiest to read with simple interface
(no internal git usage, but user level git usage) The main point to create the "fork" is the non-support of repo of relativity
in submodule of git (submodule reference with ../xxx.git) This point is really important when you want to have a rellocable
manifest and project with submodule. The simpl eexample is the atria-soft / generic-library / musicdsp that are availlable on
in submodule of git (submodule reference with ../xxx.git) This point is really important when you want to have a relocate
manifest and project with submodule. The simpl example is the atria-soft / generic-library / musicdsp that are available on
github, gitlab, bitbucket and personal server.
.. image:: https://badge.fury.io/py/island.png
:target: https://pypi.python.org/pypi/island
Release (master)
----------------
.. image:: https://travis-ci.org/HeeroYui/island.svg?branch=master
:target: https://travis-ci.org/HeeroYui/island
Developement (dev)
------------------
.. image:: https://travis-ci.org/HeeroYui/island.svg?branch=dev
:target: https://travis-ci.org/HeeroYui/island
![https://badge.fury.io/py/island.png](https://badge.fury.io/py/island.png))
Instructions
------------
@@ -78,7 +62,7 @@ Download and synchronize the sources:
island sync
Select all branch availlable in the worktree: (checkout origin/dev in dev branch and track it, do nothing if the branch does not exist)
Select all branch available in the work-tree: (checkout origin/dev in dev branch and track it, do nothing if the branch does not exist)
island checkout dev
@@ -86,6 +70,23 @@ Show the status of the workspace
island status
Develop in local (with virtual env):
====================================
see: https://setuptools.pypa.io/en/latest/userguide/development_mode.html
Create your development environment:
```bash
# Create a virtual environment
python -m venv .venv
# Activate the python virtual environment
source .venv/bin/activate
# Install the package in editable mode (dynamic use of files)
pip install --editable .
```
Run the application . ```island --help```
Manual set in production:
=========================
@@ -98,7 +99,7 @@ Create the new version:
```bash
# Clean previous packages
rm -rf dist/
\rm -rf dist/
# Compile the package
python3 -m build
# Upload the package

View File

@@ -1,10 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Inland main interface.
@author Edouard DUPIN
@copyright 2012, Edouard DUPIN, all right reserved
@license MPL v2.0 (see license file)
"""
import island # Noqa: import

View File

@@ -1,264 +1,8 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Inland main().
"""Inland INIT GLOBAL.
@author Edouard DUPIN
@copyright 2012, Edouard DUPIN, all right reserved
@license MPL v2.0 (see license file)
"""
import copy
import fnmatch
import os
import sys
from typing import Union
import death.ArgElement as arg_element
import death.Arguments as arguments
from realog import debug
# Local import
from . import (
actions,
env,
host,
tools,
)
is_init = False
debug.set_display_on_error(" ==========================\n == Some error occurred ==\n ==========================")
def init() -> None:
"""Global initialization of Island."""
global is_init
if is_init is True:
return
# import local island files
list_of_island_files = tools.import_path_local(
os.path.join(tools.get_current_path(__file__), "actions"),
base_name=env.get_system_base_name() + "*.py",
)
actions.init(list_of_island_files)
# import project actions files
list_of_island_files = tools.import_path_local(
env.get_island_root_path(),
2,
[".island", ".git", "archive"],
base_name=env.get_system_base_name() + "*.py",
)
actions.init(list_of_island_files)
is_init = True
# initialize the system ...
init()
debug.verbose("List of actions: " + str(actions.get_list_of_action()))
my_args = arguments.Arguments()
my_args.add_section("option", "Can be set one time in all case")
my_args.add("h", "help", desc="Display this help")
my_args.add(
"v",
"verbose",
list=[
["0", "None"],
["1", "error"],
["2", "warning"],
["3", "info"],
["4", "debug"],
["5", "verbose"],
["6", "extreme_verbose"],
],
desc="display debug level (verbose) default =2",
)
my_args.add("c", "color", desc="Display message in color")
my_args.add("n", "no-fetch-manifest", haveParam=False, desc="Disable the fetch of the manifest")
my_args.add(
"F",
"filter",
haveParam=True,
desc="Filter the action on a list of path or subpath: -f library",
)
my_args.add(
"f",
"folder",
haveParam=False,
desc="Display the folder instead of the git repository name",
)
my_args.add(
"w",
"wait",
haveParam=True,
desc="Wait between 2 access on the server (needed when the server is really slow to remove ssh connection) (default="
+ str(env.get_wait_between_sever_command())
+ ")",
)
my_args.set_stop_at(actions.get_list_of_action())
local_argument = my_args.parse()
def usage() -> None:
"""Display the help of Island."""
color = debug.get_color_set()
# Generic argument displayed :
my_args.display()
print(" Action available")
list_actions = actions.get_list_of_action()
for elem in list_actions:
print(f" {color['green']}{elem}{color['default']}")
print(f" {actions.get_action_help(elem)}")
"""
print(" {color['green']}init{color['default']}")
print(" initialize a 'island' interface with a manifest in a git ")
print(" {color['green']}sync{color['default']}")
print(" Synchronize the current environnement")
print(" {color['green']}status{color['default']}")
print(" Dump the status of the environnement")
"""
print(f" ex: {sys.argv[0]} -c init http://github.com/atria-soft/manifest.git")
print(f" ex: {sys.argv[0]} sync")
exit(0)
def check_boolean(value: Union[bool, str]) -> bool:
"""Check if the value is a real boolean or a boolean string and return the boolean value.
:param value: Value to check.
:return: Equivalent boolean value.
"""
if value == "" or value == "1" or value == "true" or value == "True" or value is True:
return True
return False
def parse_generic_arg(argument: arg_element.ArgElement, active: bool) -> bool:
"""Keep global args that have no dependence with the mode.
:param argument: _description_
:param active: _description_
:return: _description_
"""
debug.extreme_verbose(f"parse arg : {argument.get_option_name()} {argument.get_arg()} active={active}")
if argument.get_option_name() == "help":
if active is False:
usage()
return True
elif argument.get_option_name() == "jobs":
if active is True:
# multiprocess.set_core_number(int(argument.get_arg()))
pass
return True
elif argument.get_option_name() == "wait":
if active is True:
env.set_wait_between_sever_command(int(argument.get_arg()))
return True
elif argument.get_option_name() == "verbose":
if active is True:
debug.set_level(int(argument.get_arg()))
return True
elif argument.get_option_name() == "folder":
if active is True:
env.set_display_folder_instead_of_git_name(True)
return True
elif argument.get_option_name() == "color":
if active is True:
if check_boolean(argument.get_arg()) is True:
debug.enable_color()
else:
debug.disable_color()
return True
elif argument.get_option_name() == "filter":
if active is True:
env.set_filter_command(str(argument.get_arg()))
return True
elif argument.get_option_name() == "no-fetch-manifest":
if active is False:
env.set_fetch_manifest(False)
return True
return False
# open configuration of island:
config_file = env.get_island_path_user_config()
if os.path.isfile(config_file) is True:
sys.path.append(os.path.dirname(config_file))
debug.debug(f"Find basic configuration file: '{config_file}'")
# the file exist, we can open it and get the initial configuration:
configuration_file = __import__(env.get_system_config_name()[:-3])
if "get_exclude_path" in dir(configuration_file):
data = configuration_file.get_exclude_path()
debug.debug(f"get default config 'get_exclude_path' val='{data}'")
env.set_exclude_search_path(data)
if "get_default_color" in dir(configuration_file):
data = configuration_file.get_default_color()
debug.debug(f"get default config 'get_default_color' val='{data}'")
parse_generic_arg(arg_element.ArgElement("color", str(data)), True)
if "get_default_debug_level" in dir(configuration_file):
data = configuration_file.get_default_debug_level()
debug.debug(f"get default config 'get_default_debug_level' val='{data}'")
parse_generic_arg(arg_element.ArgElement("verbose", str(data)), True)
if "get_default_folder" in dir(configuration_file):
data = configuration_file.get_default_folder()
debug.debug(f"get default config 'get_default_folder' val='{data}'")
parse_generic_arg(arg_element.ArgElement("folder", str(data)), True)
if "get_default_wait" in dir(configuration_file):
data = configuration_file.get_default_wait()
debug.debug(f"get default config 'get_default_wait' val='{data}'")
parse_generic_arg(arg_element.ArgElement("wait", str(data)), True)
if "get_default_filter" in dir(configuration_file):
data = configuration_file.get_default_filter()
debug.debug(f"get default config 'get_default_filter' val='{data}'")
parse_generic_arg(arg_element.ArgElement("filter", str(data)), True)
# parse default unique argument:
for argument in local_argument:
parse_generic_arg(argument, True)
# remove all generic arguments:
new_argument_list = []
for argument in local_argument:
if parse_generic_arg(argument, False) is True:
continue
new_argument_list.append(argument)
# now the first argument is: the action:
if len(new_argument_list) == 0:
debug.warning("--------------------------------------")
debug.warning("Missing the action to do ...")
debug.warning("--------------------------------------")
usage()
# TODO : move tin in actions ...
list_actions = actions.get_list_of_action()
action_to_do = new_argument_list[0].get_arg()
new_argument_list = new_argument_list[1:]
if action_to_do not in list_actions:
debug.warning("--------------------------------------")
debug.warning(f"Wrong action type : '{action_to_do}' available list: {list_actions}")
debug.warning("--------------------------------------")
usage()
# todo : Remove this
if action_to_do != "init" and os.path.exists(env.get_island_path()) is False:
debug.error(f"Can not execute a island cmd if we have not initialize a config: '.{env.get_system_base_name()}' in upper 6 parent path")
exit(-1)
ret = actions.execute(action_to_do, my_args.get_last_parsed() + 1)
exit(ret)
# stop all started threads;
# multiprocess.un_init()

View File

@@ -63,7 +63,7 @@ def execute(_arguments):
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
# check system is OK
manifest.check_lutin_is_init()
manifest.check_island_is_init()
configuration = config.get_unique_config()

View File

@@ -52,7 +52,7 @@ def execute(_arguments):
cmd += elem.get_arg() + " "
# check system is OK
manifest.check_lutin_is_init()
manifest.check_island_is_init()
configuration = config.get_unique_config()

View File

@@ -64,7 +64,7 @@ def execute(_arguments):
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
# check system is OK
manifest.check_lutin_is_init()
manifest.check_island_is_init()
configuration = config.get_unique_config()

View File

@@ -57,7 +57,7 @@ def execute(_arguments):
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
# check system is OK
manifest.check_lutin_is_init()
manifest.check_island_is_init()
configuration = config.get_unique_config()

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_lutin_is_init()
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

@@ -56,7 +56,7 @@ def execute(_arguments):
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
# check system is OK
manifest.check_lutin_is_init()
manifest.check_island_is_init()
debug.info("fetch manifest : '" + str(env.get_island_path_manifest()) + "'")
commands.fetch(env.get_island_path_manifest(), "origin")

View File

@@ -75,7 +75,7 @@ def execute(_arguments):
debug.info("Init with: '" + address_manifest + "' branch='" + branch + "' name of manifest='" + manifest_name + "'")
# check if .XXX exist (create it if needed)
if manifest.is_lutin_init() is True:
if manifest.is_island_init() is True:
debug.error("System already init: path already exist: '" + str(env.get_island_path()) + "'")
tools.create_directory(env.get_island_path())

View File

@@ -65,7 +65,7 @@ def execute(_arguments):
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
# check system is OK
manifest.check_lutin_is_init()
manifest.check_island_is_init()
configuration = config.get_unique_config()

View File

@@ -52,7 +52,7 @@ def execute(_arguments):
debug.error("pull Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
# check system is OK
manifest.check_lutin_is_init()
manifest.check_island_is_init()
configuration = config.get_unique_config()

View File

@@ -56,7 +56,7 @@ def execute(_arguments):
debug.error("pull Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
# check system is OK
manifest.check_lutin_is_init()
manifest.check_island_is_init()
configuration = config.get_unique_config()

View File

@@ -62,7 +62,7 @@ def execute(_arguments):
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
# check system is OK
manifest.check_lutin_is_init()
manifest.check_island_is_init()
configuration = config.get_unique_config()
elem = configuration.get_manifest_config()

View File

@@ -51,7 +51,7 @@ def execute(_arguments):
debug.error("pull Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
# check system is OK
manifest.check_lutin_is_init()
manifest.check_island_is_init()
configuration = config.get_unique_config()

View File

@@ -56,7 +56,7 @@ def execute(_arguments):
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
# check system is OK
manifest.check_lutin_is_init()
manifest.check_island_is_init()
configuration = config.get_unique_config()

View File

@@ -66,7 +66,7 @@ def execute(_arguments):
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
# check system is OK
manifest.check_lutin_is_init()
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())

View File

@@ -67,7 +67,7 @@ def execute(_arguments):
)
# check system is OK
manifest.check_lutin_is_init()
manifest.check_island_is_init()
configuration = config.get_unique_config()

View File

@@ -70,7 +70,7 @@ def execute(_arguments):
debug.error("SYNC Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
# check system is OK
manifest.check_lutin_is_init()
manifest.check_island_is_init()
configuration = config.get_unique_config()

View File

@@ -81,7 +81,7 @@ def execute(_arguments):
debug.info("Add 'volatile' repository: '" + address_git + "' path='" + path + "'")
# check system is OK
manifest.check_lutin_is_init()
manifest.check_island_is_init()
# Update the current configuration:
conf = config.get_unique_config()

View File

@@ -44,7 +44,7 @@ def execute(_arguments):
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
# check system is OK
manifest.check_lutin_is_init()
manifest.check_island_is_init()
conf = config.get_unique_config()
volatiles = conf.get_volatile()

262
island/bin_island.py Executable file
View File

@@ -0,0 +1,262 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Inland main().
@author Edouard DUPIN
@copyright 2012, Edouard DUPIN, all right reserved
@license MPL v2.0 (see license file)
"""
import copy
import fnmatch
import os
import sys
from typing import Union
import death.ArgElement as arg_element
import death.Arguments as arguments
from realog import debug
# Local import
from . import (
actions,
env,
host,
tools,
)
is_init = False
debug.set_display_on_error(" ==========================\n == Some error occurred ==\n ==========================")
def init() -> None:
"""Global initialization of Island."""
global is_init
if is_init is True:
return
# import local island files
list_of_island_files = tools.import_path_local(
os.path.join(tools.get_current_path(__file__), "actions"),
base_name=env.get_system_base_name() + "*.py",
)
actions.init(list_of_island_files)
# import project actions files
list_of_island_files = tools.import_path_local(
env.get_island_root_path(),
2,
[".island", ".git", "archive"],
base_name=env.get_system_base_name() + "*.py",
)
actions.init(list_of_island_files)
is_init = True
def usage(my_args) -> None:
"""Display the help of Island."""
color = debug.get_color_set()
# Generic argument displayed :
my_args.display()
print(" Action available")
list_actions = actions.get_list_of_action()
for elem in list_actions:
print(f" {color['green']}{elem}{color['default']}")
print(f" {actions.get_action_help(elem)}")
"""
print(" {color['green']}init{color['default']}")
print(" initialize a 'island' interface with a manifest in a git ")
print(" {color['green']}sync{color['default']}")
print(" Synchronize the current environnement")
print(" {color['green']}status{color['default']}")
print(" Dump the status of the environnement")
"""
print(f" ex: {sys.argv[0]} -c init http://github.com/atria-soft/manifest.git")
print(f" ex: {sys.argv[0]} sync")
exit(0)
def check_boolean(value: Union[bool, str]) -> bool:
"""Check if the value is a real boolean or a boolean string and return the boolean value.
:param value: Value to check.
:return: Equivalent boolean value.
"""
if value == "" or value == "1" or value == "true" or value == "True" or value is True:
return True
return False
def parse_generic_arg(my_args, argument: arg_element.ArgElement, active: bool) -> bool:
"""Keep global args that have no dependence with the mode.
:param argument: _description_
:param active: _description_
:return: _description_
"""
debug.extreme_verbose(f"parse arg : {argument.get_option_name()} {argument.get_arg()} active={active}")
if argument.get_option_name() == "help":
if active is False:
usage(my_args)
return True
elif argument.get_option_name() == "jobs":
if active is True:
# multiprocess.set_core_number(int(argument.get_arg()))
pass
return True
elif argument.get_option_name() == "wait":
if active is True:
env.set_wait_between_sever_command(int(argument.get_arg()))
return True
elif argument.get_option_name() == "verbose":
if active is True:
debug.set_level(int(argument.get_arg()))
return True
elif argument.get_option_name() == "folder":
if active is True:
env.set_display_folder_instead_of_git_name(True)
return True
elif argument.get_option_name() == "color":
if active is True:
if check_boolean(argument.get_arg()) is True:
debug.enable_color()
else:
debug.disable_color()
return True
elif argument.get_option_name() == "filter":
if active is True:
env.set_filter_command(str(argument.get_arg()))
return True
elif argument.get_option_name() == "no-fetch-manifest":
if active is False:
env.set_fetch_manifest(False)
return True
return False
def main():
# initialize the system ...
init()
debug.verbose("List of actions: " + str(actions.get_list_of_action()))
my_args = arguments.Arguments()
my_args.add_section("option", "Can be set one time in all case")
my_args.add("h", "help", desc="Display this help")
my_args.add(
"v",
"verbose",
list=[
["0", "None"],
["1", "error"],
["2", "warning"],
["3", "info"],
["4", "debug"],
["5", "verbose"],
["6", "extreme_verbose"],
],
desc="display debug level (verbose) default =2",
)
my_args.add("c", "color", desc="Display message in color")
my_args.add("n", "no-fetch-manifest", haveParam=False, desc="Disable the fetch of the manifest")
my_args.add(
"F",
"filter",
haveParam=True,
desc="Filter the action on a list of path or subpath: -f library",
)
my_args.add(
"f",
"folder",
haveParam=False,
desc="Display the folder instead of the git repository name",
)
my_args.add(
"w",
"wait",
haveParam=True,
desc="Wait between 2 access on the server (needed when the server is really slow to remove ssh connection) (default="
+ str(env.get_wait_between_sever_command())
+ ")",
)
my_args.set_stop_at(actions.get_list_of_action())
local_argument = my_args.parse()
# open configuration of island:
config_file = env.get_island_path_user_config()
if os.path.isfile(config_file) is True:
sys.path.append(os.path.dirname(config_file))
debug.debug(f"Find basic configuration file: '{config_file}'")
# the file exist, we can open it and get the initial configuration:
configuration_file = __import__(env.get_system_config_name()[:-3])
if "get_exclude_path" in dir(configuration_file):
data = configuration_file.get_exclude_path()
debug.debug(f"get default config 'get_exclude_path' val='{data}'")
env.set_exclude_search_path(data)
if "get_default_color" in dir(configuration_file):
data = configuration_file.get_default_color()
debug.debug(f"get default config 'get_default_color' val='{data}'")
parse_generic_arg(my_args, arg_element.ArgElement("color", str(data)), True)
if "get_default_debug_level" in dir(configuration_file):
data = configuration_file.get_default_debug_level()
debug.debug(f"get default config 'get_default_debug_level' val='{data}'")
parse_generic_arg(my_args, arg_element.ArgElement("verbose", str(data)), True)
if "get_default_folder" in dir(configuration_file):
data = configuration_file.get_default_folder()
debug.debug(f"get default config 'get_default_folder' val='{data}'")
parse_generic_arg(my_args, arg_element.ArgElement("folder", str(data)), True)
if "get_default_wait" in dir(configuration_file):
data = configuration_file.get_default_wait()
debug.debug(f"get default config 'get_default_wait' val='{data}'")
parse_generic_arg(my_args, arg_element.ArgElement("wait", str(data)), True)
if "get_default_filter" in dir(configuration_file):
data = configuration_file.get_default_filter()
debug.debug(f"get default config 'get_default_filter' val='{data}'")
parse_generic_arg(my_args, arg_element.ArgElement("filter", str(data)), True)
# parse default unique argument:
for argument in local_argument:
parse_generic_arg(my_args, argument, True)
# remove all generic arguments:
new_argument_list = []
for argument in local_argument:
if parse_generic_arg(my_args, argument, False) is True:
continue
new_argument_list.append(argument)
# now the first argument is: the action:
if len(new_argument_list) == 0:
debug.warning("--------------------------------------")
debug.warning("Missing the action to do ...")
debug.warning("--------------------------------------")
usage(my_args)
# TODO : move tin in actions ...
list_actions = actions.get_list_of_action()
action_to_do = new_argument_list[0].get_arg()
new_argument_list = new_argument_list[1:]
if action_to_do not in list_actions:
debug.warning("--------------------------------------")
debug.warning(f"Wrong action type : '{action_to_do}' available list: {list_actions}")
debug.warning("--------------------------------------")
usage(my_args)
# todo : Remove this
if action_to_do != "init" and os.path.exists(env.get_island_path()) is False:
debug.error(f"Can not execute a island cmd if we have not initialize a config: '.{env.get_system_base_name()}' in upper 6 parent path")
exit(-1)
ret = actions.execute(action_to_do, my_args.get_last_parsed() + 1)
exit(ret)

View File

@@ -12,12 +12,12 @@ import fnmatch
import os
import shutil
import stat
from pathlib import Path
# Local import
from realog import debug
from . import (
debug,
env,
multiprocess,
)
@@ -46,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 = []
@@ -118,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]
@@ -126,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")
@@ -136,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]
@@ -146,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]
@@ -154,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 != "":
@@ -204,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
@@ -237,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
@@ -248,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)
@@ -369,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
@@ -388,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

View File

@@ -29,22 +29,22 @@ from . import (
)
def is_lutin_init():
if os.path.exists(env.get_island_path()) is False:
def is_island_init():
if not os.path.exists(env.get_island_path()):
debug.verbose(f"Island is not init: path does not exist: '{env.get_island_path()}'")
return False
if os.path.exists(env.get_island_path_config()) is False and os.path.exists(env.get_island_path_config_old()) is False:
debug.verbose(f"Island is not init: config does not exist: '{env.get_island_path_config()}' or '{env.get_island_path_config_old()}'")
if not os.path.exists(env.get_island_path_config()):
debug.verbose(f"Island is not init: config does not exist: '{env.get_island_path_config()}'")
return False
if os.path.exists(env.get_island_path_manifest()) is False:
if not os.path.exists(env.get_island_path_manifest()):
debug.verbose(f"Island is not init: Manifest does not exist: '{env.get_island_path_manifest()}'")
return False
return True
def check_lutin_is_init():
def check_island_is_init():
# check if .XXX exist (create it if needed)
if not is_lutin_init():
if not is_island_init():
debug.error(f"System not init: missing config: '{env.get_island_path()}'. Call <island init> first")
exit(-1)

View File

@@ -1,2 +1,40 @@
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"
[tool.setuptools]
py-modules = [ "island" ]
[project]
name = "island"
requires-python = ">=3.7"
dependencies = ["lxml", "realog", "death", "PyYAML"]
description = "island generic source manager (like repo in simple mode)"
readme = "README.md"
authors = [
{name = "Edouard DUPIN", email = "yui.heero@gmail.com" } # Optional
]
license = {text = "MPL-2"}
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
"Programming Language :: Python",
"Topic :: Software Development :: Build Tools"
]
keywords = ["source", "manager", "repo", "qisrc", "lutin"]
dynamic = ["version"]
[project.scripts]
island = "island.bin_island:main"
[project.urls]
"Homepage" = "http://github.com/HeeroYui/island"
"Bug Reports" = "http://github.com/HeeroYui/island/issues"
"Source" = "http://github.com/HeeroYui/island"
[tool.setuptools.dynamic]
version = {file = "version.txt"}
[tool.black]
line-length = 150
line-length = 150

View File

View File

@@ -1,69 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# @author Edouard DUPIN
#
# @copyright 2012, Edouard DUPIN, all right reserved
#
# @license MPL v2.0 (see license file)
#
from setuptools import setup
import os
def readme():
with open("README.rst") as f:
return f.read()
def read_version_file():
if not os.path.isfile("version.txt"):
return ""
file = open("version.txt", "r")
data_file = file.read()
file.close()
if len(data_file) > 4 and data_file[-4:] == "-dev":
data_file = data_file[:-4]
return data_file
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
setup(
name="island",
version=read_version_file(),
description="island generic source manager (like repo in simple mode)",
long_description=readme(),
url="http://github.com/HeeroYui/island",
author="Edouard DUPIN",
author_email="yui.heero@gmail.com",
license="MPL-2",
packages=["island", "island/actions"],
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
"Programming Language :: Python",
"Topic :: Software Development :: Build Tools",
],
keywords="source manager repo qisrc lutin",
scripts=["bin/island"],
# Does not work on MacOs
# data_file=[
# ('/etc/bash_completion.d', ['bash-autocompletion/lutin']),
# ],
install_requires=[
"lxml",
"realog",
"death",
"PyYAML",
],
include_package_data=True,
)
# To developp: sudo ./setup.py install
# sudo ./setup.py develop
# TO register all in pip: use external tools:
# pip install twine
# # create the archive
# ./setup.py sdist
# twine upload dist/*

View File

@@ -1 +1 @@
1.1.3
1.3.0