[DEV] update to the command actions

This commit is contained in:
Edouard DUPIN 2019-05-30 13:59:23 +02:00
parent 39a80ea719
commit 77cc304dac
8 changed files with 29 additions and 87 deletions

View File

@ -14,6 +14,7 @@ from island import env
from island import config from island import config
from island import multiprocess from island import multiprocess
from island import manifest from island import manifest
from island import commands
import os import os
@ -66,35 +67,13 @@ def execute(arguments):
continue continue
# check if the repository is modify # check if the repository is modify
cmd = "git diff --quiet" is_modify = commands.check_repository_is_modify(git_repo_path)
debug.verbose("execute : " + cmd)
ret_diff = multiprocess.run_command(cmd, cwd=git_repo_path)
# get local branch
cmd = "git branch"
debug.verbose("execute : " + cmd)
ret_branch = multiprocess.run_command(cmd, cwd=git_repo_path)
# get tracking branch
cmd = "git rev-parse --abbrev-ref --symbolic-full-name @{u}"
debug.verbose("execute : " + cmd)
ret_track = multiprocess.run_command(cmd, cwd=git_repo_path)
is_modify = True
if ret_diff[0] == 0:
is_modify = False
if is_modify == True: if is_modify == True:
debug.warning("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> modify data can not checkout new branch") debug.warning("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> modify data can not checkout new branch")
continue continue
list_branch = ret_branch[1].split('\n') list_branch_local = commands.get_list_branch_local(git_repo_path)
list_branch2 = [] select_branch = commands.get_current_branch(git_repo_path)
select_branch = ""
for elem_branch in list_branch:
list_branch2.append(elem_branch[2:])
if elem_branch[:2] == "* ":
select_branch = elem_branch[2:]
# check if we are on the good branch: # check if we are on the good branch:
if branch_to_checkout == select_branch: if branch_to_checkout == select_branch:
@ -102,8 +81,8 @@ def execute(arguments):
continue continue
# check if we have already checkout the branch before # check if we have already checkout the branch before
debug.verbose(" check : " + branch_to_checkout + " in " + str(list_branch2)) debug.verbose(" check : " + branch_to_checkout + " in " + str(list_branch_local))
if branch_to_checkout in list_branch2: if branch_to_checkout in list_branch_local:
cmd = "git checkout " + branch_to_checkout cmd = "git checkout " + branch_to_checkout
debug.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
ret = multiprocess.run_command(cmd, cwd=git_repo_path) ret = multiprocess.run_command(cmd, cwd=git_repo_path)
@ -118,18 +97,10 @@ def execute(arguments):
continue continue
# Check if the remote branch exist ... # Check if the remote branch exist ...
cmd = "git branch -a" list_branch_remote = commands.get_list_branch_remote(git_repo_path)
debug.verbose("execute : " + cmd) if elem.select_remote["name"] + "/" + branch_to_checkout in list_branch_remote:
ret_branch_all = multiprocess.run_command(cmd, cwd=git_repo_path) debug.info(" ==> find ...")
list_branch_all = ret_branch_all[1].split('\n') else:
exist = False
for elem_branch in list_branch_all:
debug.verbose(" check : '" + elem_branch + "' == '" + " remotes/" + elem.select_remote["name"] + "/" + branch_to_checkout + "'")
if elem_branch == " remotes/" + elem.select_remote["name"] + "/" + branch_to_checkout:
exist = True
debug.info(" ==> find ...")
break
if exist == False:
debug.info("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> NO remote branch") debug.info("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> NO remote branch")
continue continue

View File

@ -14,6 +14,7 @@ from island import env
from island import multiprocess from island import multiprocess
from island import config from island import config
from island import manifest from island import manifest
from island import commands
import os import os

View File

@ -14,6 +14,7 @@ from island import env
from island import config from island import config
from island import multiprocess from island import multiprocess
from island import manifest from island import manifest
from island import commands
import os import os

View File

@ -14,6 +14,7 @@ from island import env
from island import config from island import config
from island import multiprocess from island import multiprocess
from island import manifest from island import manifest
from island import commands
import os import os

View File

@ -12,6 +12,7 @@ from realog import debug
from island import tools from island import tools
from island import env from island import env
from island import config from island import config
from island import commands
from island import multiprocess from island import multiprocess
import os import os

View File

@ -14,6 +14,7 @@ from island import env
from island import config from island import config
from island import multiprocess from island import multiprocess
from island import manifest from island import manifest
from island import commands
import os import os

View File

