[DEV] add volatile basic insterface

This commit is contained in:
Edouard DUPIN 2019-08-02 00:05:26 +02:00
parent 31f2815230
commit d646aab6f6
2 changed files with 67 additions and 4 deletions

View File

@ -75,11 +75,14 @@ def execute(_arguments):
for elem in all_project:
id_element += 1
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
volatile = ""
if elem.volatile == True:
volatile = " (volatile)"
debug.verbose("status : " + base_display)
#debug.debug("elem : " + str(elem))
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
if os.path.exists(git_repo_path) == False:
debug.info(base_display + "\r\t\t\t\t\t\t\t\t\t" + " (not download)")
debug.info(base_display + volatile + "\r\t\t\t\t\t\t\t\t\t" + " (not download)")
continue
is_modify = commands.check_repository_is_modify(git_repo_path)
@ -89,7 +92,7 @@ def execute(_arguments):
# get tracking branch
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, select_branch)
if tracking_remote_branch == None:
debug.info(base_display + "\r\t\t\t\t\t\t\t (NO BRANCH)")
debug.info(base_display + volatile + "\r\t\t\t\t\t\t\t (NO BRANCH)")
continue
modify_status = " "
@ -132,8 +135,7 @@ def execute(_arguments):
tags_comment += elem_tag
if len(tags_comment) != 0:
tags_comment = "\r\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[" + tags_comment + "]"
debug.info(base_display + "\r\t\t\t\t\t\t\t" + modify_status + "(" + select_branch + " -> " + tracking_remote_branch + ")" + behind_forward_comment + tags_comment)
debug.info(base_display + volatile + "\r\t\t\t\t\t\t\t" + modify_status + "(" + select_branch + " -> " + tracking_remote_branch + ")" + behind_forward_comment + tags_comment)
if is_modify == True:
cmd = "git status --short"
debug.verbose("execute : " + cmd)

View File

@ -26,6 +26,7 @@ class RepoConfig():
self.remotes = [] # list of all remotes, with the upstream elements (needed for third party integrations)
self.select_remote = ""
self.branch = ""
self.volatile = False
def is_lutin_init():
if os.path.exists(env.get_island_path()) == False:
@ -310,6 +311,66 @@ class Manifest():
list_project = elem["manifest"].get_all_configs(default, upper_remotes_forward)
for elem_proj in list_project:
out.append(elem_proj)
## -------------------------------------------------------------
## -- add Volatile ...
## -------------------------------------------------------------
debug.verbose("include volatile config")
# TODO: maybe find a better way to do this...
conf_global = config.Config()
for elem in conf_global.get_volatile():
conf = RepoConfig()
base_volatile, repo_volatile = split_repo(elem["git_address"])
conf.name = repo_volatile
conf.path = elem["path"]
conf.branch = "master"
conf.volatile = True
conf.remotes = [
{
'name': 'origin',
'fetch': base_volatile,
'mirror': []
}
]
conf.select_remote = {
'name': 'origin',
'fetch': base_volatile,
'sync': False,
'mirror': []
}
out.append(conf)
## -------------------------------------------------------------
if False:
debug.info("list of all repo:")
for elem in out:
debug.info(" '" + elem.name + "'")
debug.info(" path: " + elem.path)
debug.info(" remotes: " + str(elem.remotes))
debug.info(" select_remote: " + str(elem.select_remote))
debug.info(" branch: " + elem.branch)
return out
def split_repo(git_repo):
debug.verbose("parse git repo in RAW: " + str(git_repo))
if len(git_repo) > 4 \
and git_repo[:4] == "http":
# http://wdfqsdfqs@qsdfqsdf/qsdfqsdf/qsdfqsdf/qsdfqs.git find the 3rd '/' and cut at this point
elements = git_repo.split('/')
if len(elements) < 4:
debug.error("Can not parse the git repository : '" + str(git_repo) + "' wrong format http?://xxx@xxx.xxx/****")
base = elements[0] + "/" + elements[1] + "/" + elements[2]
repo = git_repo[len(base)+1:]
elif len(git_repo) > 3 \
and git_repo[:3] == "git":
# git@qsdfqsdf:qsdfqsdf/qsdfqsdf/qsdfqs.git find the 1st ':' and cut at this point
elements = git_repo.split(':')
if len(elements) < 2:
debug.error("Can not parse the git repository : '" + str(git_repo) + "' wrong format git@xxx.xxx:****")
base = elements[0]
repo = git_repo[len(base)+1:]
else:
debug.error("Can not parse the git repository : '" + str(git_repo) + "' does not start with ['http', 'git']")
debug.verbose(" base: " + str(base))
debug.verbose(" repo: " + str(repo))
return (base, repo)