[DEV] continue REWORK, pb with EXML
This commit is contained in:
parent
9148d9242c
commit
1351757c48
@ -12,8 +12,8 @@ import org.atriasoft.island.model.ActionException;
|
|||||||
import org.atriasoft.island.model.ActionInterface;
|
import org.atriasoft.island.model.ActionInterface;
|
||||||
|
|
||||||
public class Actions {
|
public class Actions {
|
||||||
private static Map<String, Class<ActionInterface>> actions = new HashMap<String,Class<ActionInterface>>();
|
private static Map<String, Class<? extends ActionInterface>> actions = new HashMap<String,Class<? extends ActionInterface>>();
|
||||||
public static void addAction(final String name, final Class<ActionInterface> klass) {
|
public static <T extends ActionInterface>void addAction(final String name, final Class<T> klass) {
|
||||||
Actions.actions.put(name, klass);
|
Actions.actions.put(name, klass);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -52,7 +52,7 @@ public class Actions {
|
|||||||
* @throws ActionException
|
* @throws ActionException
|
||||||
*/
|
*/
|
||||||
private static String getFullActionHelp(final String action_name) throws ActionException {
|
private static String getFullActionHelp(final String action_name) throws ActionException {
|
||||||
Class<ActionInterface> actionClass = Actions.actions.get(action_name);
|
Class<? extends ActionInterface> actionClass = Actions.actions.get(action_name);
|
||||||
if (actionClass == null) {
|
if (actionClass == null) {
|
||||||
throw new ActionException("Action does not registered");
|
throw new ActionException("Action does not registered");
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ public class Actions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String getActionHelpExample(final String action_name) throws ActionException {
|
private static String getActionHelpExample(final String action_name) throws ActionException {
|
||||||
Class<ActionInterface> actionClass = Actions.actions.get(action_name);
|
Class<? extends ActionInterface> actionClass = Actions.actions.get(action_name);
|
||||||
if (actionClass == null) {
|
if (actionClass == null) {
|
||||||
throw new ActionException("Action does not registered");
|
throw new ActionException("Action does not registered");
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ public class Actions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void execute(final String action_name, final List<String> arguments) throws ActionException {
|
public static void execute(final String action_name, final List<String> arguments) throws ActionException {
|
||||||
Class<ActionInterface> actionClass = Actions.actions.get(action_name);
|
Class<? extends ActionInterface> actionClass = Actions.actions.get(action_name);
|
||||||
if (actionClass == null) {
|
if (actionClass == null) {
|
||||||
throw new ActionException("Action does not registered");
|
throw new ActionException("Action does not registered");
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ public class Actions {
|
|||||||
List<ArgElement> my_under_args = my_under_args_parser.parse(arguments, have_unknow_argument);
|
List<ArgElement> my_under_args = my_under_args_parser.parse(arguments, have_unknow_argument);
|
||||||
// search help if needed ==> permit to not duplicating code
|
// search help if needed ==> permit to not duplicating code
|
||||||
for (ArgElement elem : my_under_args) {
|
for (ArgElement elem : my_under_args) {
|
||||||
if (elem.getOptionName().equals("help") {
|
if (elem.getOptionName().equals("help")) {
|
||||||
Actions.usage(action_name, my_under_args_parser);
|
Actions.usage(action_name, my_under_args_parser);
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
@ -142,7 +142,12 @@ public class Actions {
|
|||||||
for (ArgElement elem : my_under_args) {
|
for (ArgElement elem : my_under_args) {
|
||||||
Log.debug(" " + elem.getOptionName() + "='" + elem.getArg() + "'");
|
Log.debug(" " + elem.getOptionName() + "='" + elem.getArg() + "'");
|
||||||
}
|
}
|
||||||
action.execute(my_under_args);
|
try {
|
||||||
|
action.execute(my_under_args);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public static boolean exist(final String action_to_do) {
|
public static boolean exist(final String action_to_do) {
|
||||||
return Actions.actions.get(action_to_do) != null;
|
return Actions.actions.get(action_to_do) != null;
|
||||||
|
116
src/org/atriasoft/island/Commands.java
Normal file
116
src/org/atriasoft/island/Commands.java
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
package org.atriasoft.island;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.island.internal.Log;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.api.Git;
|
||||||
|
import org.eclipse.jgit.api.ListBranchCommand.ListMode;
|
||||||
|
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||||
|
import org.eclipse.jgit.api.errors.NoHeadException;
|
||||||
|
import org.eclipse.jgit.lib.BranchConfig;
|
||||||
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
|
import org.eclipse.jgit.lib.Ref;
|
||||||
|
import org.eclipse.jgit.lib.Repository;
|
||||||
|
import org.eclipse.jgit.revwalk.RevCommit;
|
||||||
|
|
||||||
|
public class Commands {
|
||||||
|
private Commands() {}
|
||||||
|
public static List<String> get_list_branch_local(final Git git) throws GitAPIException {
|
||||||
|
List<String> remotes = Commands.get_list_branch_remote(git);
|
||||||
|
List<Ref> list_branch_local = git.branchList().setListMode(ListMode.ALL).call();
|
||||||
|
List<String> out = new ArrayList<>();
|
||||||
|
for (Ref elem1 : list_branch_local) {
|
||||||
|
if (!remotes.contains(elem1.getName())) {
|
||||||
|
out.add(elem1.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
public static List<String> get_list_branch_all(final Git git) throws GitAPIException {
|
||||||
|
List<Ref> list_branch_local = git.branchList().setListMode(ListMode.ALL).call();
|
||||||
|
List<String> out = new ArrayList<>();
|
||||||
|
for (Ref elem1 : list_branch_local) {
|
||||||
|
out.add(elem1.getName());
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> get_list_branch_remote(final Git git) throws GitAPIException {
|
||||||
|
List<Ref> list_branch_local = git.branchList().setListMode(ListMode.REMOTE).call();
|
||||||
|
List<String> out = new ArrayList<>();
|
||||||
|
for (Ref elem1 : list_branch_local) {
|
||||||
|
out.add(elem1.getName());
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* better git.getRepository().getBranch();
|
||||||
|
* @param git
|
||||||
|
* @return
|
||||||
|
* @throws GitAPIException
|
||||||
|
* @deprecated use git.getRepository().getBranch();
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static String get_current_branch(final Git git) throws GitAPIException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public static List<String> get_tags(final Git git) throws GitAPIException {
|
||||||
|
List<Ref> list_tag = git.tagList().call();
|
||||||
|
List<String> out = new ArrayList<>();
|
||||||
|
for (Ref elem1 : list_tag) {
|
||||||
|
out.add(elem1.getName());
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
public static String get_tracking_branch(final Git git, final String remote_name, final String select_branch) throws GitAPIException, IOException {
|
||||||
|
// get tracking branch
|
||||||
|
if (remote_name.isEmpty() || remote_name == null) {
|
||||||
|
return Commands.get_current_tracking_branch(git);
|
||||||
|
}
|
||||||
|
List<String> list_branch_remote = Commands.get_list_branch_remote(git);
|
||||||
|
Log.verbose("check if exist " + remote_name + "/" + select_branch + " in " + list_branch_remote);
|
||||||
|
String tmpBranchName = remote_name + "/" + select_branch;
|
||||||
|
if (!list_branch_remote.contains(tmpBranchName)) {
|
||||||
|
Log.debug(" ==> can not get remote branch");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return remote_name + "/" + select_branch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String get_current_tracking_branch(final Git git) throws IOException {
|
||||||
|
Repository repo = git.getRepository();
|
||||||
|
return new BranchConfig(repo.getConfig(), repo.getBranch()).getTrackingBranch();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ObjectId> get_revision_list_to_branch(final Git git, final String branch) throws NoHeadException, GitAPIException {
|
||||||
|
Iterable<RevCommit> commits = git.log().call();
|
||||||
|
List<ObjectId> out = new ArrayList<>();
|
||||||
|
for(RevCommit commit : commits ) {
|
||||||
|
ObjectId tmp = commit.toObjectId();
|
||||||
|
out.add(tmp);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> get_tags_current(final Git git) {
|
||||||
|
List<String> out = new ArrayList<>();
|
||||||
|
out.add("TODO");
|
||||||
|
out.add("TODO");
|
||||||
|
/*
|
||||||
|
cmd = "git tag --points-at"
|
||||||
|
Log.verbose("execute : " + cmd)
|
||||||
|
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||||
|
multiprocess.generic_display_error(return_value, "get_tags_current", error_only=true)
|
||||||
|
list_tags = []
|
||||||
|
for elem in return_value[1].split('\n'):
|
||||||
|
if elem != "":
|
||||||
|
list_tags.append(elem)
|
||||||
|
*/
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -97,11 +97,12 @@ public class Env {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
//String tmp = island_root_path.toAbsolutePath().toString();
|
//String tmp = island_root_path.toAbsolutePath().toString();
|
||||||
//Log.info("Current absolute path is: " + tmp);
|
|
||||||
Env.island_root_path = Paths.get("");
|
Env.island_root_path = Paths.get("");
|
||||||
Path tmpPath = Env.island_root_path;
|
Path tmpPath = Env.island_root_path.toAbsolutePath();
|
||||||
|
Log.info("Current absolute path is: " + tmpPath);
|
||||||
while (!Files.isDirectory(tmpPath.resolve("." + Env.get_system_base_name()))) {
|
while (!Files.isDirectory(tmpPath.resolve("." + Env.get_system_base_name()))) {
|
||||||
tmpPath = tmpPath.getParent();
|
tmpPath = tmpPath.getParent();
|
||||||
|
Log.info("test upper path: " + tmpPath);
|
||||||
if (tmpPath == null) {
|
if (tmpPath == null) {
|
||||||
Log.critical("the root path of " + Env.get_system_base_name() + " must not be upper parent paths of (" + Env.island_root_path.toAbsolutePath() + ")");
|
Log.critical("the root path of " + Env.get_system_base_name() + " must not be upper parent paths of (" + Env.island_root_path.toAbsolutePath() + ")");
|
||||||
}
|
}
|
||||||
|
@ -9,39 +9,20 @@ import java.util.Set;
|
|||||||
import org.atriasoft.death.ArgChoice;
|
import org.atriasoft.death.ArgChoice;
|
||||||
import org.atriasoft.death.ArgElement;
|
import org.atriasoft.death.ArgElement;
|
||||||
import org.atriasoft.death.Arguments;
|
import org.atriasoft.death.Arguments;
|
||||||
|
import org.atriasoft.island.actions.IslandActionCheckout;
|
||||||
|
import org.atriasoft.island.actions.IslandActionStatus;
|
||||||
import org.atriasoft.island.internal.Log;
|
import org.atriasoft.island.internal.Log;
|
||||||
import org.atriasoft.island.model.ActionException;
|
import org.atriasoft.island.model.ActionException;
|
||||||
|
|
||||||
public class MainIsland {
|
public class MainIsland {
|
||||||
private static Arguments my_args = new Arguments();
|
private final Arguments my_args = new Arguments();
|
||||||
|
|
||||||
//Log.verbose("List of actions: " + str(actions.get_list_of_action()))
|
|
||||||
static {
|
|
||||||
MainIsland.my_args.addSection("option", "Can be set one time in all case");
|
|
||||||
MainIsland.my_args.add("h", "help", null, "Display this help");
|
|
||||||
MainIsland.my_args.add("v", "verbose", Arrays.asList(
|
|
||||||
new ArgChoice("0","None"),
|
|
||||||
new ArgChoice("1","error"),
|
|
||||||
new ArgChoice("2","warning"),
|
|
||||||
new ArgChoice("3","info"),
|
|
||||||
new ArgChoice("4","debug"),
|
|
||||||
new ArgChoice("5","verbose"),
|
|
||||||
new ArgChoice("6","extreme_verbose")
|
|
||||||
), "display debug level (verbose) default =2");
|
|
||||||
MainIsland.my_args.add("c", "color", null, "Display message in color");
|
|
||||||
MainIsland.my_args.add("n", "no-fetch-manifest", null, "Disable the fetch of the manifest", false);
|
|
||||||
MainIsland.my_args.add("F", "filter", null, "Filter the action on a list of path or subpath: -f library", true);
|
|
||||||
MainIsland.my_args.add("f", "folder", null, "Display the folder instead of the git repository name", false);
|
|
||||||
MainIsland.my_args.add("w", "wait", null, "Wait between 2 acces on the server (needed when the server is really slow to remove ssh connection) (default=" + Env.get_wait_between_sever_command() + ")", true);
|
|
||||||
//my_args.setStopAt(actions.get_list_of_action());
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// @brief Display the help of this makefile.
|
// @brief Display the help of this makefile.
|
||||||
//
|
//
|
||||||
public static void usage() {
|
public void usage() {
|
||||||
// generic argument displayed :
|
// generic argument displayed :
|
||||||
MainIsland.my_args.display("");
|
this.my_args.display("");
|
||||||
Log.print(" Action availlable" );
|
Log.print(" Action availlable" );
|
||||||
Set<String> list_actions = Actions.getListOfAction();
|
Set<String> list_actions = Actions.getListOfAction();
|
||||||
for (String elem : list_actions) {
|
for (String elem : list_actions) {
|
||||||
@ -75,11 +56,11 @@ public class MainIsland {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// preparse the argument to get the verbose element for Log mode
|
// preparse the argument to get the verbose element for Log mode
|
||||||
public static boolean parse_generic_arg(final ArgElement argument, final boolean active) {
|
public boolean parse_generic_arg(final ArgElement argument, final boolean active) {
|
||||||
Log.verbose("parse arg : " + argument.getOptionName() + " " + argument.getArg() + " active=" + active);
|
Log.verbose("parse arg : " + argument.getOptionName() + " " + argument.getArg() + " active=" + active);
|
||||||
if (argument.getOptionName().equals("help") ){
|
if (argument.getOptionName().equals("help") ){
|
||||||
if (!active) {
|
if (!active) {
|
||||||
MainIsland.usage();
|
usage();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -176,21 +157,39 @@ public class MainIsland {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
public MainIsland() {
|
public MainIsland() {
|
||||||
|
Actions.addAction("status", IslandActionStatus.class);
|
||||||
|
Actions.addAction("checkout", IslandActionCheckout.class);
|
||||||
|
this.my_args.addSection("option", "Can be set one time in all case");
|
||||||
|
this.my_args.add("h", "help", null, "Display this help");
|
||||||
|
this.my_args.add("v", "verbose", Arrays.asList(
|
||||||
|
new ArgChoice("0","None"),
|
||||||
|
new ArgChoice("1","error"),
|
||||||
|
new ArgChoice("2","warning"),
|
||||||
|
new ArgChoice("3","info"),
|
||||||
|
new ArgChoice("4","debug"),
|
||||||
|
new ArgChoice("5","verbose"),
|
||||||
|
new ArgChoice("6","extreme_verbose")
|
||||||
|
), "display debug level (verbose) default =2");
|
||||||
|
this.my_args.add("c", "color", null, "Display message in color");
|
||||||
|
this.my_args.add("n", "no-fetch-manifest", null, "Disable the fetch of the manifest", false);
|
||||||
|
this.my_args.add("F", "filter", null, "Filter the action on a list of path or subpath: -f library", true);
|
||||||
|
this.my_args.add("f", "folder", null, "Display the folder instead of the git repository name", false);
|
||||||
|
this.my_args.add("w", "wait", null, "Wait between 2 acces on the server (needed when the server is really slow to remove ssh connection) (default=" + Env.get_wait_between_sever_command() + ")", true);
|
||||||
|
this.my_args.setStopAt(List.copyOf(Actions.getListOfAction()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void run(final String[] args) throws ActionException {
|
void run(final String[] args) throws ActionException {
|
||||||
List<String> argss = Arrays.asList(args);
|
List<String> argss = Arrays.asList(args);
|
||||||
List<ArgElement> local_argument = MainIsland.my_args.parse(argss);
|
List<ArgElement> local_argument = this.my_args.parse(argss);
|
||||||
|
|
||||||
// parse default unique argument:
|
// parse default unique argument:
|
||||||
for (ArgElement argument : local_argument) {
|
for (ArgElement argument : local_argument) {
|
||||||
MainIsland.parse_generic_arg(argument, true);
|
parse_generic_arg(argument, true);
|
||||||
}
|
}
|
||||||
// remove all generic arguments:
|
// remove all generic arguments:
|
||||||
List<ArgElement> new_argument_list = new ArrayList<>();
|
List<ArgElement> new_argument_list = new ArrayList<>();
|
||||||
for (ArgElement argument : local_argument) {
|
for (ArgElement argument : local_argument) {
|
||||||
if (MainIsland.parse_generic_arg(argument, false)) {
|
if (parse_generic_arg(argument, false)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
new_argument_list.add(argument);
|
new_argument_list.add(argument);
|
||||||
@ -201,7 +200,7 @@ public class MainIsland {
|
|||||||
Log.warning("--------------------------------------");
|
Log.warning("--------------------------------------");
|
||||||
Log.warning("Missing the action to do ...");
|
Log.warning("Missing the action to do ...");
|
||||||
Log.warning("--------------------------------------");
|
Log.warning("--------------------------------------");
|
||||||
MainIsland.usage();
|
usage();
|
||||||
}
|
}
|
||||||
String action_to_do = new_argument_list.get(0).getArg();
|
String action_to_do = new_argument_list.get(0).getArg();
|
||||||
new_argument_list.remove(0);
|
new_argument_list.remove(0);
|
||||||
@ -209,7 +208,7 @@ public class MainIsland {
|
|||||||
Log.warning("--------------------------------------");
|
Log.warning("--------------------------------------");
|
||||||
Log.warning("Wrong action type : '" + action_to_do + "' availlable list: " + Actions.getListOfAction());
|
Log.warning("Wrong action type : '" + action_to_do + "' availlable list: " + Actions.getListOfAction());
|
||||||
Log.warning("--------------------------------------");
|
Log.warning("--------------------------------------");
|
||||||
MainIsland.usage();
|
usage();
|
||||||
}
|
}
|
||||||
// todo : Remove this
|
// todo : Remove this
|
||||||
if (!action_to_do.equals("init") && !Files.exists(Env.get_island_path())) {
|
if (!action_to_do.equals("init") && !Files.exists(Env.get_island_path())) {
|
||||||
@ -217,7 +216,7 @@ public class MainIsland {
|
|||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
argss = argss.subList(MainIsland.my_args.getLastParsed()+1, argss.size());
|
argss = argss.subList(this.my_args.getLastParsed()+1, argss.size());
|
||||||
Actions.execute(action_to_do, argss);
|
Actions.execute(action_to_do, argss);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import org.atriasoft.island.model.ActionInterface;
|
|||||||
import org.atriasoft.island.model.ConfigManifest;
|
import org.atriasoft.island.model.ConfigManifest;
|
||||||
import org.atriasoft.island.model.ProjectConfig;
|
import org.atriasoft.island.model.ProjectConfig;
|
||||||
|
|
||||||
public class islandActionCheckout implements ActionInterface {
|
public class IslandActionCheckout extends ActionInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String help() {
|
public String help() {
|
||||||
@ -35,18 +35,18 @@ public class islandActionCheckout implements ActionInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final List<ArgElement> _arguments) throws ActionException {
|
public void execute(final List<ArgElement> _arguments) throws ActionException, Exception {
|
||||||
|
|
||||||
String argument_remote_name = "";
|
String argument_remote_name = "";
|
||||||
String branch_to_checkout = "";
|
String branch_to_checkout = "";
|
||||||
for (ArgElement elem : _arguments) {
|
for (ArgElement elem : _arguments) {
|
||||||
if (elem.getOptionName().equals("remote")) {
|
if (elem.getOptionName().equals("remote")) {
|
||||||
Log.info("find remote name: '" + elem.getArg() + "'");
|
Log.info("find remote name{ '" + elem.getArg() + "'");
|
||||||
argument_remote_name = elem.getArg();
|
argument_remote_name = elem.getArg();
|
||||||
} else if (elem.getOptionName().equals("branch")) {
|
} else if (elem.getOptionName().equals("branch")) {
|
||||||
branch_to_checkout = elem.getArg();
|
branch_to_checkout = elem.getArg();
|
||||||
} else {
|
} else {
|
||||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'");
|
Log.error("Wrong argument{ '" + elem.getOptionName() + "' '" + elem.getArg() + "'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,18 +55,18 @@ public class islandActionCheckout implements ActionInterface {
|
|||||||
|
|
||||||
ConfigManifest configuration = Config.getUniqueConfig();
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
// update the local configuration file:
|
// update the local configuration file{
|
||||||
configuration.setBranch(branch_to_checkout);
|
configuration.setBranch(branch_to_checkout);
|
||||||
configuration.store();
|
configuration.store();
|
||||||
|
|
||||||
Path file_source_manifest = Env.get_island_path_manifest().resolve(configuration.getManifestName());
|
Path file_source_manifest = Env.get_island_path_manifest().resolve(configuration.getManifestName());
|
||||||
if (!Files.exists(file_source_manifest)) {
|
if (!Files.exists(file_source_manifest)) {
|
||||||
Log.critical("Missing manifest file : '" + file_source_manifest.toAbsolutePath() + "'");
|
Log.critical("Missing manifest file { '" + file_source_manifest.toAbsolutePath() + "'");
|
||||||
}
|
}
|
||||||
Manifest mani = new Manifest(file_source_manifest);
|
Manifest mani = new Manifest(file_source_manifest);
|
||||||
|
|
||||||
List<ProjectConfig> all_project = mani.get_all_configs();
|
List<ProjectConfig> all_project = mani.get_all_configs();
|
||||||
Log.info("checkout of: " + all_project.size() + " projects");
|
Log.info("checkout of{ " + all_project.size() + " projects");
|
||||||
int id_element = 0;
|
int id_element = 0;
|
||||||
boolean have_error = false;
|
boolean have_error = false;
|
||||||
for (ProjectConfig elem : all_project) {
|
for (ProjectConfig elem : all_project) {
|
92
src/org/atriasoft/island/actions/IslandActionStatus.java
Normal file
92
src/org/atriasoft/island/actions/IslandActionStatus.java
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
package org.atriasoft.island.actions;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.death.ArgElement;
|
||||||
|
import org.atriasoft.death.Arguments;
|
||||||
|
import org.atriasoft.island.Config;
|
||||||
|
import org.atriasoft.island.Env;
|
||||||
|
import org.atriasoft.island.Manifest;
|
||||||
|
import org.atriasoft.island.Tools;
|
||||||
|
import org.atriasoft.island.internal.Log;
|
||||||
|
import org.atriasoft.island.model.ActionException;
|
||||||
|
import org.atriasoft.island.model.ActionInterface;
|
||||||
|
import org.atriasoft.island.model.ConfigManifest;
|
||||||
|
import org.atriasoft.island.model.ProjectConfig;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.api.Git;
|
||||||
|
|
||||||
|
public class IslandActionStatus extends ActionInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String help() {
|
||||||
|
return "Get the status of all the repositories";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add_specific_arguments(final Arguments myArgs, final String section) {
|
||||||
|
myArgs.add("r", "remote", null, "Name of the remote server", true);
|
||||||
|
myArgs.add("t", "tags", null, "Display if the commit is on a tag (and display it)", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(final List<ArgElement> _arguments) throws ActionException, Exception {
|
||||||
|
String argument_remote_name = "";
|
||||||
|
boolean argument_display_tag = false;
|
||||||
|
for (ArgElement elem : _arguments) {
|
||||||
|
if (elem.getOptionName().equals("remote")) {
|
||||||
|
Log.info("find remote name: '" + elem.getArg() + "'");
|
||||||
|
argument_remote_name = elem.getArg();
|
||||||
|
} else if (elem.getOptionName().equals("tags")) {
|
||||||
|
argument_display_tag = true;
|
||||||
|
} else {
|
||||||
|
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check system is OK
|
||||||
|
Manifest.checkIsInit();
|
||||||
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
|
Path file_source_manifest = Env.get_island_path_manifest().resolve(configuration.getManifestName());
|
||||||
|
if (!Files.exists(file_source_manifest)) {
|
||||||
|
Log.critical("Missing manifest file : '" + file_source_manifest + "'");
|
||||||
|
}
|
||||||
|
Manifest mani = new Manifest(file_source_manifest);
|
||||||
|
Git git = Git.open(Env.get_island_path_manifest().toFile());
|
||||||
|
boolean is_modify_manifest = git.status().call().hasUncommittedChanges();
|
||||||
|
if (is_modify_manifest) {
|
||||||
|
Log.info("!!!!!!!!!!!! MANIFEST is modify !!!!!!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ProjectConfig> all_project = mani.get_all_configs();
|
||||||
|
Log.info("status of: " + all_project.size() + " projects");
|
||||||
|
int id_element = 0;
|
||||||
|
|
||||||
|
/* Display status of manifest ==> todo later ...
|
||||||
|
elem = configuration.get_manifest_config()
|
||||||
|
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||||
|
status.display_status(elem, argument_remote_name, argument_display_tag, id_element, base_display)
|
||||||
|
*/
|
||||||
|
boolean is_behind = false;
|
||||||
|
for (ProjectConfig elem : all_project) {
|
||||||
|
id_element++;
|
||||||
|
String base_display = Tools.get_list_base_display(id_element, all_project.size(), elem);
|
||||||
|
int ret = Status.displayStatus(elem, argument_remote_name, argument_display_tag, id_element, base_display);
|
||||||
|
if (ret != 0) {
|
||||||
|
is_behind = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is_behind == true) {
|
||||||
|
//return Env.ret_action_need_updtate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String helpExample() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,102 +1,214 @@
|
|||||||
package org.atriasoft.island.actions;
|
package org.atriasoft.island.actions;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.island.Commands;
|
||||||
|
import org.atriasoft.island.Env;
|
||||||
import org.atriasoft.island.internal.Log;
|
import org.atriasoft.island.internal.Log;
|
||||||
import org.atriasoft.island.model.ProjectConfig;
|
import org.atriasoft.island.model.ProjectConfig;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.api.Git;
|
||||||
|
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||||
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
|
|
||||||
public class Status {
|
public class Status {
|
||||||
|
|
||||||
public static boolean checkout_elem(final ProjectConfig elem, final String argument_remote_name, final String branch_to_checkout, final String base_display) {
|
private static String default_behind_message = "[DEV] update dev tag version";
|
||||||
|
private static String default_update_message = "[VERSION] update dev tag version";
|
||||||
|
private static String base_name_of_a_tagged_branch = "branch_on_tag_";
|
||||||
|
|
||||||
|
public static boolean checkout_elem(final ProjectConfig elem, final String argument_remote_name, String branch_to_checkout, final String base_display) throws Exception {
|
||||||
Log.verbose("checkout : " + base_display);
|
Log.verbose("checkout : " + base_display);
|
||||||
git_repo_path = new Path(Env.get_island_root_path(), elem.path)
|
Path git_repo_path = Env.get_island_root_path().resolve(elem.getPath());
|
||||||
if os.path.exists(git_repo_path) == false:
|
if (!Files.exists(git_repo_path)){
|
||||||
Log.warning("checkout " + base_display + " ==> repository does not exist ...")
|
Log.warning("checkout " + base_display + " ==> repository does not exist ...");
|
||||||
return false
|
return false;
|
||||||
|
}
|
||||||
// check if the repository is modify
|
// check if the repository is modify
|
||||||
is_modify = commands.check_repository_is_modify(git_repo_path)
|
Git git = Git.open(git_repo_path.toFile());
|
||||||
if is_modify == true:
|
boolean is_modify = git.status().call().hasUncommittedChanges();
|
||||||
Log.warning("checkout " + base_display + " ==> modify data can not checkout new branch")
|
if (is_modify == true){
|
||||||
return false
|
Log.warning("checkout " + base_display + " ==> modify data can not checkout new branch");
|
||||||
|
return false;
|
||||||
list_branch_local = commands.get_list_branch_local(git_repo_path)
|
}
|
||||||
select_branch = commands.get_current_branch(git_repo_path)
|
List<String> list_branch_local = Commands.get_list_branch_local(git);
|
||||||
|
String select_branch = git.getRepository().getBranch();
|
||||||
is_tag = false
|
|
||||||
if branch_to_checkout.equals("__TAG__"):
|
|
||||||
branch_to_checkout = base_name_of_a_tagged_branch + elem.getTag();
|
|
||||||
is_tag = true
|
|
||||||
if elem.volatile == true:
|
|
||||||
Log.info("checkout " + base_display + " ==> Can not checkout for 'volatile' repository")
|
|
||||||
return true
|
|
||||||
if elem.tag == None:
|
|
||||||
Log.info("checkout " + base_display + " ==> Can not checkout for '''None''' Tag")
|
|
||||||
return true
|
|
||||||
// check if we are on the good branch:
|
|
||||||
if branch_to_checkout == select_branch:
|
|
||||||
Log.info("checkout " + base_display + " ==> No change already on good branch")
|
|
||||||
return true
|
|
||||||
|
|
||||||
|
boolean is_tag = false;
|
||||||
|
if (branch_to_checkout.equals("__TAG__")) {
|
||||||
|
branch_to_checkout = Status.base_name_of_a_tagged_branch + elem.getTag();
|
||||||
|
is_tag = true;
|
||||||
|
if (elem.isVolatile()) {
|
||||||
|
Log.info("checkout " + base_display + " ==> Can not checkout for 'volatile' repository");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (elem.getTag() == null) {
|
||||||
|
Log.info("checkout " + base_display + " ==> Can not checkout for 'null' Tag");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check if we are on the good branch{
|
||||||
|
if (branch_to_checkout.equals(select_branch)) {
|
||||||
|
Log.info("checkout " + base_display + " ==> No change already on good branch");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
// check if we have already checkout the branch before
|
// check if we have already checkout the branch before
|
||||||
Log.verbose(" check : " + branch_to_checkout + " in " + str(list_branch_local))
|
Log.verbose(" check : " + branch_to_checkout + " in " + list_branch_local);
|
||||||
if branch_to_checkout in list_branch_local:
|
if (list_branch_local.contains(branch_to_checkout)) {
|
||||||
cmd = "git checkout " + branch_to_checkout
|
git.checkout().setCreateBranch(false).setName(branch_to_checkout).call();
|
||||||
Log.verbose("execute : " + cmd)
|
Log.info("checkout " + base_display + " ==> switch branch");
|
||||||
ret = multiprocess.run_command(cmd, cwd=git_repo_path)
|
return true;
|
||||||
if ret[0] != 0 \
|
}
|
||||||
and ret[1] != "" \
|
|
||||||
and ret != false:
|
List<String> list_tags = Commands.get_tags(git);
|
||||||
Log.info("'" + str(ret) + "'")
|
if (list_tags.contains(branch_to_checkout)) {
|
||||||
Log.error("checkout " + base_display + " ==> Can not checkout to the correct branch")
|
is_tag = true;
|
||||||
return false
|
if (elem.getTag() == null) {
|
||||||
Log.info("checkout " + base_display + " ==> switch branch")
|
elem.setTag(branch_to_checkout);
|
||||||
// TODO : Check the number of commit to the origin/XXX branch ....
|
branch_to_checkout = Status.base_name_of_a_tagged_branch + elem.getTag();
|
||||||
return true
|
}
|
||||||
|
}
|
||||||
list_tags = commands.get_tags(git_repo_path)
|
|
||||||
if branch_to_checkout in list_tags:
|
|
||||||
is_tag = true
|
|
||||||
if elem.tag == None:
|
|
||||||
elem.tag = branch_to_checkout
|
|
||||||
branch_to_checkout = base_name_of_a_tagged_branch + str(elem.tag)
|
|
||||||
|
|
||||||
// Check if the remote branch exist ...
|
// Check if the remote branch exist ...
|
||||||
if is_tag == false:
|
if (is_tag) {
|
||||||
list_branch_remote = commands.get_list_branch_remote(git_repo_path)
|
Log.info("checkout " + base_display + " ==> NO remote branch");
|
||||||
if elem.select_remote["name"] + "/" + branch_to_checkout in list_branch_remote:
|
return true;
|
||||||
Log.info(" ==> find ...")
|
}
|
||||||
else:
|
List<String> list_branch_remote = Commands.get_list_branch_remote(git);
|
||||||
Log.info("checkout " + base_display + " ==> NO remote branch")
|
String tryRemoteBranch = elem.getSelectRemotes().getName() + "/" + branch_to_checkout;
|
||||||
return true
|
if (list_branch_remote.contains(tryRemoteBranch)) {
|
||||||
// checkout the new branch:
|
Log.info(" ==> find ...");
|
||||||
cmd = "git checkout --quiet " + elem.select_remote["name"] + "/" + branch_to_checkout + " -b " + branch_to_checkout
|
try {
|
||||||
// + " --track " + elem.select_remote["name"] + "/" + branch_to_checkout
|
git.checkout().setCreateBranch(true).setName(tryRemoteBranch).call();
|
||||||
Log.verbose("execute : " + cmd)
|
} catch (Exception ex) {
|
||||||
ret = multiprocess.run_command(cmd, cwd=git_repo_path)
|
ex.printStackTrace();
|
||||||
if ret[1] != "" \
|
Log.error("checkout " + base_display + " ==> Can not checkout to the correct branch");
|
||||||
and ret != false:
|
return false;
|
||||||
Log.info("'" + str(ret) + "'")
|
}
|
||||||
Log.error("checkout " + base_display + " ==> Can not checkout to the correct branch")
|
Log.info("checkout " + base_display + " ==> create new branch");
|
||||||
return false
|
return true;
|
||||||
Log.info("checkout " + base_display + " ==> create new branch")
|
}
|
||||||
return true
|
// Checkout a specific tags{
|
||||||
// Checkout a specific tags:
|
if (!list_tags.contains(elem.getTag())) {
|
||||||
if elem.tag in list_tags:
|
Log.info("checkout " + base_display + " ==> NO remote tags");
|
||||||
Log.info(" ==> find ...")
|
return true;
|
||||||
else:
|
}
|
||||||
Log.info("checkout " + base_display + " ==> NO remote tags")
|
Log.info(" ==> find ...");
|
||||||
return true
|
Log.todo("checkout " + base_display + " ==> Can not checkout to the correct tags MUST be inplemented");
|
||||||
// checkout the new branch:
|
return false;
|
||||||
cmd = "git checkout --quiet " + elem.tag + " -b " + branch_to_checkout
|
/*
|
||||||
// + " --track " + elem.select_remote["name"] + "/" + branch_to_checkout
|
// checkout the new branch{
|
||||||
Log.verbose("execute : " + cmd)
|
cmd = "git checkout --quiet " + elem.tag + " -b " + branch_to_checkout;
|
||||||
ret = multiprocess.run_command(cmd, cwd=git_repo_path)
|
// + " --track " + elem.select_remote["name"] + "/" + branch_to_checkout;
|
||||||
|
Log.verbose("execute : " + cmd);
|
||||||
|
ret = multiprocess.run_command(cmd, cwd=git_repo_path);
|
||||||
if ret[1] != "" \
|
if ret[1] != "" \
|
||||||
and ret != false:
|
and ret != false{
|
||||||
Log.info("'" + str(ret) + "'")
|
Log.info("'" + str(ret) + "'");
|
||||||
Log.error("checkout " + base_display + " ==> Can not checkout to the correct tags")
|
Log.error("checkout " + base_display + " ==> Can not checkout to the correct tags");
|
||||||
return false
|
return false;
|
||||||
Log.info("checkout " + base_display + " ==> create new branch: " + branch_to_checkout)
|
}
|
||||||
|
Log.info("checkout " + base_display + " ==> create new branch: " + branch_to_checkout);
|
||||||
return true;
|
return true;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
public static int displayStatus(final ProjectConfig elem, final String argument_remote_name, final boolean argument_display_tag, final int id_element, final String base_display) throws IOException, GitAPIException {
|
||||||
|
String volatileString = "";
|
||||||
|
if (elem.isVolatile()) {
|
||||||
|
volatileString = " (volatile)";
|
||||||
|
}
|
||||||
|
Log.verbose("status : " + base_display);
|
||||||
|
//Log.debug("elem : " + str(elem))
|
||||||
|
Path git_repo_path = Env.get_island_root_path().resolve(elem.getPath());
|
||||||
|
if (!Files.exists(git_repo_path)) {
|
||||||
|
Log.info(base_display + volatileString + "\r\t\t\t\t\t\t\t\t\t" + " (not download)");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Git git = Git.open(git_repo_path.toFile());
|
||||||
|
boolean is_modify = git.status().call().hasUncommittedChanges();
|
||||||
|
|
||||||
|
List<String> list_branch = Commands.get_list_branch_all(git);
|
||||||
|
String select_branch = git.getRepository().getBranch();
|
||||||
|
Log.verbose("List all branch: " + list_branch);
|
||||||
|
String tracking_remote_branch = null;
|
||||||
|
if (!select_branch.startsWith(Status.base_name_of_a_tagged_branch)) {
|
||||||
|
// get tracking branch
|
||||||
|
tracking_remote_branch = Commands.get_tracking_branch(git, argument_remote_name, select_branch);
|
||||||
|
if (tracking_remote_branch == null) {
|
||||||
|
Log.info(base_display + volatileString + "\r\t\t\t\t\t\t\t (NO BRANCH)");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tracking_remote_branch = select_branch.substring(Status.base_name_of_a_tagged_branch.length());
|
||||||
|
}
|
||||||
|
String modify_status = " ";
|
||||||
|
if (is_modify == true) {
|
||||||
|
modify_status = " *** ";
|
||||||
|
}
|
||||||
|
Log.verbose("select branch = '" + select_branch + "' is modify : " + is_modify + " track: '" + tracking_remote_branch + "'");
|
||||||
|
|
||||||
|
List<ObjectId> ret_current_branch_sha1 = Commands.get_revision_list_to_branch(git, select_branch);
|
||||||
|
List<ObjectId> ret_track_branch_sha1 = Commands.get_revision_list_to_branch(git, tracking_remote_branch);
|
||||||
|
// remove all identical sha1 ==> not needed for this
|
||||||
|
int in_forward = 0;
|
||||||
|
for (ObjectId elem_sha1 : ret_current_branch_sha1) {
|
||||||
|
if (!ret_track_branch_sha1.contains(elem_sha1)) {
|
||||||
|
in_forward++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int in_behind = 0;
|
||||||
|
for (ObjectId elem_sha1 : ret_track_branch_sha1) {
|
||||||
|
if (!ret_current_branch_sha1.contains(elem_sha1)) {
|
||||||
|
in_behind++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String behind_forward_comment = "";
|
||||||
|
if (in_forward != 0) {
|
||||||
|
behind_forward_comment += "forward=" + in_forward;
|
||||||
|
}
|
||||||
|
if (in_behind != 0) {
|
||||||
|
if (in_forward != 0) {
|
||||||
|
behind_forward_comment += " ";
|
||||||
|
}
|
||||||
|
behind_forward_comment += "behind=" + in_behind;
|
||||||
|
}
|
||||||
|
if (behind_forward_comment != "") {
|
||||||
|
behind_forward_comment = "\r\t\t\t\t\t\t\t\t\t\t\t\t[" + behind_forward_comment + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
String tags_comment = "";
|
||||||
|
// check the current tags of the repository
|
||||||
|
if (argument_display_tag) {
|
||||||
|
List<String> ret_current_tags = Commands.get_tags_current(git);
|
||||||
|
Log.verbose("tags found: " + ret_current_tags);
|
||||||
|
for (String elem_tag : ret_current_tags) {
|
||||||
|
if (!tags_comment.isEmpty()) {
|
||||||
|
tags_comment += ",";
|
||||||
|
}
|
||||||
|
tags_comment += elem_tag;
|
||||||
|
}
|
||||||
|
if (!tags_comment.isEmpty()) {
|
||||||
|
tags_comment = "\r\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[" + tags_comment + "]";
|
||||||
|
} else {
|
||||||
|
tags_comment = "\r\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t- - - - -";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Log.info(base_display + volatileString + "\r\t\t\t\t\t\t\t" + modify_status + "(" + select_branch + " -> " + tracking_remote_branch + ")" + behind_forward_comment + tags_comment);
|
||||||
|
if (is_modify) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
cmd = "git status --short"
|
||||||
|
Log.verbose("execute : " + cmd)
|
||||||
|
ret_diff = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||||
|
tmp_color_red = "\033[31m"
|
||||||
|
tmp_color_default= "\033[00m"
|
||||||
|
Log.info(tmp_color_red + ret_diff[1] + tmp_color_default)
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
return in_behind;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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):
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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):
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -4,69 +4,70 @@ import io.scenarium.logger.LogLevel;
|
|||||||
import io.scenarium.logger.Logger;
|
import io.scenarium.logger.Logger;
|
||||||
|
|
||||||
public class Log {
|
public class Log {
|
||||||
|
private static final boolean FORCE = true;
|
||||||
private static final String LIB_NAME = "island";
|
private static final String LIB_NAME = "island";
|
||||||
private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME);
|
private static final String LIB_NAME_DRAW = Logger.getDrawableName(Log.LIB_NAME);
|
||||||
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL);
|
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.CRITICAL);
|
||||||
private static final boolean PRINT_ERROR = Logger.getNeedPrint(LIB_NAME, LogLevel.ERROR);
|
private static final boolean PRINT_ERROR = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.ERROR);
|
||||||
private static final boolean PRINT_WARNING = Logger.getNeedPrint(LIB_NAME, LogLevel.WARNING);
|
private static final boolean PRINT_WARNING = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.WARNING);
|
||||||
private static final boolean PRINT_INFO = Logger.getNeedPrint(LIB_NAME, LogLevel.INFO);
|
private static final boolean PRINT_INFO = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.INFO);
|
||||||
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG);
|
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.DEBUG);
|
||||||
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LIB_NAME, LogLevel.VERBOSE);
|
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.VERBOSE);
|
||||||
private static final boolean PRINT_TODO = Logger.getNeedPrint(LIB_NAME, LogLevel.TODO);
|
private static final boolean PRINT_TODO = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.TODO);
|
||||||
private static final boolean PRINT_PRINT = Logger.getNeedPrint(LIB_NAME, LogLevel.PRINT);
|
private static final boolean PRINT_PRINT = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.PRINT);
|
||||||
|
|
||||||
public static void critical(final String data) {
|
public static void critical(final String data) {
|
||||||
if (PRINT_CRITICAL) {
|
if (Log.PRINT_CRITICAL || Log.FORCE) {
|
||||||
Logger.critical(LIB_NAME_DRAW, data);
|
Logger.critical(Log.LIB_NAME_DRAW, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void critical(final String data, final Exception e) {
|
public static void critical(final String data, final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
if (PRINT_CRITICAL) {
|
if (Log.PRINT_CRITICAL || Log.FORCE) {
|
||||||
Logger.critical(LIB_NAME_DRAW, data + " : " + e.getMessage());
|
Logger.critical(Log.LIB_NAME_DRAW, data + " : " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debug(final String data) {
|
public static void debug(final String data) {
|
||||||
if (PRINT_DEBUG) {
|
if (Log.PRINT_DEBUG || Log.FORCE) {
|
||||||
Logger.debug(LIB_NAME_DRAW, data);
|
Logger.debug(Log.LIB_NAME_DRAW, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void error(final String data) {
|
public static void error(final String data) {
|
||||||
if (PRINT_ERROR) {
|
if (Log.PRINT_ERROR || Log.FORCE) {
|
||||||
Logger.error(LIB_NAME_DRAW, data);
|
Logger.error(Log.LIB_NAME_DRAW, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void info(final String data) {
|
public static void info(final String data) {
|
||||||
if (PRINT_INFO) {
|
if (Log.PRINT_INFO || Log.FORCE) {
|
||||||
Logger.info(LIB_NAME_DRAW, data);
|
Logger.info(Log.LIB_NAME_DRAW, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void print(final String data) {
|
public static void print(final String data) {
|
||||||
if (PRINT_PRINT) {
|
if (Log.PRINT_PRINT || Log.FORCE) {
|
||||||
Logger.print(LIB_NAME_DRAW, data);
|
Logger.print(Log.LIB_NAME_DRAW, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void todo(final String data) {
|
public static void todo(final String data) {
|
||||||
if (PRINT_TODO) {
|
if (Log.PRINT_TODO || Log.FORCE) {
|
||||||
Logger.todo(LIB_NAME_DRAW, data);
|
Logger.todo(Log.LIB_NAME_DRAW, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void verbose(final String data) {
|
public static void verbose(final String data) {
|
||||||
if (PRINT_VERBOSE) {
|
if (Log.PRINT_VERBOSE || Log.FORCE) {
|
||||||
Logger.verbose(LIB_NAME_DRAW, data);
|
Logger.verbose(Log.LIB_NAME_DRAW, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void warning(final String data) {
|
public static void warning(final String data) {
|
||||||
if (PRINT_WARNING) {
|
if (Log.PRINT_WARNING || Log.FORCE) {
|
||||||
Logger.warning(LIB_NAME_DRAW, data);
|
Logger.warning(Log.LIB_NAME_DRAW, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,19 +5,19 @@ import java.util.List;
|
|||||||
import org.atriasoft.death.ArgElement;
|
import org.atriasoft.death.ArgElement;
|
||||||
import org.atriasoft.death.Arguments;
|
import org.atriasoft.death.Arguments;
|
||||||
|
|
||||||
public interface ActionInterface {
|
public abstract class ActionInterface {
|
||||||
/**
|
/**
|
||||||
* Get the global description of the current action
|
* Get the global description of the current action
|
||||||
* @return the description string (fist line if reserved for the overview, all is for the specific display)
|
* @return the description string (fist line if reserved for the overview, all is for the specific display)
|
||||||
*/
|
*/
|
||||||
String help();
|
public abstract String help();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Add argument to the specific action
|
* @brief Add argument to the specific action
|
||||||
* @param[in,out] my_args (death.Arguments) Argument manager
|
* @param[in,out] my_args (death.Arguments) Argument manager
|
||||||
* @param[in] section Name of the currect action
|
* @param[in] section Name of the currect action
|
||||||
*/
|
*/
|
||||||
default void addSpecificArguments(Arguments myArgs, String section) {
|
public void addSpecificArguments(final Arguments myArgs, final String section) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ public interface ActionInterface {
|
|||||||
* Set the option argument are not able to check if the argument are correct or not
|
* Set the option argument are not able to check if the argument are correct or not
|
||||||
* @return Have parameter without arguments
|
* @return Have parameter without arguments
|
||||||
*/
|
*/
|
||||||
default boolean haveUnknowArgument() {
|
public boolean haveUnknowArgument() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ public interface ActionInterface {
|
|||||||
* @param myArgs (death.Arguments) Argument manager
|
* @param myArgs (death.Arguments) Argument manager
|
||||||
* @param section Name of the current action
|
* @param section Name of the current action
|
||||||
*/
|
*/
|
||||||
void add_specific_arguments(Arguments myArgs, String section);
|
public abstract void add_specific_arguments(Arguments myArgs, String section);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the action required.
|
* Execute the action required.
|
||||||
@ -44,9 +44,9 @@ public interface ActionInterface {
|
|||||||
* -11 : ACTION execution system error
|
* -11 : ACTION execution system error
|
||||||
* -12 : ACTION Wrong parameters
|
* -12 : ACTION Wrong parameters
|
||||||
*/
|
*/
|
||||||
public void execute(List<ArgElement> _arguments) throws ActionException;
|
public abstract void execute(List<ArgElement> _arguments) throws ActionException, Exception;
|
||||||
|
|
||||||
String helpExample();
|
public abstract String helpExample();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ public class ProjectConfig {
|
|||||||
private String name;
|
private String name;
|
||||||
private String path;
|
private String path;
|
||||||
private String tag;
|
private String tag;
|
||||||
|
private boolean volatileElement = false;
|
||||||
private List<RemoteConfig> remotes = new ArrayList<>();
|
private List<RemoteConfig> remotes = new ArrayList<>();
|
||||||
RemoteConfig selectRemotes = null;
|
RemoteConfig selectRemotes = null;
|
||||||
public ProjectConfig(final String name, final String path, final String tag) {
|
public ProjectConfig(final String name, final String path, final String tag) {
|
||||||
@ -47,4 +48,10 @@ public class ProjectConfig {
|
|||||||
public void setSelectRemotes(final RemoteConfig selectRemotes) {
|
public void setSelectRemotes(final RemoteConfig selectRemotes) {
|
||||||
this.selectRemotes = selectRemotes;
|
this.selectRemotes = selectRemotes;
|
||||||
}
|
}
|
||||||
|
public boolean isVolatile() {
|
||||||
|
return this.volatileElement;
|
||||||
|
}
|
||||||
|
public void setVolatile(final boolean volatileElement) {
|
||||||
|
this.volatileElement = volatileElement;
|
||||||
|
}
|
||||||
}
|
}
|
@ -48,9 +48,9 @@ public void execute(_arguments):
|
|||||||
cmd += elem.getArg() + " "
|
cmd += elem.getArg() + " "
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||||
if os.path.exists(file_source_manifest) == false:
|
if os.path.exists(file_source_manifest) == false:
|
||||||
|
@ -60,9 +60,9 @@ public void execute(_arguments):
|
|||||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||||
if os.path.exists(file_source_manifest) == false:
|
if os.path.exists(file_source_manifest) == false:
|
||||||
|
@ -52,9 +52,9 @@ public void execute(_arguments):
|
|||||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||||
if os.path.exists(file_source_manifest) == false:
|
if os.path.exists(file_source_manifest) == false:
|
||||||
|
@ -58,9 +58,9 @@ public void execute(_arguments):
|
|||||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||||
if os.path.exists(file_source_manifest) == false:
|
if os.path.exists(file_source_manifest) == false:
|
||||||
|
@ -52,12 +52,12 @@ public void execute(_arguments):
|
|||||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
Log.info("fetch manifest : '" + str(Env.get_island_path_manifest()) + "'")
|
Log.info("fetch manifest : '" + str(Env.get_island_path_manifest()) + "'")
|
||||||
commands.fetch(Env.get_island_path_manifest(), "origin")
|
commands.fetch(Env.get_island_path_manifest(), "origin")
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||||
if os.path.exists(file_source_manifest) == false:
|
if os.path.exists(file_source_manifest) == false:
|
||||||
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||||
|
@ -57,9 +57,9 @@ public void execute(_arguments):
|
|||||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
|
|
||||||
elem = configuration.get_manifest_config()
|
elem = configuration.get_manifest_config()
|
||||||
|
@ -48,9 +48,9 @@ public void execute(_arguments):
|
|||||||
Log.error("pull Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
Log.error("pull Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||||
if os.path.exists(file_source_manifest) == false:
|
if os.path.exists(file_source_manifest) == false:
|
||||||
|
@ -52,9 +52,9 @@ public void execute(_arguments):
|
|||||||
Log.error("pull Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
Log.error("pull Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||||
if os.path.exists(file_source_manifest) == false:
|
if os.path.exists(file_source_manifest) == false:
|
||||||
|
@ -53,9 +53,9 @@ public void execute(_arguments):
|
|||||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
elem = configuration.get_manifest_config()
|
elem = configuration.get_manifest_config()
|
||||||
base_display = tools.get_list_base_display(0, 0, elem)
|
base_display = tools.get_list_base_display(0, 0, elem)
|
||||||
ret = status.display_status(elem, argument_remote_name, argument_display_tag, 0, base_display)
|
ret = status.display_status(elem, argument_remote_name, argument_display_tag, 0, base_display)
|
||||||
|
@ -47,9 +47,9 @@ public void execute(_arguments):
|
|||||||
Log.error("pull Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
Log.error("pull Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
Log.info("update manifest : '" + str(Env.get_island_path_manifest()) + "'")
|
Log.info("update manifest : '" + str(Env.get_island_path_manifest()) + "'")
|
||||||
is_modify_manifest = commands.check_repository_is_modify(Env.get_island_path_manifest())
|
is_modify_manifest = commands.check_repository_is_modify(Env.get_island_path_manifest())
|
||||||
|
@ -52,9 +52,9 @@ public void execute(_arguments):
|
|||||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||||
if os.path.exists(file_source_manifest) == false:
|
if os.path.exists(file_source_manifest) == false:
|
||||||
|
@ -1,92 +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 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 "Get the status of all the repositories"
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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("r", "remote", haveParam=true, desc="Name of the remote server")
|
|
||||||
_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
|
|
||||||
//#
|
|
||||||
public void execute(_arguments):
|
|
||||||
argument_remote_name = ""
|
|
||||||
argument_display_tag = false
|
|
||||||
for elem in _arguments:
|
|
||||||
if elem.getOptionName().equals("remote":
|
|
||||||
Log.info("find remote name: '" + elem.getArg() + "'")
|
|
||||||
argument_remote_name = elem.getArg()
|
|
||||||
} else if elem.getOptionName().equals("tags":
|
|
||||||
argument_display_tag = true
|
|
||||||
else:
|
|
||||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
|
||||||
|
|
||||||
// check system is OK
|
|
||||||
manifest.check_lutin_is_init()
|
|
||||||
configuration = config.get_unique_config()
|
|
||||||
|
|
||||||
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)
|
|
||||||
is_modify_manifest = commands.check_repository_is_modify(Env.get_island_path_manifest())
|
|
||||||
if is_modify_manifest == true:
|
|
||||||
Log.info("!!!!!!!!!!!! MANIFEST is modify !!!!!!!!")
|
|
||||||
|
|
||||||
|
|
||||||
all_project = mani.get_all_configs()
|
|
||||||
Log.info("status of: " + str(len(all_project)) + " projects")
|
|
||||||
id_element = 0
|
|
||||||
|
|
||||||
elem = configuration.get_manifest_config()
|
|
||||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
|
||||||
status.display_status(elem, argument_remote_name, argument_display_tag, id_element, base_display)
|
|
||||||
|
|
||||||
is_behind = false
|
|
||||||
for elem in all_project:
|
|
||||||
id_element += 1
|
|
||||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
|
||||||
ret = status.display_status(elem, argument_remote_name, argument_display_tag, id_element, base_display)
|
|
||||||
if ret != None:
|
|
||||||
is_behind = true
|
|
||||||
|
|
||||||
if is_behind == true:
|
|
||||||
return Env.ret_action_need_updtate
|
|
||||||
|
|
||||||
|
|
@ -55,9 +55,9 @@ public void execute(_arguments):
|
|||||||
Log.error("SYNC Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'", ret_value=Env.ret_action_wrong_parameters)
|
Log.error("SYNC Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'", ret_value=Env.ret_action_wrong_parameters)
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
Log.info("update manifest : '" + str(Env.get_island_path_manifest()) + "'")
|
Log.info("update manifest : '" + str(Env.get_island_path_manifest()) + "'")
|
||||||
is_modify_manifest = commands.check_repository_is_modify(Env.get_island_path_manifest())
|
is_modify_manifest = commands.check_repository_is_modify(Env.get_island_path_manifest())
|
||||||
|
@ -59,9 +59,9 @@ public void execute(_arguments):
|
|||||||
Log.error("SYNC Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
Log.error("SYNC Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
// TODO: Load Old manifect to check diff ...
|
// TODO: Load Old manifect to check diff ...
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public void execute(_arguments):
|
|||||||
Log.info("Add 'volatile' repository: '" + address_git + "' path='" + path + "'")
|
Log.info("Add 'volatile' repository: '" + address_git + "' path='" + path + "'")
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
// Update the current configuration:
|
// Update the current configuration:
|
||||||
conf = config.get_unique_config()
|
conf = config.get_unique_config()
|
||||||
|
@ -40,7 +40,7 @@ public void execute(_arguments):
|
|||||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
conf = config.get_unique_config()
|
conf = config.get_unique_config()
|
||||||
volatiles = conf.get_volatile()
|
volatiles = conf.get_volatile()
|
||||||
|
@ -18,87 +18,6 @@ from island import commands
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
default_behind_message = "[DEV] update dev tag version"
|
|
||||||
default_update_message = "[VERSION] update dev tag version"
|
|
||||||
|
|
||||||
|
|
||||||
base_name_of_a_tagged_branch = "branch_on_tag_"
|
|
||||||
|
|
||||||
public void display_status(elem, argument_remote_name, argument_display_tag, id_element, base_display):
|
|
||||||
volatile = ""
|
|
||||||
if elem.volatile == true:
|
|
||||||
volatile = " (volatile)"
|
|
||||||
Log.verbose("status : " + base_display)
|
|
||||||
//Log.debug("elem : " + str(elem))
|
|
||||||
git_repo_path = new Path(Env.get_island_root_path(), elem.path)
|
|
||||||
if os.path.exists(git_repo_path) == false:
|
|
||||||
Log.info(base_display + volatile + "\r\t\t\t\t\t\t\t\t\t" + " (not download)")
|
|
||||||
return
|
|
||||||
|
|
||||||
is_modify = commands.check_repository_is_modify(git_repo_path)
|
|
||||||
list_branch = commands.get_list_branch_all(git_repo_path)
|
|
||||||
select_branch = commands.get_current_branch(git_repo_path)
|
|
||||||
Log.verbose("List all branch: " + str(list_branch))
|
|
||||||
if select_branch[:len(base_name_of_a_tagged_branch)] != base_name_of_a_tagged_branch:
|
|
||||||
// get tracking branch
|
|
||||||
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, select_branch)
|
|
||||||
if tracking_remote_branch == None:
|
|
||||||
Log.info(base_display + volatile + "\r\t\t\t\t\t\t\t (NO BRANCH)")
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
tracking_remote_branch = select_branch[len(base_name_of_a_tagged_branch):]
|
|
||||||
modify_status = " "
|
|
||||||
if is_modify == true:
|
|
||||||
modify_status = " *** "
|
|
||||||
|
|
||||||
Log.verbose("select branch = '" + select_branch + "' is modify : " + str(is_modify) + " track: '" + str(tracking_remote_branch) + "'")
|
|
||||||
|
|
||||||
ret_current_branch_sha1 = commands.get_revision_list_to_branch(git_repo_path, select_branch)
|
|
||||||
ret_track_branch_sha1 = commands.get_revision_list_to_branch(git_repo_path, tracking_remote_branch)
|
|
||||||
// remove all identical sha1 ==> not needed for this
|
|
||||||
in_forward = 0
|
|
||||||
for elem_sha1 in ret_current_branch_sha1:
|
|
||||||
if elem_sha1 not in ret_track_branch_sha1:
|
|
||||||
in_forward += 1
|
|
||||||
in_behind = 0
|
|
||||||
for elem_sha1 in ret_track_branch_sha1:
|
|
||||||
if elem_sha1 not in ret_current_branch_sha1:
|
|
||||||
in_behind += 1
|
|
||||||
|
|
||||||
behind_forward_comment = ""
|
|
||||||
if in_forward != 0:
|
|
||||||
behind_forward_comment += "forward=" + str(in_forward)
|
|
||||||
if in_behind != 0:
|
|
||||||
if in_forward != 0:
|
|
||||||
behind_forward_comment += " "
|
|
||||||
behind_forward_comment += "behind=" + str(in_behind)
|
|
||||||
if behind_forward_comment != "":
|
|
||||||
behind_forward_comment = "\r\t\t\t\t\t\t\t\t\t\t\t\t[" + behind_forward_comment + "]"
|
|
||||||
|
|
||||||
|
|
||||||
tags_comment = ""
|
|
||||||
// check the current tags of the repository
|
|
||||||
if argument_display_tag == true:
|
|
||||||
ret_current_tags = commands.get_tags_current(git_repo_path)
|
|
||||||
Log.verbose("tags found: " + str(ret_current_tags))
|
|
||||||
for elem_tag in ret_current_tags:
|
|
||||||
if len(tags_comment) != 0:
|
|
||||||
tags_comment += ","
|
|
||||||
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 + "]"
|
|
||||||
else:
|
|
||||||
tags_comment = "\r\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t- - - - -"
|
|
||||||
Log.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"
|
|
||||||
Log.verbose("execute : " + cmd)
|
|
||||||
ret_diff = multiprocess.run_command(cmd, cwd=git_repo_path)
|
|
||||||
tmp_color_red = "\033[31m"
|
|
||||||
tmp_color_default= "\033[00m"
|
|
||||||
Log.info(tmp_color_red + ret_diff[1] + tmp_color_default)
|
|
||||||
return in_behind
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void deliver_check(elem, argument_remote_name, id_element, base_display, source_branch, destination_branch):
|
public void deliver_check(elem, argument_remote_name, id_element, base_display, source_branch, destination_branch):
|
||||||
|
@ -79,23 +79,6 @@ public void get_list_branch_all(path_repository):
|
|||||||
Log.verbose("List all branch: " + str(out))
|
Log.verbose("List all branch: " + str(out))
|
||||||
return out
|
return out
|
||||||
|
|
||||||
public void get_list_branch_local(path_repository):
|
|
||||||
tmp = get_list_branch_meta(path_repository)
|
|
||||||
out = []
|
|
||||||
for elem in tmp:
|
|
||||||
if elem["remote"] == false:
|
|
||||||
out.append(elem["name"])
|
|
||||||
Log.verbose("List local branch: " + str(out))
|
|
||||||
return out
|
|
||||||
|
|
||||||
public void get_list_branch_remote(path_repository):
|
|
||||||
tmp = get_list_branch_meta(path_repository)
|
|
||||||
out = []
|
|
||||||
for elem in tmp:
|
|
||||||
if elem["remote"] == true:
|
|
||||||
out.append(elem["name"])
|
|
||||||
Log.verbose("List remote branch: " + str(out))
|
|
||||||
return out
|
|
||||||
|
|
||||||
public void get_current_branch(path_repository):
|
public void get_current_branch(path_repository):
|
||||||
tmp = get_list_branch_meta(path_repository)
|
tmp = get_list_branch_meta(path_repository)
|
||||||
@ -106,23 +89,7 @@ public void get_current_branch(path_repository):
|
|||||||
Log.verbose("List local branch: None" )
|
Log.verbose("List local branch: None" )
|
||||||
return None
|
return None
|
||||||
|
|
||||||
public void get_current_tracking_branch(path_repository):
|
|
||||||
// get tracking branch
|
|
||||||
cmd = "git rev-parse --abbrev-ref --symbolic-full-name @{u}"
|
|
||||||
Log.verbose("execute : " + cmd)
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
if return_value[1].equals("@{u}":
|
|
||||||
Log.warning("in '" + path_repository + "' no tracking branch is specify")
|
|
||||||
return None
|
|
||||||
multiprocess.generic_display_error(return_value, "get_current_tracking_branch", error_only=true)
|
|
||||||
return return_value[1]
|
|
||||||
|
|
||||||
public void get_revision_list_to_branch(path_repository, branch):
|
|
||||||
cmd = "git rev-list " + branch
|
|
||||||
Log.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)
|
|
||||||
return return_value[1].split('\n')
|
|
||||||
|
|
||||||
public void get_specific_commit_message(path_repository, sha_1):
|
public void get_specific_commit_message(path_repository, sha_1):
|
||||||
if sha_1 == None or sha_1.equals("":
|
if sha_1 == None or sha_1.equals("":
|
||||||
@ -143,23 +110,7 @@ public void get_sha1_for_branch(path_repository, branch_name):
|
|||||||
return return_value[1].split('\n')[0]
|
return return_value[1].split('\n')[0]
|
||||||
|
|
||||||
|
|
||||||
public void get_tags_current(path_repository):
|
|
||||||
cmd = "git tag --points-at"
|
|
||||||
Log.verbose("execute : " + cmd)
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
multiprocess.generic_display_error(return_value, "get_tags_current", error_only=true)
|
|
||||||
list_tags = []
|
|
||||||
for elem in return_value[1].split('\n'):
|
|
||||||
if elem != "":
|
|
||||||
list_tags.append(elem)
|
|
||||||
return list_tags
|
|
||||||
|
|
||||||
public void get_tags(path_repository):
|
|
||||||
cmd = "git tag"
|
|
||||||
Log.verbose("execute : " + cmd)
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
multiprocess.generic_display_error(return_value, "get_tags", error_only=true)
|
|
||||||
return return_value[1].split('\n')
|
|
||||||
|
|
||||||
public void get_tags_remote(path_repository, remote_name):
|
public void get_tags_remote(path_repository, remote_name):
|
||||||
if remote_name.equals("" or remote_name == None:
|
if remote_name.equals("" or remote_name == None:
|
||||||
@ -189,16 +140,6 @@ public void get_tags_remote(path_repository, remote_name):
|
|||||||
out.append(cut[1])
|
out.append(cut[1])
|
||||||
return out
|
return out
|
||||||
|
|
||||||
public void get_tracking_branch(path_repository, remote_name, select_branch):
|
|
||||||
// get tracking branch
|
|
||||||
if remote_name.equals("" or remote_name == None:
|
|
||||||
return get_current_tracking_branch(path_repository)
|
|
||||||
list_branch_remote = get_list_branch_remote(path_repository)
|
|
||||||
Log.extreme_verbose("check if exist " + remote_name + "/" + select_branch + " in " + str(list_branch_remote))
|
|
||||||
if remote_name + "/" + select_branch not in list_branch_remote:
|
|
||||||
Log.debug(" ==> can not get remote branch")
|
|
||||||
return None
|
|
||||||
return remote_name + "/" + select_branch
|
|
||||||
|
|
||||||
|
|
||||||
public void merge_branch_on_master(path_repository, branch_name, merge_force=true, branch_destination = "master"):
|
public void merge_branch_on_master(path_repository, branch_name, merge_force=true, branch_destination = "master"):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user