@ -14,6 +14,7 @@ from island import env
from island import multiprocess from island import multiprocess
from island import config from island import config
from island import manifest from island import manifest
from island import commands
import os import os
@ -53,67 +54,31 @@ def execute(arguments):
id_element = 0 id_element = 0
for elem in all_project: for elem in all_project:
id_element += 1 id_element += 1
debug.verbose("status : " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name)) debug.verbose("status : " + str(id_element) + " / " + str(len(all_project)) + " : " + str(elem.name))
#debug.debug("elem : " + str(elem)) #debug.debug("elem : " + str(elem))
git_repo_path = os.path.join(env.get_island_root_path(), elem.path) git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
if os.path.exists(git_repo_path) == False: if os.path.exists(git_repo_path) == False:
debug.info("" + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + "\r\t\t\t\t\t\t\t\t\t" + " (not download)") debug.info("" + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + "\r\t\t\t\t\t\t\t\t\t" + " (not download)")
continue continue
# check if the repository is modify is_modify = commands.check_repository_is_modify(git_repo_path)
cmd = "git diff --quiet" list_branch = commands.get_list_branch_all(git_repo_path)
debug.verbose("execute : " + cmd) select_branch = commands.get_current_branch(git_repo_path)
ret_diff = multiprocess.run_command(cmd, cwd=git_repo_path) debug.verbose("List all branch: " + str(list_branch))
# get local branch
cmd = "git branch -a"
debug.verbose("execute : " + cmd)
ret_branch = multiprocess.run_command(cmd, cwd=git_repo_path)
is_modify = True
if ret_diff[0] == 0:
is_modify = False
list_branch = ret_branch[1].split('\n')
list_branch2 = []
list_branch3 = []
select_branch = ""
for elem_branch in list_branch:
if len(elem_branch.split(" -> ")) != 1:
continue
if elem_branch[2:10] == "remotes/":
elem_branch = elem_branch[:2] + elem_branch[10:]
if elem_branch[:2] == "* ":
list_branch2.append([elem_branch[2:], True])
select_branch = elem_branch[2:]
else:
list_branch2.append([elem_branch[2:], False])
list_branch3.append(elem_branch[2:])
debug.verbose("List all branch: " + str(list_branch3))
# get tracking branch # get tracking branch
if argument_remote_name == "": tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, select_branch)
cmd = "git rev-parse --abbrev-ref --symbolic-full-name @{u}" if tracking_remote_branch == None:
debug.verbose("execute : " + cmd) debug.info("" + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + "\r\t\t\t\t\t\t\t (NO BRANCH)")
ret_track = multiprocess.run_command(cmd, cwd=git_repo_path) continue
else:
debug.extreme_verbose("check if exist " + argument_remote_name + "/" + select_branch + " in " + str(list_branch3))
if argument_remote_name + "/" + select_branch not in list_branch3:
debug.info("" + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + "\r\t\t\t\t\t\t\t (NO BRANCH)")
continue;
else:
ret_track = [True, argument_remote_name + "/" + select_branch]
modify_status = " " modify_status = " "
if is_modify == True: if is_modify == True:
modify_status = " *** " modify_status = " *** "
debug.verbose("select branch = '" + select_branch + "' is modify : " + str(is_modify) + " track: '" + str(ret_track[1]) + "'") debug.verbose("select branch = '" + select_branch + "' is modify : " + str(is_modify) + " track: '" + str(tracking_remote_branch) + "'")
cmd = "git rev-list " + select_branch ret_current_branch_sha1 = commands.get_revision_list_to_branch(git_repo_path, select_branch)
debug.verbose("execute : " + cmd) ret_track_branch_sha1 = commands.get_revision_list_to_branch(git_repo_path, tracking_remote_branch)
ret_current_branch_sha1 = multiprocess.run_command(cmd, cwd=git_repo_path)[1].split('\n')
cmd = "git rev-list " + ret_track[1]
debug.verbose("execute : " + cmd)
ret_track_branch_sha1 = multiprocess.run_command(cmd, cwd=git_repo_path)[1].split('\n')
# remove all identical sha1 ==> not needed for this # remove all identical sha1 ==> not needed for this
in_forward = 0 in_forward = 0
for elem_sha1 in ret_current_branch_sha1: for elem_sha1 in ret_current_branch_sha1:

View File

@ -14,6 +14,7 @@ from island import env
from island import config from island import config
from island import multiprocess from island import multiprocess
from island import manifest from island import manifest
from island import commands
import os import os