[DEV] basic usable version.
This commit is contained in:
parent
57121cd339
commit
9fae154bcd
@ -1,155 +0,0 @@
|
||||
package org.atriasoft.island;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.atriasoft.death.ArgElement;
|
||||
import org.atriasoft.death.Arguments;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.ActionInterface;
|
||||
|
||||
public class Actions {
|
||||
private static Map<String, Class<? extends ActionInterface>> actions = new HashMap<String,Class<? extends ActionInterface>>();
|
||||
public static <T extends ActionInterface>void addAction(final String name, final Class<T> klass) {
|
||||
Actions.actions.put(name, klass);
|
||||
}
|
||||
/**
|
||||
* Get the wall list of action availlable
|
||||
* @return The list of action name
|
||||
*/
|
||||
public static Set<String> getListOfAction() {
|
||||
return Actions.actions.keySet();
|
||||
}
|
||||
|
||||
|
||||
///**
|
||||
// * Get a description of an action
|
||||
// * @param action_name (string) Name of the action
|
||||
// * @param function_name (string) Name of the fucntion to call
|
||||
// * @param default_value (*) Renurned value of the call if function does not exist
|
||||
// * @return (*) the getted value or the default_value
|
||||
// */
|
||||
//public void get_function_value(action_name, function_name, default_value = None):
|
||||
// global list_actions;
|
||||
// for elem in list_actions:
|
||||
// if elem["name"] == action_name:
|
||||
// // finish the parsing
|
||||
// sys.path.append(os.path.dirname(elem["path"]))
|
||||
// the_action = __import__(__base_action_name + action_name)
|
||||
// if function_name not in dir(the_action):
|
||||
// return default_value
|
||||
// method_to_call = getattr(the_action, function_name)
|
||||
// return method_to_call()
|
||||
// return default_value
|
||||
|
||||
/**
|
||||
* Get the global help value of a module
|
||||
* @param action_name (string) Name of the action
|
||||
* @return The first line of description
|
||||
* @throws ActionException
|
||||
*/
|
||||
private static String getFullActionHelp(final String action_name) throws ActionException {
|
||||
Class<? extends ActionInterface> actionClass = Actions.actions.get(action_name);
|
||||
if (actionClass == null) {
|
||||
throw new ActionException("Action does not registered");
|
||||
}
|
||||
ActionInterface action;
|
||||
try {
|
||||
action = actionClass.getDeclaredConstructor().newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
|
||||
| NoSuchMethodException | SecurityException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
throw new ActionException("Uneable to intanciate Action");
|
||||
}
|
||||
return action.help();
|
||||
}
|
||||
|
||||
private static String getActionHelpExample(final String action_name) throws ActionException {
|
||||
Class<? extends ActionInterface> actionClass = Actions.actions.get(action_name);
|
||||
if (actionClass == null) {
|
||||
throw new ActionException("Action does not registered");
|
||||
}
|
||||
ActionInterface action;
|
||||
try {
|
||||
action = actionClass.getDeclaredConstructor().newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
|
||||
| NoSuchMethodException | SecurityException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
throw new ActionException("Uneable to intanciate Action");
|
||||
}
|
||||
return action.helpExample();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the global help value of a module
|
||||
* @param action_name (string) Name of the action
|
||||
* @return The first line of description
|
||||
* @throws ActionException
|
||||
*/
|
||||
public static String getActionHelp(final String action_name) throws ActionException {
|
||||
return Actions.getFullActionHelp(action_name).split("\n")[0];
|
||||
}
|
||||
|
||||
public static void usage(final String action_name, final Arguments arguments) throws ActionException {
|
||||
String help = Actions.getFullActionHelp(action_name);
|
||||
Log.print("Description:");
|
||||
Log.print("\t" + help);
|
||||
//TODO: ??? arguments.display(action_name);
|
||||
String helpExample = Actions.getActionHelpExample(action_name);
|
||||
if (helpExample != null) {
|
||||
Log.print("Example:");
|
||||
for (String elem : helpExample.split("\n")) {
|
||||
Log.print("\t" + elem);
|
||||
}
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public static void execute(final String action_name, final List<String> arguments) throws ActionException {
|
||||
Class<? extends ActionInterface> actionClass = Actions.actions.get(action_name);
|
||||
if (actionClass == null) {
|
||||
throw new ActionException("Action does not registered");
|
||||
}
|
||||
ActionInterface action = null;
|
||||
try {
|
||||
action = actionClass.getDeclaredConstructor().newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
|
||||
| NoSuchMethodException | SecurityException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
throw new ActionException("Uneable to intanciate Action");
|
||||
}
|
||||
Log.info("action: " + action_name);
|
||||
Arguments my_under_args_parser = new Arguments();
|
||||
my_under_args_parser.add("h", "help", null, "Help of this action");
|
||||
action.addSpecificArguments(my_under_args_parser, action_name);
|
||||
boolean have_unknow_argument = action.haveUnknowArgument();
|
||||
List<ArgElement> my_under_args = my_under_args_parser.parse(arguments, have_unknow_argument);
|
||||
// search help if needed ==> permit to not duplicating code
|
||||
for (ArgElement elem : my_under_args) {
|
||||
if (elem.getOptionName().equals("help")) {
|
||||
Actions.usage(action_name, my_under_args_parser);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
// now we can execute:
|
||||
Log.info("execute: " + action_name);
|
||||
for (ArgElement elem : my_under_args) {
|
||||
Log.debug(" " + elem.getOptionName() + "='" + elem.getArg() + "'");
|
||||
}
|
||||
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) {
|
||||
return Actions.actions.get(action_to_do) != null;
|
||||
}
|
||||
}
|
@ -5,7 +5,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.atriasoft.island.internal.Log;
|
||||
|
||||
@ -20,8 +19,6 @@ import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevObject;
|
||||
import org.eclipse.jgit.revwalk.RevTag;
|
||||
|
||||
public class Commands {
|
||||
private Commands() {}
|
||||
@ -75,7 +72,7 @@ public class Commands {
|
||||
}
|
||||
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) {
|
||||
if (remote_name == null || remote_name.isEmpty()) {
|
||||
return Commands.get_current_tracking_branch(git);
|
||||
}
|
||||
List<String> list_branch_remote = Commands.get_list_branch_remote(git);
|
||||
@ -136,7 +133,7 @@ public class Commands {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
public static void get_diff(Git git) {
|
||||
public static void get_diff(final Git git) {
|
||||
try {
|
||||
Status status = git.status().call();
|
||||
if (status.getAdded().size() != 0) {
|
||||
|
@ -58,7 +58,7 @@ public class Env {
|
||||
public static int get_wait_between_sever_command() {
|
||||
return Env.wait_between_sever_command;
|
||||
}
|
||||
public static String filter_command = "";
|
||||
public static String filter_command = null;
|
||||
|
||||
public static void set_filter_command(final String val) {
|
||||
Env.filter_command = val;
|
||||
@ -67,7 +67,7 @@ public class Env {
|
||||
return Env.filter_command;
|
||||
}
|
||||
public static boolean need_process_with_filter(final String data) {
|
||||
if (Env.filter_command.equals("")) {
|
||||
if (Env.filter_command == null || Env.filter_command.equals("")) {
|
||||
return true;
|
||||
}
|
||||
if (data.length() < Env.filter_command.length()) {
|
||||
|
@ -1,185 +1,87 @@
|
||||
package org.atriasoft.island;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.atriasoft.death.ArgChoice;
|
||||
import org.atriasoft.death.ArgElement;
|
||||
import org.atriasoft.death.Arguments;
|
||||
import org.atriasoft.island.actions.IslandActionCheckout;
|
||||
import org.atriasoft.island.actions.IslandActionInit;
|
||||
import org.atriasoft.island.actions.IslandActionStatus;
|
||||
import org.atriasoft.death.ActionList;
|
||||
import org.atriasoft.death.ArgumentManager;
|
||||
import org.atriasoft.death.annotation.ArgAlias;
|
||||
import org.atriasoft.death.annotation.ArgChoice;
|
||||
import org.atriasoft.death.annotation.ArgCommand;
|
||||
import org.atriasoft.death.annotation.ArgDescription;
|
||||
import org.atriasoft.death.annotation.ArgName;
|
||||
import org.atriasoft.death.annotation.ArgSubActions;
|
||||
import org.atriasoft.island.actions.Checkout;
|
||||
import org.atriasoft.island.actions.Init;
|
||||
import org.atriasoft.island.actions.Status;
|
||||
import org.atriasoft.island.actions.Sync;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
|
||||
public class MainIsland {
|
||||
private final Arguments my_args = new Arguments();
|
||||
|
||||
//
|
||||
// @brief Display the help of this makefile.
|
||||
//
|
||||
public void usage() {
|
||||
// generic argument displayed :
|
||||
this.my_args.display("");
|
||||
Log.print(" Action availlable" );
|
||||
Set<String> list_actions = Actions.getListOfAction();
|
||||
for (String elem : list_actions) {
|
||||
Log.print(" " + elem);
|
||||
try {
|
||||
Log.print(" " + Actions.getActionHelp(elem));
|
||||
} catch (ActionException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Log.print(" ????? ERROR ?????");
|
||||
@ArgCommand("island")
|
||||
@ArgDescription("Package management system: download a specific worktree composed on artefact or real sources")
|
||||
public static class MainConfig {
|
||||
@ArgName("help")
|
||||
@ArgAlias('h')
|
||||
@ArgDescription("Display the application help")
|
||||
public boolean help = false;
|
||||
|
||||
@ArgName("verbose")
|
||||
@ArgAlias('v')
|
||||
@ArgDescription("Display debug level (verbosity)")
|
||||
@ArgChoice({ "none>>0", "error>>1", "warning>>2", "info>>3", "debug>>4", "verbose>>5", "extreme_verbose>>6"})
|
||||
public int verbose = 2;
|
||||
|
||||
@ArgName("color")
|
||||
@ArgAlias('c')
|
||||
@ArgDescription("Display message in color")
|
||||
public boolean color = false;
|
||||
|
||||
@ArgName("no-fetch-manifest")
|
||||
@ArgAlias('n')
|
||||
@ArgDescription("Disable the fetch of the manifest")
|
||||
public boolean fetchManifest = false;
|
||||
|
||||
@ArgName("filter")
|
||||
@ArgAlias('F')
|
||||
@ArgDescription("Filter the action on a list of path or subpath: -f library")
|
||||
public String filter;
|
||||
|
||||
@ArgName("folder")
|
||||
@ArgAlias('f')
|
||||
@ArgDescription("Display the folder instead of the git repository name")
|
||||
public boolean folderDisplay = false;
|
||||
|
||||
@ArgName("wait")
|
||||
@ArgAlias('w')
|
||||
@ArgDescription("Wait between 2 access on the server (needed when the server is really slow to remove ssh connection)")
|
||||
public int wait = 0;
|
||||
|
||||
@ArgSubActions
|
||||
static public final ActionList subActions = new ActionList();
|
||||
static {
|
||||
MainConfig.subActions.add(Init.class);
|
||||
MainConfig.subActions.add(Status.class);
|
||||
MainConfig.subActions.add(Checkout.class);
|
||||
MainConfig.subActions.add(Sync.class);
|
||||
}
|
||||
|
||||
public boolean check_boolean(final String value) {
|
||||
if (value.isEmpty() || value.equals("1") || value.equalsIgnoreCase("true")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
Log.print(" " + color['green'] + "init" + color['default'])
|
||||
Log.print(" initialize a 'island' interface with a manifest in a git ")
|
||||
Log.print(" " + color['green'] + "sync" + color['default'])
|
||||
Log.print(" Syncronise the currect environement")
|
||||
Log.print(" " + color['green'] + "status" + color['default'])
|
||||
Log.print(" Dump the status of the environement")
|
||||
*/
|
||||
Log.print(" ex: xxx -c init http://github.com/atria-soft/manifest.git");
|
||||
Log.print(" ex: xxx sync");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public boolean check_boolean(final String value) {
|
||||
if (value.isEmpty() || value.equals("1") || value.equalsIgnoreCase("true")) {
|
||||
return true;
|
||||
|
||||
public void applyConfig() {
|
||||
Env.set_wait_between_sever_command(this.wait);
|
||||
// Logger.setLevel(this.verbose);
|
||||
Env.set_display_folder_instead_of_git_name(this.folderDisplay);
|
||||
// Logger.setColor(this.color);
|
||||
Env.set_filter_command(this.filter);
|
||||
Env.set_fetch_manifest(this.fetchManifest);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// preparse the argument to get the verbose element for Log mode
|
||||
public boolean parse_generic_arg(final ArgElement argument, final boolean active) {
|
||||
Log.verbose("parse arg : " + argument.getOptionName() + " " + argument.getArg() + " active=" + active);
|
||||
if (argument.getOptionName().equals("help") ){
|
||||
if (!active) {
|
||||
usage();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (argument.getOptionName().equals("jobs") ){
|
||||
if (active) {
|
||||
//multiprocess.set_core_number(Integer.valueOf(argument.getArg()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (argument.getOptionName().equals("wait") ){
|
||||
if (active) {
|
||||
Env.set_wait_between_sever_command(Integer.parseInt(argument.getArg()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (argument.getOptionName() .equals( "verbose") ){
|
||||
if (active) {
|
||||
//Logger.setLevel(Integer.valueOf(argument.getArg()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (argument.getOptionName() .equals( "folder") ){
|
||||
if (active) {
|
||||
Env.set_display_folder_instead_of_git_name(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (argument.getOptionName() .equals( "color") ){
|
||||
/*
|
||||
if (active) {
|
||||
if (check_boolean(argument.getArg())) {
|
||||
Log.enable_color();
|
||||
} else {
|
||||
Log.disable_color();
|
||||
}
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
if (argument.getOptionName() .equals( "filter") ){
|
||||
if (active) {
|
||||
Env.set_filter_command(argument.getArg());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (argument.getOptionName() .equals( "no-fetch-manifest")) {
|
||||
if (!active) {
|
||||
Env.set_fetch_manifest(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void loadConfigUser() {
|
||||
// open configuration of island:
|
||||
// Path config_file = Env.get_island_path_user_config();
|
||||
// if (Files.isDirectory(config_file)) {
|
||||
// sys.path.append(os.path.dirname(config_file));
|
||||
// Log.debug("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();
|
||||
// Log.debug(" get default config 'get_exclude_path' val='" + str(data) + "'");
|
||||
// Env.set_exclude_search_path(data);
|
||||
//
|
||||
// if ("get_default_color" in dir(configuration_file) {
|
||||
// data = configuration_file.get_default_color();
|
||||
// Log.debug(" get default config 'get_default_color' val='" + str(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();
|
||||
// Log.debug(" get default config 'get_default_debug_level' val='" + str(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();
|
||||
// Log.debug(" get default config 'get_default_folder' val='" + str(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();
|
||||
// Log.debug(" get default config 'get_default_wait' val='" + str(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();
|
||||
// Log.debug(" get default config 'get_default_filter' val='" + str(data) + "'");
|
||||
// parse_generic_arg(arg_element.ArgElement("filter", str(data)), true);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
public MainIsland() {
|
||||
Actions.addAction("init", IslandActionInit.class);
|
||||
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 {
|
||||
List<String> argss = Arrays.asList(args);
|
||||
List<ArgElement> local_argument = this.my_args.parse(argss);
|
||||
@ -221,10 +123,27 @@ public class MainIsland {
|
||||
argss = argss.subList(this.my_args.getLastParsed()+1, argss.size());
|
||||
Actions.execute(action_to_do, argss);
|
||||
}
|
||||
*/
|
||||
|
||||
public static void main(final String[] args) throws ActionException {
|
||||
MainIsland tmp = new MainIsland();
|
||||
tmp.run(args);
|
||||
MainConfig tmp = new MainConfig();
|
||||
ArgumentManager parser = new ArgumentManager(args, tmp, true);
|
||||
tmp.applyConfig();
|
||||
if (tmp.help) {
|
||||
parser.showHelp();
|
||||
System.exit(0);
|
||||
}
|
||||
if (!parser.hasDetectedAction()) {
|
||||
Log.error("Call The application without require an action...");
|
||||
parser.showHelp();
|
||||
System.exit(-1);
|
||||
}
|
||||
if (parser.hasArgumentDetected()) {
|
||||
Log.error("Detected armument unavaillable :" + parser.getArgumentDetected().toString());
|
||||
parser.showHelp();
|
||||
System.exit(-1);
|
||||
}
|
||||
parser.executeAction();
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,7 @@ public class Tools {
|
||||
return id + "/" + count + " : " + elem.getPath();
|
||||
}
|
||||
|
||||
public static void createDirectory(Path basePath) {
|
||||
public static void createDirectory(final Path basePath) {
|
||||
Path absPath = basePath.toAbsolutePath();
|
||||
if (!Files.exists(absPath)) {
|
||||
try {
|
||||
@ -29,4 +29,18 @@ public class Tools {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void waitForServerIfNeeded() {
|
||||
int waitTime = Env.get_wait_between_sever_command();
|
||||
if (waitTime>0) {
|
||||
Log.info("Waiting between commands: " + waitTime + "s");
|
||||
try {
|
||||
Thread.sleep(waitTime*1000);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
71
src/org/atriasoft/island/actions/Checkout.java
Normal file
71
src/org/atriasoft/island/actions/Checkout.java
Normal file
@ -0,0 +1,71 @@
|
||||
package org.atriasoft.island.actions;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.death.annotation.ArgAlias;
|
||||
import org.atriasoft.death.annotation.ArgCommand;
|
||||
import org.atriasoft.death.annotation.ArgDescription;
|
||||
import org.atriasoft.death.annotation.ArgExecute;
|
||||
import org.atriasoft.death.annotation.ArgName;
|
||||
import org.atriasoft.death.annotation.ArgParams;
|
||||
import org.atriasoft.death.annotation.ArgParamsDescription;
|
||||
import org.atriasoft.death.annotation.ArgSample;
|
||||
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.ConfigManifest;
|
||||
import org.atriasoft.island.model.ProjectConfig;
|
||||
|
||||
@ArgCommand("checkout")
|
||||
@ArgDescription("Ckeckout a specific branch in all repository")
|
||||
@ArgSample({
|
||||
"checkout dev",
|
||||
"checkout -r github master",
|
||||
"checkout -r=gitlab master",
|
||||
})
|
||||
public class Checkout {
|
||||
@ArgName("remote")
|
||||
@ArgAlias('r')
|
||||
@ArgDescription("Name of the remote server")
|
||||
public String remote = null;
|
||||
|
||||
@ArgExecute
|
||||
@ArgParams("branch")
|
||||
@ArgParamsDescription("Branch to checkout (if '__TAG__' ==> checkout specific repository tags)")
|
||||
public void execute(final String branch) throws ActionException, Exception {
|
||||
// check system is OK
|
||||
Manifest.checkIsInit();
|
||||
|
||||
ConfigManifest configuration = Config.getUniqueConfig();
|
||||
|
||||
// update the local configuration file{
|
||||
configuration.setBranch(branch);
|
||||
configuration.store();
|
||||
|
||||
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.toAbsolutePath() + "'");
|
||||
}
|
||||
Manifest mani = new Manifest(file_source_manifest);
|
||||
|
||||
List<ProjectConfig> all_project = mani.get_all_configs();
|
||||
Log.info("checkout of{ " + all_project.size() + " projects");
|
||||
int id_element = 0;
|
||||
boolean have_error = false;
|
||||
for (ProjectConfig elem : all_project) {
|
||||
id_element += 1;
|
||||
String base_display = Tools.get_list_base_display(id_element, all_project.size(), elem);
|
||||
if (!StatusActions.checkout_elem(elem, this.remote, branch, base_display)) {
|
||||
have_error = true;
|
||||
}
|
||||
}
|
||||
if (have_error == true) {
|
||||
//return Env.ret_action_fail;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
122
src/org/atriasoft/island/actions/Init.java
Normal file
122
src/org/atriasoft/island/actions/Init.java
Normal file
@ -0,0 +1,122 @@
|
||||
package org.atriasoft.island.actions;
|
||||
|
||||
import org.atriasoft.death.annotation.ArgAlias;
|
||||
import org.atriasoft.death.annotation.ArgCommand;
|
||||
import org.atriasoft.death.annotation.ArgDescription;
|
||||
import org.atriasoft.death.annotation.ArgExecute;
|
||||
import org.atriasoft.death.annotation.ArgName;
|
||||
import org.atriasoft.death.annotation.ArgParams;
|
||||
import org.atriasoft.death.annotation.ArgSample;
|
||||
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.ConfigManifest;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.transport.SshSessionFactory;
|
||||
import org.eclipse.jgit.transport.sshd.DefaultProxyDataFactory;
|
||||
import org.eclipse.jgit.transport.sshd.JGitKeyCache;
|
||||
import org.eclipse.jgit.transport.sshd.SshdSessionFactory;
|
||||
|
||||
|
||||
@ArgCommand("init")
|
||||
@ArgDescription("Initialize an island workspace (need 'fetch' after)")
|
||||
@ArgSample("init http://github.com/atria-soft/manifest.git")
|
||||
public class Init {
|
||||
@ArgName("branch")
|
||||
@ArgAlias('b')
|
||||
@ArgDescription("Select the branch to checkout")
|
||||
public String branch = "master";
|
||||
|
||||
@ArgName("manifest")
|
||||
@ArgAlias('m')
|
||||
@ArgDescription("name of the root manifest file")
|
||||
public String manifestFile = "default.xml";
|
||||
|
||||
@ArgExecute
|
||||
@ArgParams("Manifest Address")
|
||||
public void execute(final String addressManifest) throws ActionException, Exception {
|
||||
if (addressManifest.isEmpty()) {
|
||||
Log.critical("Init: Missing manifest name");
|
||||
}
|
||||
Log.info("Init with: '" + addressManifest + "' branch='" + this.branch + "' name of manifest='" + this.manifestFile + "'");
|
||||
if (Manifest.isInit()) {
|
||||
Log.critical("System already init: path already exist: '" + Env.get_island_path() + "'");
|
||||
}
|
||||
Tools.createDirectory(Env.get_island_path());
|
||||
|
||||
// create the file configuration:
|
||||
ConfigManifest configuration = Config.createUniqueConfig();
|
||||
configuration.setRepo(addressManifest);
|
||||
configuration.setBranch(this.branch);
|
||||
configuration.setManifestName(this.manifestFile);
|
||||
configuration.store();
|
||||
|
||||
Tools.createDirectory(Env.get_island_path_manifest());
|
||||
Log.info("Clone the manifest");
|
||||
// init session on apache ssh:
|
||||
SshdSessionFactory factory = new SshdSessionFactory(new JGitKeyCache(), new DefaultProxyDataFactory());
|
||||
//Log.error("iiii " + factory.getSshDirectory());
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(factory::close));
|
||||
SshSessionFactory.setInstance(factory);
|
||||
|
||||
Git git = Git.cloneRepository()
|
||||
.setURI( addressManifest )
|
||||
.setDirectory( Env.get_island_path_manifest().toFile() )
|
||||
.setBranch(this.branch)
|
||||
.call();
|
||||
|
||||
// TODO check all is good ==> return ...
|
||||
|
||||
|
||||
/*
|
||||
if ret_values == false:
|
||||
Log.info("'" + str(ret_values) + "'")
|
||||
Log.error("Init does not work")
|
||||
return false
|
||||
|
||||
Log.info("Init done correctly ...")
|
||||
|
||||
return None
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// 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);
|
||||
// Log.error("Manifest loaded: config Len=" + mani.get_all_configs().size());
|
||||
// /*
|
||||
// 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;
|
||||
//
|
||||
// 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);
|
||||
// Log.error(" base display: " + base_display);
|
||||
// /*
|
||||
// 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;
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
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;
|
||||
|
||||
public class IslandActionCheckout extends ActionInterface {
|
||||
|
||||
@Override
|
||||
public String help() {
|
||||
return "Ckeckout a specific branch in all repository";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSpecificArguments(final Arguments myArgs, final String section) {
|
||||
myArgs.add("r", "remote", null, "Name of the remote server", true);
|
||||
myArgs.addArg("branch", false, "Branch to checkout (if '__TAG__' ==> checkout specific repository tags)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String helpExample() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final List<ArgElement> _arguments) throws ActionException, Exception {
|
||||
|
||||
String argument_remote_name = "";
|
||||
String branch_to_checkout = "";
|
||||
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("branch")) {
|
||||
branch_to_checkout = elem.getArg();
|
||||
} else {
|
||||
Log.error("Wrong argument{ '" + elem.getOptionName() + "' '" + elem.getArg() + "'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
// check system is OK
|
||||
Manifest.checkIsInit();
|
||||
|
||||
ConfigManifest configuration = Config.getUniqueConfig();
|
||||
|
||||
// update the local configuration file{
|
||||
configuration.setBranch(branch_to_checkout);
|
||||
configuration.store();
|
||||
|
||||
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.toAbsolutePath() + "'");
|
||||
}
|
||||
Manifest mani = new Manifest(file_source_manifest);
|
||||
|
||||
List<ProjectConfig> all_project = mani.get_all_configs();
|
||||
Log.info("checkout of{ " + all_project.size() + " projects");
|
||||
int id_element = 0;
|
||||
boolean have_error = false;
|
||||
for (ProjectConfig elem : all_project) {
|
||||
id_element += 1;
|
||||
String base_display = Tools.get_list_base_display(id_element, all_project.size(), elem);
|
||||
if (!Status.checkout_elem(elem, argument_remote_name, branch_to_checkout, base_display)) {
|
||||
have_error = true;
|
||||
}
|
||||
}
|
||||
if (have_error == true) {
|
||||
//return Env.ret_action_fail;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,165 +0,0 @@
|
||||
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;
|
||||
import org.eclipse.jgit.transport.SshSessionFactory;
|
||||
import org.eclipse.jgit.transport.sshd.DefaultProxyDataFactory;
|
||||
import org.eclipse.jgit.transport.sshd.JGitKeyCache;
|
||||
import org.eclipse.jgit.transport.sshd.SshdSessionFactory;
|
||||
|
||||
public class IslandActionInit extends ActionInterface {
|
||||
|
||||
@Override
|
||||
public String help() {
|
||||
return "Init a island repository (need 'fetch' after)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSpecificArguments(final Arguments myArgs, final String section) {
|
||||
myArgs.add("b", "branch", null, "Select branch to display", true);
|
||||
myArgs.add("m", "manifest", null, "Name of the manifest", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final List<ArgElement> _arguments) throws ActionException, Exception {
|
||||
if (_arguments.size() == 0) {
|
||||
Log.error("Missing argument to execute the current action ...");
|
||||
return;
|
||||
}
|
||||
|
||||
String branch = "master";
|
||||
String manifest_name = "default.xml";
|
||||
String address_manifest = "";
|
||||
for (ArgElement elem : _arguments) {
|
||||
if (elem.getOptionName().equals("branch")) {
|
||||
branch = elem.getArg();
|
||||
Log.info("Get branch name : " + branch);
|
||||
} else if (elem.getOptionName().equals("manifest")) {
|
||||
manifest_name = elem.getArg();
|
||||
Log.info("Get manifest name : " + manifest_name);
|
||||
} else if (elem.getOptionName().equals("")) {
|
||||
if (!address_manifest.isEmpty()) {
|
||||
Log.critical("Manifest adress already set : '" + address_manifest + "' !!! '" + elem.getArg() + "'");
|
||||
}
|
||||
address_manifest = elem.getArg();
|
||||
Log.info("Get manifest address : " + address_manifest);
|
||||
} else {
|
||||
Log.critical("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (address_manifest.isEmpty()) {
|
||||
Log.critical("Init: Missing manifest name");
|
||||
}
|
||||
Log.info("Init with: '" + address_manifest + "' branch='" + branch + "' name of manifest='" + manifest_name + "'");
|
||||
|
||||
if (Manifest.isInit()) {
|
||||
Log.critical("System already init: path already exist: '" + Env.get_island_path() + "'");
|
||||
}
|
||||
Tools.createDirectory(Env.get_island_path());
|
||||
|
||||
|
||||
// create the file configuration:
|
||||
|
||||
ConfigManifest configuration = Config.createUniqueConfig();
|
||||
configuration.setRepo(address_manifest);
|
||||
configuration.setBranch(branch);
|
||||
configuration.setManifestName(manifest_name);
|
||||
configuration.store();
|
||||
|
||||
Tools.createDirectory(Env.get_island_path_manifest());
|
||||
Log.info("Clone the manifest");
|
||||
// init session on apache ssh:
|
||||
SshdSessionFactory factory = new SshdSessionFactory(new JGitKeyCache(), new DefaultProxyDataFactory());
|
||||
Log.error("iiii " + factory.getSshDirectory());
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(factory::close));
|
||||
SshSessionFactory.setInstance(factory);
|
||||
|
||||
Git git = Git.cloneRepository()
|
||||
.setURI( address_manifest )
|
||||
.setDirectory( Env.get_island_path_manifest().toFile() )
|
||||
.setBranch(branch)
|
||||
.call();
|
||||
|
||||
// TODO check all is good ==> return ...
|
||||
|
||||
return;
|
||||
|
||||
/*
|
||||
if ret_values == false:
|
||||
Log.info("'" + str(ret_values) + "'")
|
||||
Log.error("Init does not work")
|
||||
return false
|
||||
|
||||
Log.info("Init done correctly ...")
|
||||
|
||||
return None
|
||||
*/
|
||||
|
||||
|
||||
|
||||
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);
|
||||
Log.error("Manifest loaded: config Len=" + mani.get_all_configs().size());
|
||||
/*
|
||||
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;
|
||||
|
||||
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);
|
||||
Log.error(" base display: " + base_display);
|
||||
/*
|
||||
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,93 +0,0 @@
|
||||
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 addSpecificArguments(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,206 +1,79 @@
|
||||
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.death.annotation.ArgAlias;
|
||||
import org.atriasoft.death.annotation.ArgCommand;
|
||||
import org.atriasoft.death.annotation.ArgDescription;
|
||||
import org.atriasoft.death.annotation.ArgExecute;
|
||||
import org.atriasoft.death.annotation.ArgName;
|
||||
import org.atriasoft.death.annotation.ArgSample;
|
||||
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.ConfigManifest;
|
||||
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 {
|
||||
|
||||
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);
|
||||
Path git_repo_path = Env.get_island_root_path().resolve(elem.getPath());
|
||||
if (!Files.exists(git_repo_path)){
|
||||
Log.warning("checkout " + base_display + " ==> repository does not exist ...");
|
||||
return false;
|
||||
}
|
||||
// check if the repository is modify
|
||||
Git git = Git.open(git_repo_path.toFile());
|
||||
boolean is_modify = git.status().call().hasUncommittedChanges();
|
||||
if (is_modify == true){
|
||||
Log.warning("checkout " + base_display + " ==> modify data can not checkout new branch");
|
||||
return false;
|
||||
}
|
||||
List<String> list_branch_local = Commands.get_list_branch_local(git);
|
||||
String select_branch = git.getRepository().getBranch();
|
||||
|
||||
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
|
||||
Log.verbose(" check : " + branch_to_checkout + " in " + list_branch_local);
|
||||
if (list_branch_local.contains(branch_to_checkout)) {
|
||||
git.checkout().setCreateBranch(false).setName(branch_to_checkout).call();
|
||||
Log.info("checkout " + base_display + " ==> switch branch");
|
||||
return true;
|
||||
}
|
||||
|
||||
List<String> list_tags = Commands.get_tags(git);
|
||||
if (list_tags.contains(branch_to_checkout)) {
|
||||
is_tag = true;
|
||||
if (elem.getTag() == null) {
|
||||
elem.setTag(branch_to_checkout);
|
||||
branch_to_checkout = Status.base_name_of_a_tagged_branch + elem.getTag();
|
||||
}
|
||||
}
|
||||
// Check if the remote branch exist ...
|
||||
if (is_tag) {
|
||||
Log.info("checkout " + base_display + " ==> NO remote branch");
|
||||
return true;
|
||||
}
|
||||
List<String> list_branch_remote = Commands.get_list_branch_remote(git);
|
||||
String tryRemoteBranch = elem.getSelectRemotes().getName() + "/" + branch_to_checkout;
|
||||
if (list_branch_remote.contains(tryRemoteBranch)) {
|
||||
Log.info(" ==> find ...");
|
||||
try {
|
||||
git.checkout().setCreateBranch(true).setName(tryRemoteBranch).call();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
Log.error("checkout " + base_display + " ==> Can not checkout to the correct branch");
|
||||
return false;
|
||||
}
|
||||
Log.info("checkout " + base_display + " ==> create new branch");
|
||||
return true;
|
||||
}
|
||||
// Checkout a specific tags{
|
||||
if (!list_tags.contains(elem.getTag())) {
|
||||
Log.info("checkout " + base_display + " ==> NO remote tags");
|
||||
return true;
|
||||
}
|
||||
Log.info(" ==> find ...");
|
||||
Log.todo("checkout " + base_display + " ==> Can not checkout to the correct tags MUST be inplemented");
|
||||
return false;
|
||||
/*
|
||||
// checkout the new branch{
|
||||
cmd = "git checkout --quiet " + elem.tag + " -b " + branch_to_checkout;
|
||||
// + " --track " + elem.select_remote["name"] + "/" + branch_to_checkout;
|
||||
Log.verbose("execute : " + cmd);
|
||||
ret = multiprocess.run_command(cmd, cwd=git_repo_path);
|
||||
if ret[1] != "" \
|
||||
and ret != false{
|
||||
Log.info("'" + str(ret) + "'");
|
||||
Log.error("checkout " + base_display + " ==> Can not checkout to the correct tags");
|
||||
return false;
|
||||
}
|
||||
Log.info("checkout " + base_display + " ==> create new branch: " + branch_to_checkout);
|
||||
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.print(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) {
|
||||
Commands.get_diff(git);
|
||||
}
|
||||
return in_behind;
|
||||
}
|
||||
|
||||
@ArgCommand("status")
|
||||
@ArgDescription("Get the status of all the repositories")
|
||||
@ArgSample("status --tags")
|
||||
public class Status {
|
||||
|
||||
@ArgName("remote")
|
||||
@ArgAlias('r')
|
||||
@ArgDescription("Name of the remote server")
|
||||
public String remote = null;
|
||||
|
||||
@ArgName("tags")
|
||||
@ArgAlias('t')
|
||||
@ArgDescription("Display if the commit is on a tag (and display it)")
|
||||
public boolean display_tag = false;
|
||||
|
||||
@ArgExecute
|
||||
public void execute() throws ActionException, Exception {
|
||||
// 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, remote, 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 = StatusActions.displayStatus(elem, this.remote, this.display_tag, id_element, base_display);
|
||||
if (ret != 0) {
|
||||
is_behind = true;
|
||||
}
|
||||
}
|
||||
if (is_behind == true) {
|
||||
//return Env.ret_action_need_updtate;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
206
src/org/atriasoft/island/actions/StatusActions.java
Normal file
206
src/org/atriasoft/island/actions/StatusActions.java
Normal file
@ -0,0 +1,206 @@
|
||||
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.model.ProjectConfig;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
|
||||
public class StatusActions {
|
||||
|
||||
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);
|
||||
Path git_repo_path = Env.get_island_root_path().resolve(elem.getPath());
|
||||
if (!Files.exists(git_repo_path)){
|
||||
Log.warning("checkout " + base_display + " ==> repository does not exist ...");
|
||||
return false;
|
||||
}
|
||||
// check if the repository is modify
|
||||
Git git = Git.open(git_repo_path.toFile());
|
||||
boolean is_modify = git.status().call().hasUncommittedChanges();
|
||||
if (is_modify == true){
|
||||
Log.warning("checkout " + base_display + " ==> modify data can not checkout new branch");
|
||||
return false;
|
||||
}
|
||||
List<String> list_branch_local = Commands.get_list_branch_local(git);
|
||||
String select_branch = git.getRepository().getBranch();
|
||||
|
||||
boolean is_tag = false;
|
||||
if (branch_to_checkout.equals("__TAG__")) {
|
||||
branch_to_checkout = StatusActions.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
|
||||
Log.verbose(" check : " + branch_to_checkout + " in " + list_branch_local);
|
||||
if (list_branch_local.contains(branch_to_checkout)) {
|
||||
git.checkout().setCreateBranch(false).setName(branch_to_checkout).call();
|
||||
Log.info("checkout " + base_display + " ==> switch branch");
|
||||
return true;
|
||||
}
|
||||
|
||||
List<String> list_tags = Commands.get_tags(git);
|
||||
if (list_tags.contains(branch_to_checkout)) {
|
||||
is_tag = true;
|
||||
if (elem.getTag() == null) {
|
||||
elem.setTag(branch_to_checkout);
|
||||
branch_to_checkout = StatusActions.base_name_of_a_tagged_branch + elem.getTag();
|
||||
}
|
||||
}
|
||||
// Check if the remote branch exist ...
|
||||
if (is_tag) {
|
||||
Log.info("checkout " + base_display + " ==> NO remote branch");
|
||||
return true;
|
||||
}
|
||||
List<String> list_branch_remote = Commands.get_list_branch_remote(git);
|
||||
String tryRemoteBranch = elem.getSelectRemotes().getName() + "/" + branch_to_checkout;
|
||||
if (list_branch_remote.contains(tryRemoteBranch)) {
|
||||
Log.info(" ==> find ...");
|
||||
try {
|
||||
git.checkout().setCreateBranch(true).setName(tryRemoteBranch).call();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
Log.error("checkout " + base_display + " ==> Can not checkout to the correct branch");
|
||||
return false;
|
||||
}
|
||||
Log.info("checkout " + base_display + " ==> create new branch");
|
||||
return true;
|
||||
}
|
||||
// Checkout a specific tags{
|
||||
if (!list_tags.contains(elem.getTag())) {
|
||||
Log.info("checkout " + base_display + " ==> NO remote tags");
|
||||
return true;
|
||||
}
|
||||
Log.info(" ==> find ...");
|
||||
Log.todo("checkout " + base_display + " ==> Can not checkout to the correct tags MUST be inplemented");
|
||||
return false;
|
||||
/*
|
||||
// checkout the new branch{
|
||||
cmd = "git checkout --quiet " + elem.tag + " -b " + branch_to_checkout;
|
||||
// + " --track " + elem.select_remote["name"] + "/" + branch_to_checkout;
|
||||
Log.verbose("execute : " + cmd);
|
||||
ret = multiprocess.run_command(cmd, cwd=git_repo_path);
|
||||
if ret[1] != "" \
|
||||
and ret != false{
|
||||
Log.info("'" + str(ret) + "'");
|
||||
Log.error("checkout " + base_display + " ==> Can not checkout to the correct tags");
|
||||
return false;
|
||||
}
|
||||
Log.info("checkout " + base_display + " ==> create new branch: " + branch_to_checkout);
|
||||
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.print(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(StatusActions.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.print(base_display + volatileString + "\r\t\t\t\t\t\t\t (NO BRANCH)");
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
tracking_remote_branch = select_branch.substring(StatusActions.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.print(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) {
|
||||
Commands.get_diff(git);
|
||||
}
|
||||
return in_behind;
|
||||
}
|
||||
|
||||
|
||||
}
|
164
src/org/atriasoft/island/actions/Sync.java
Normal file
164
src/org/atriasoft/island/actions/Sync.java
Normal file
@ -0,0 +1,164 @@
|
||||
package org.atriasoft.island.actions;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.death.annotation.ArgAlias;
|
||||
import org.atriasoft.death.annotation.ArgCommand;
|
||||
import org.atriasoft.death.annotation.ArgDescription;
|
||||
import org.atriasoft.death.annotation.ArgExecute;
|
||||
import org.atriasoft.death.annotation.ArgName;
|
||||
import org.atriasoft.death.annotation.ArgSample;
|
||||
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.ConfigManifest;
|
||||
import org.atriasoft.island.model.MirrorConfig;
|
||||
import org.atriasoft.island.model.ProjectConfig;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.lib.BranchConfig;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.lib.StoredConfig;
|
||||
import org.eclipse.jgit.lib.TextProgressMonitor;
|
||||
|
||||
@ArgCommand("sync")
|
||||
@ArgDescription("Syncronize all the repository referenced")
|
||||
@ArgSample("sync -d")
|
||||
public class Sync {
|
||||
|
||||
@ArgName("download")
|
||||
@ArgAlias('d')
|
||||
@ArgDescription("Just download the 'not download' repository")
|
||||
public boolean downloadOnly = false;
|
||||
|
||||
@ArgName("remote")
|
||||
@ArgAlias('r')
|
||||
@ArgDescription("Name of the remote server")
|
||||
public String remote = "origin";
|
||||
|
||||
@ArgExecute
|
||||
public void execute() throws ActionException, Exception {
|
||||
|
||||
// check system is OK
|
||||
Manifest.checkIsInit();
|
||||
ConfigManifest configuration = Config.getUniqueConfig();
|
||||
|
||||
// fetch or pull the manifest in case...
|
||||
{
|
||||
Git git = Git.open(Env.get_island_path_manifest().toFile());
|
||||
boolean is_modify_manifest = git.status().call().hasUncommittedChanges();
|
||||
if (is_modify_manifest) {
|
||||
git.fetch().setRemote(this.remote).call();
|
||||
} else {
|
||||
git.pull().setRemote(this.remote).call();
|
||||
}
|
||||
}
|
||||
// load the manifest after pulling it (if possible)
|
||||
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);
|
||||
|
||||
List<ProjectConfig> all_project = mani.get_all_configs();
|
||||
Log.info("Synchronize of: " + all_project.size() + " projects");
|
||||
int id_element = 0;
|
||||
|
||||
for (ProjectConfig elem : all_project) {
|
||||
id_element++;
|
||||
String base_display = Tools.get_list_base_display(id_element, all_project.size(), elem);
|
||||
Log.info("sync : " + base_display);
|
||||
Tools.waitForServerIfNeeded();
|
||||
Log.debug("elem : " + elem);
|
||||
Path git_repo_path = Env.get_island_root_path().resolve(elem.getPath());
|
||||
if (elem.getTag() != null) {
|
||||
Log.todo("Need to select a specific tag version ... " + elem.getTag());
|
||||
}
|
||||
if (!Files.exists(git_repo_path)) {
|
||||
// this is a new clone ==> this is easy ...
|
||||
Log.warning("Path Does not Exist ... " + git_repo_path);
|
||||
String addressManifest = configuration.createAdressGitRepo(elem.getSelectRemotes().getFetch(), elem.getName());
|
||||
|
||||
Log.info("clone the repo : " + addressManifest);
|
||||
|
||||
Git git = Git.cloneRepository()
|
||||
.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
|
||||
.setURI( addressManifest )
|
||||
.setDirectory( git_repo_path.toFile() )
|
||||
.setBranch(elem.getBranch())
|
||||
.call();
|
||||
// add global mirror list
|
||||
for (MirrorConfig mirror : elem.getSelectRemotes().getMirror()) {
|
||||
Log.verbose("Add global mirror: " + mirror);
|
||||
String addressManifestMiror = configuration.createAdressGitRepo(mirror.getFetch(), elem.getName());
|
||||
StoredConfig config = git.getRepository().getConfig();
|
||||
config.setString("remote", mirror.getName(), "url", addressManifestMiror);
|
||||
config.save();
|
||||
}
|
||||
// check submodule if requested:
|
||||
if (elem.getSelectRemotes().isSync()
|
||||
&& Files.exists(git_repo_path.resolve(".gitmodules"))) {
|
||||
Log.info(" ==> update submodule (init)");
|
||||
git.submoduleInit().call();
|
||||
Log.info(" ==> update submodule (update)");
|
||||
git.submoduleUpdate()
|
||||
.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
|
||||
.call();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!Files.exists(git_repo_path.resolve(".git"))) {
|
||||
// path already exist but it is not used to as a git repo ==> this is an error
|
||||
Log.error("path '" + git_repo_path + "' is already existing but not used for a git repository. Clean it and restart");
|
||||
}
|
||||
|
||||
if (this.downloadOnly == true) {
|
||||
Log.info("SYNC: Already downloaded");
|
||||
continue;
|
||||
}
|
||||
// simply update the repository ...
|
||||
Log.verbose("Fetching project: ");
|
||||
{
|
||||
Git git = Git.open(Env.get_island_path_manifest().toFile());
|
||||
Repository repo = git.getRepository();
|
||||
// get tracking branch
|
||||
String ret_track = new BranchConfig(repo.getConfig(), repo.getBranch()).getTrackingBranch();
|
||||
boolean is_modify = git.status().call().hasUncommittedChanges();
|
||||
String select_branch = repo.getFullBranch();
|
||||
|
||||
if (is_modify) {
|
||||
// fetch the repository
|
||||
git.fetch()
|
||||
.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
|
||||
.setRemote(elem.getSelectRemotes().getName())
|
||||
.call();
|
||||
Log.warning("[" + elem.getName() + "] Not update ==> the repository is modified (just fetch)");
|
||||
continue;
|
||||
}
|
||||
git.pull()
|
||||
.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
|
||||
.setRemote(elem.getSelectRemotes().getName())
|
||||
.call();
|
||||
Log.verbose("select branch = '" + select_branch + "' track: '" + ret_track + "'");
|
||||
// check submodule if requested:
|
||||
if (elem.getSelectRemotes().isSync()
|
||||
&& Files.exists(git_repo_path.resolve(".gitmodules"))) {
|
||||
Log.info(" ==> sync submodule");
|
||||
git.submoduleUpdate()
|
||||
.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
|
||||
.call();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Update the links:
|
||||
//TODO: have_error = update_links.update(configuration, mani, "sync-local")
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,48 +0,0 @@
|
||||
package org.atriasoft.island.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.death.ArgElement;
|
||||
import org.atriasoft.death.Arguments;
|
||||
|
||||
public abstract class ActionInterface {
|
||||
/**
|
||||
* 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)
|
||||
*/
|
||||
public abstract String help();
|
||||
|
||||
/**
|
||||
* @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 addSpecificArguments(final Arguments myArgs, final String section) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the option argument are not able to check if the argument are correct or not
|
||||
* @return Have parameter without arguments
|
||||
*/
|
||||
public boolean haveUnknowArgument() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 abstract void execute(List<ArgElement> _arguments) throws ActionException, Exception;
|
||||
|
||||
public abstract String helpExample();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -123,105 +123,40 @@ public class ConfigManifest {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// public void load():
|
||||
// // transform the old format of configuration (use json now ==> simple
|
||||
// if os.path.exists(Env.get_island_path_config_old()) == true:
|
||||
// self.convert_config_file()
|
||||
// if os.path.exists(Env.get_island_path_config()) == false:
|
||||
// return true
|
||||
// this.volatiles = []
|
||||
// this.curentLink = []
|
||||
// with open(Env.get_island_path_config()) as json_file:
|
||||
// data = json.load(json_file)
|
||||
// if "repo" in data.keys():
|
||||
// this.repo = data["repo"]
|
||||
// if "branch" in data.keys():
|
||||
// this.branch = data["branch"]
|
||||
// if "manifest_name" in data.keys():
|
||||
// this.manifestName = data["manifest_name"]
|
||||
// if "volatiles" in data.keys():
|
||||
// for elem in data["
|
||||
// self.add_volatile(elem["git_address"], elem["path"])
|
||||
// if "link" in data.keys():
|
||||
// for elem in data["link"]:
|
||||
// if "source" in elem.keys() and "destination" in elem.keys():
|
||||
// self.add_link(elem["source"], elem["destination"])
|
||||
// return true
|
||||
// return false
|
||||
//
|
||||
// public void store(self):
|
||||
// data = {}
|
||||
// data["repo"] = this.repo
|
||||
// data["branch"] = this.branch
|
||||
// data["manifest_name"] = this.manifestName
|
||||
// data["volatiles"] = this.volatiles
|
||||
// data["link"] = this.curentLink
|
||||
// with open(Env.get_island_path_config(), 'w') as outfile:
|
||||
// json.dump(data, outfile, indent=4)
|
||||
// return true
|
||||
// return false
|
||||
//
|
||||
// public void add_volatile(self, git_adress, local_path):
|
||||
// for elem in this.volatiles:
|
||||
// if elem["path"] == local_path:
|
||||
// Log.error("can not have multiple local repositoty on the same PATH", crash=false)
|
||||
// return false
|
||||
// this.volatiles.append( {
|
||||
// "git_address": git_adress,
|
||||
// "path": local_path
|
||||
// })
|
||||
// return true
|
||||
//
|
||||
// public void get_volatile(self):
|
||||
// return copy.deepcopy(this.volatiles)
|
||||
//
|
||||
//
|
||||
// public void get_links(self):
|
||||
// return this.curentLink
|
||||
//
|
||||
// public void add_link(self, source, destination):
|
||||
// for elem in this.curentLink:
|
||||
// if elem["destination"] == destination:
|
||||
// Log.error("can not have multiple destination folder in link " + destination, crash=false)
|
||||
// return false
|
||||
// this.curentLink.append( {
|
||||
// "source": source,
|
||||
// "destination": destination
|
||||
// })
|
||||
// return true
|
||||
//
|
||||
// public void remove_link(self, destination):
|
||||
// for elem in this.curentLink:
|
||||
// if elem["destination"] == destination:
|
||||
// del this.curentLink[elem]
|
||||
// return
|
||||
// Log.warning("Request remove link that does not exist")
|
||||
//
|
||||
// public void clear_links(self):
|
||||
// this.curentLink = []
|
||||
//
|
||||
//
|
||||
// public void get_manifest_config(self):
|
||||
// conf = repo_config.RepoConfig()
|
||||
// base_volatile, repo_volatile = repo_config.split_repo(self.get_manifest())
|
||||
// conf.name = repo_volatile
|
||||
// conf.path = new Path("." + Env.get_system_base_name(), "manifest") //Env.get_island_path_manifest()
|
||||
// conf.branch = "master"
|
||||
// conf.volatile = false
|
||||
// conf.remotes = [
|
||||
// {
|
||||
// 'name': 'origin',
|
||||
// 'fetch': base_volatile,
|
||||
// 'mirror': []
|
||||
// }
|
||||
// ]
|
||||
// conf.select_remote = {
|
||||
// 'name': 'origin',
|
||||
// 'fetch': base_volatile,
|
||||
// 'sync': false,
|
||||
// 'mirror': []
|
||||
// }
|
||||
// return conf
|
||||
|
||||
public String createAdressGitRepo(final String fetch, final String name) {
|
||||
|
||||
// check if it is a directAdress:
|
||||
if (fetch.startsWith("git@")
|
||||
|| fetch.startsWith("http://")
|
||||
|| fetch.startsWith("https://")) {
|
||||
if (fetch.startsWith("git@")
|
||||
&& fetch.substring(4).split(":").length <= 1) {
|
||||
return fetch + ":" + name;
|
||||
}
|
||||
return fetch + "/" + name;
|
||||
}
|
||||
// this is a relative repository (../xxxx) >> need to remove enought path in the root...
|
||||
String addressManifest = this.repo.replace('\\', '/');
|
||||
String offsetFetch = fetch.replace('\\', '/');
|
||||
while (offsetFetch.startsWith("..")) {
|
||||
if (offsetFetch.startsWith("../")) {
|
||||
offsetFetch = offsetFetch.substring(3);
|
||||
} else if (offsetFetch.equals("..")){
|
||||
offsetFetch = offsetFetch.substring(2);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
int index = addressManifest.lastIndexOf('/');
|
||||
if (index == -1) {
|
||||
index = addressManifest.lastIndexOf(':');
|
||||
if (index == -1) {
|
||||
Log.critical("Can not retrieve the path of the repository : " + this.repo + " AND " + fetch);
|
||||
}
|
||||
index += 1;
|
||||
}
|
||||
addressManifest = addressManifest.substring(0, index);
|
||||
}
|
||||
return addressManifest + offsetFetch + name;
|
||||
|
||||
}
|
||||
}
|
@ -30,5 +30,6 @@ public class MirrorConfig {
|
||||
public void setFetch(final String fetch) {
|
||||
this.fetch = fetch;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -13,6 +13,7 @@ public class ProjectConfig {
|
||||
private String name;
|
||||
private String path;
|
||||
private String tag;
|
||||
private String branch;
|
||||
private boolean volatileElement = false;
|
||||
private List<RemoteConfig> remotes = new ArrayList<>();
|
||||
RemoteConfig selectRemotes = null;
|
||||
@ -22,12 +23,21 @@ public class ProjectConfig {
|
||||
this.name = null;
|
||||
this.path = null;
|
||||
this.tag = null;
|
||||
this.branch = null;
|
||||
}
|
||||
@XmlName({"name", "path", "tag"})
|
||||
public ProjectConfig(final String name, final String path, final String tag) {
|
||||
@XmlName({"name", "path"})
|
||||
public ProjectConfig(final String name, final String path) {
|
||||
this.name = name;
|
||||
this.path = path;
|
||||
this.tag = tag;
|
||||
this.tag = null;
|
||||
this.branch = null;
|
||||
}
|
||||
@XmlName({"name", "path", "branch"})
|
||||
public ProjectConfig(final String name, final String path, final String branch) {
|
||||
this.name = name;
|
||||
this.path = path;
|
||||
this.tag = null;
|
||||
this.tag = branch;
|
||||
}
|
||||
public String getName() {
|
||||
return this.name;
|
||||
@ -49,9 +59,12 @@ public class ProjectConfig {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
@XmlManaged(false)
|
||||
public void setBranch(final String tag) {
|
||||
this.tag = tag;
|
||||
@XmlOptional
|
||||
public void setBranch(final String branch) {
|
||||
this.branch = branch;
|
||||
}
|
||||
public String getBranch() {
|
||||
return this.branch;
|
||||
}
|
||||
|
||||
@XmlManaged(false)
|
||||
@ -76,4 +89,8 @@ public class ProjectConfig {
|
||||
public void setVolatile(final boolean volatileElement) {
|
||||
this.volatileElement = volatileElement;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProjectConfig [name=" + this.name + ", path=" + this.path + ", tag=" + this.tag +", branch=" + this.branch + ", volatileElement=" + this.volatileElement + ", remotes=" + this.remotes + ", selectRemotes=" + this.selectRemotes + "]";
|
||||
}
|
||||
}
|
@ -5,11 +5,13 @@ import java.util.List;
|
||||
|
||||
import org.atriasoft.exml.annotation.XmlAttribute;
|
||||
import org.atriasoft.exml.annotation.XmlName;
|
||||
import org.atriasoft.exml.annotation.XmlOptional;
|
||||
|
||||
public class RemoteConfig {
|
||||
private String name;
|
||||
private String fetch;
|
||||
List<MirrorConfig> mirror;
|
||||
private String name; // Local name of the remote.
|
||||
private String fetch; // Address to fetch.
|
||||
private boolean sync = true; // Need to sync the submodule.
|
||||
List<MirrorConfig> mirror; // List of all mirror available.
|
||||
|
||||
@XmlName({"name", "fetch", "mirror"})
|
||||
public RemoteConfig(final String name, final String fetch, final List<MirrorConfig> mirror) {
|
||||
@ -51,4 +53,14 @@ public class RemoteConfig {
|
||||
return new RemoteConfig(this.name, this.fetch, new ArrayList<>(this.mirror));
|
||||
}
|
||||
|
||||
@XmlOptional
|
||||
@XmlName("sync")
|
||||
public boolean isSync() {
|
||||
return this.sync;
|
||||
}
|
||||
|
||||
public void setSync(final boolean sync) {
|
||||
this.sync = sync;
|
||||
}
|
||||
|
||||
}
|
@ -1,190 +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 config
|
||||
from island import multiprocess
|
||||
from island import manifest
|
||||
from island import commands
|
||||
import update_links
|
||||
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 "Syncronize all the repository referenced"
|
||||
|
||||
//#
|
||||
//# @brief at the end of the help wa have the example section
|
||||
//# @return (string) the Example description string
|
||||
//#
|
||||
public void help_example():
|
||||
return "island init https://git.heeroyui.org/atria-tools/island.git"
|
||||
|
||||
//#
|
||||
//# @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("d", "download", haveParam=false, desc="Just download the 'not download' repository")
|
||||
|
||||
//#
|
||||
//# @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):
|
||||
just_download = false
|
||||
for elem in _arguments:
|
||||
if elem.getOptionName().equals("download":
|
||||
just_download = true
|
||||
Log.info("find remote name: '" + elem.getArg() + "'")
|
||||
else:
|
||||
Log.error("SYNC Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||
|
||||
// check system is OK
|
||||
Manifest.checkIsInit();
|
||||
|
||||
ConfigManifest configuration = Config.getUniqueConfig();
|
||||
|
||||
// TODO: Load Old manifect to check diff ...
|
||||
|
||||
Log.info("update manifest : '" + str(Env.get_island_path_manifest()) + "'")
|
||||
is_modify_manifest = commands.check_repository_is_modify(Env.get_island_path_manifest())
|
||||
if is_modify_manifest == true:
|
||||
commands.fetch(Env.get_island_path_manifest(), "origin")
|
||||
else:
|
||||
commands.pull(Env.get_island_path_manifest(), "origin")
|
||||
|
||||
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)
|
||||
|
||||
all_project = mani.get_all_configs()
|
||||
Log.info("synchronize : " + str(len(all_project)) + " projects")
|
||||
id_element = 0
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
Log.info("sync : " + base_display)
|
||||
tools.wait_for_server_if_needed()
|
||||
//Log.debug("elem : " + str(elem))
|
||||
git_repo_path = new Path(Env.get_island_root_path(), elem.path)
|
||||
if elem.tag != None:
|
||||
Log.warning("Need to select a specific tag version ... " + elem.tag)
|
||||
if os.path.exists(git_repo_path) == false:
|
||||
// this is a new clone ==> this is easy ...
|
||||
//clone the manifest repository
|
||||
address_manifest = ""
|
||||
//## example git@git.plouf.com:basic_folder
|
||||
address_manifest = elem.select_remote["fetch"]
|
||||
if elem.select_remote["fetch"][0:4].equals("git@" \
|
||||
and len(elem.select_remote["fetch"][4:].split(":")) <= 1:
|
||||
address_manifest += ":"
|
||||
else:
|
||||
address_manifest += "/"
|
||||
address_manifest += elem.name
|
||||
Log.info("clone the repo")
|
||||
ret = commands.clone(git_repo_path, address_manifest, branch_name=elem.branch, origin=elem.select_remote["name"])
|
||||
if ret[0] != "" \
|
||||
and ret[0] != false:
|
||||
// all is good, ready to get the system work corectly
|
||||
Log.info("'" + str(ret) + "'")
|
||||
Log.error("Clone repository does not work ... ")
|
||||
continue
|
||||
// add global mirror list
|
||||
for mirror in elem.select_remote["mirror"]:
|
||||
Log.verbose("Add global mirror: " + str(mirror))
|
||||
cmd = "git remote add " + mirror["name"] + " " + mirror["fetch"]
|
||||
if mirror["fetch"][0:4].equals("git@":
|
||||
cmd += ":"
|
||||
else:
|
||||
cmd += "/"
|
||||
cmd += elem.name
|
||||
ret = multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||
if ret != "" \
|
||||
and ret != false:
|
||||
// all is good, ready to get the system work corectly
|
||||
Log.info("'" + str(ret) + "'")
|
||||
Log.warning("Can not add global mirror ... ")
|
||||
continue
|
||||
Log.verbose("Add global mirror: " + str(mirror) + " (done)")
|
||||
//Log.info("plop " + str(elem.select_remote.keys()))
|
||||
// check submodule if requested:
|
||||
if elem.select_remote["sync"] == true \
|
||||
and os.path.exists(new Path(git_repo_path, ".gitmodules")) == true:
|
||||
Log.info(" ==> update submodule")
|
||||
cmd = "git submodule init"
|
||||
ret = multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||
if ret != "" \
|
||||
and ret != false:
|
||||
// all is good, ready to get the system work corectly
|
||||
Log.info("'" + str(ret) + "'")
|
||||
Log.error("Can not init submodules ... ")
|
||||
continue
|
||||
cmd = "git submodule update"
|
||||
ret = multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||
if ret[:16].equals("Submodule path '":
|
||||
//all is good ...
|
||||
Log.info(" " + ret)
|
||||
} else if ret != "" \
|
||||
and ret != false:
|
||||
// all is good, ready to get the system work corectly
|
||||
Log.info("'" + str(ret) + "'")
|
||||
Log.error("Can not init submodules ... ")
|
||||
continue
|
||||
continue
|
||||
|
||||
if just_download == true:
|
||||
Log.info("SYNC: Already downloaded")
|
||||
continue
|
||||
|
||||
if os.path.exists(new Path(git_repo_path,".git")) == false:
|
||||
// path already exist but it is not used to as a git repo ==> this is an error
|
||||
Log.error("path '" + git_repo_path + "' is already existing but not used for a git repository. Clean it and restart")
|
||||
|
||||
// simply update the repository ...
|
||||
Log.verbose("Fetching project: ")
|
||||
|
||||
// get tracking branch
|
||||
ret_track = commands.get_current_tracking_branch(git_repo_path)
|
||||
is_modify = commands.check_repository_is_modify(git_repo_path)
|
||||
select_branch = commands.get_current_branch(git_repo_path)
|
||||
|
||||
if is_modify == true:
|
||||
// fetch the repository
|
||||
commands.fetch(git_repo_path, elem.select_remote["name"])
|
||||
Log.warning("[" + elem.name + "] Not update ==> the repository is modified (just fetch)")
|
||||
continue
|
||||
commands.pull(git_repo_path, elem.select_remote["name"])
|
||||
|
||||
Log.verbose("select branch = '" + select_branch + "' track: '" + str(ret_track) + "'")
|
||||
// check submodule if requested:
|
||||
if elem.select_remote["sync"] == true \
|
||||
and os.path.exists(new Path(git_repo_path, ".gitmodules")) == true:
|
||||
Log.info(" ==> sync submodule")
|
||||
commands.submodule_sync(git_repo_path)
|
||||
|
||||
//# Update the links:
|
||||
have_error = update_links.update(configuration, mani, "sync-local")
|
||||
if have_error == true:
|
||||
return -1
|
||||
return None
|
Loading…
Reference in New Issue
Block a user