Compare commits
3 Commits
1bb1c4638e
...
1351757c48
Author | SHA1 | Date | |
---|---|---|---|
1351757c48 | |||
9148d9242c | |||
5a05e0eb77 |
6
.project
6
.project
@ -11,14 +11,8 @@
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
@ -12,16 +12,16 @@ import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.ActionInterface;
|
||||
|
||||
public class Actions {
|
||||
private static Map<String, Class<ActionInterface>> actions = new HashMap<String,Class<ActionInterface>>();
|
||||
public static void addAction(String name, Class<ActionInterface> klass) {
|
||||
actions.put(name, klass);
|
||||
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.keySet();
|
||||
return Actions.actions.keySet();
|
||||
}
|
||||
|
||||
|
||||
@ -51,8 +51,8 @@ public class Actions {
|
||||
* @return The first line of description
|
||||
* @throws ActionException
|
||||
*/
|
||||
private String getFullActionHelp(String action_name) throws ActionException {
|
||||
Class<ActionInterface> actionClass = actions.get(action_name);
|
||||
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");
|
||||
}
|
||||
@ -68,8 +68,8 @@ public class Actions {
|
||||
return action.help();
|
||||
}
|
||||
|
||||
private String getActionHelpExample(String action_name) throws ActionException {
|
||||
Class<ActionInterface> actionClass = actions.get(action_name);
|
||||
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");
|
||||
}
|
||||
@ -91,16 +91,16 @@ public class Actions {
|
||||
* @return The first line of description
|
||||
* @throws ActionException
|
||||
*/
|
||||
public String getActionHelp(String action_name) throws ActionException {
|
||||
return getFullActionHelp(action_name).split("\n")[0];
|
||||
public static String getActionHelp(final String action_name) throws ActionException {
|
||||
return Actions.getFullActionHelp(action_name).split("\n")[0];
|
||||
}
|
||||
|
||||
public void usage(String action_name, Arguments arguments) throws ActionException {
|
||||
String help = getFullActionHelp(action_name);
|
||||
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 = getActionHelpExample(action_name);
|
||||
String helpExample = Actions.getActionHelpExample(action_name);
|
||||
if (helpExample != null) {
|
||||
Log.print("Example:");
|
||||
for (String elem : helpExample.split("\n")) {
|
||||
@ -110,8 +110,8 @@ public class Actions {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public void execute(String action_name, List<String> arguments) throws ActionException {
|
||||
Class<ActionInterface> actionClass = actions.get(action_name);
|
||||
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");
|
||||
}
|
||||
@ -132,8 +132,8 @@ public class Actions {
|
||||
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() == "help") {
|
||||
usage(action_name, my_under_args_parser);
|
||||
if (elem.getOptionName().equals("help")) {
|
||||
Actions.usage(action_name, my_under_args_parser);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
@ -142,6 +142,14 @@ public class Actions {
|
||||
for (ArgElement elem : my_under_args) {
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import java.nio.file.Paths;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
|
||||
public class Env {
|
||||
|
||||
private Env() {}
|
||||
public static final int ret_manifest_is_not_existing = -5;
|
||||
public static final int ret_action_is_not_existing = -10;
|
||||
public static final int ret_action_executing_system_error = -11;
|
||||
@ -29,51 +29,51 @@ public class Env {
|
||||
|
||||
public static String system_base_name = "island";
|
||||
|
||||
public static void set_system_base_name(String val) {
|
||||
system_base_name = val;
|
||||
public static void set_system_base_name(final String val) {
|
||||
Env.system_base_name = val;
|
||||
}
|
||||
public static String get_system_base_name() {
|
||||
return system_base_name;
|
||||
return Env.system_base_name;
|
||||
}
|
||||
|
||||
public static String get_system_config_name() {
|
||||
return "." + system_base_name + "Config.json";
|
||||
return "." + Env.system_base_name + "Config.json";
|
||||
}
|
||||
|
||||
private static boolean fetch_manifest = true;
|
||||
|
||||
public static void set_fetch_manifest(boolean val) {
|
||||
fetch_manifest = val;
|
||||
public static void set_fetch_manifest(final boolean val) {
|
||||
Env.fetch_manifest = val;
|
||||
}
|
||||
public static boolean get_fetch_manifest() {
|
||||
return fetch_manifest;
|
||||
return Env.fetch_manifest;
|
||||
}
|
||||
|
||||
private static int wait_between_sever_command = 0;
|
||||
|
||||
public static void set_wait_between_sever_command(int val) {
|
||||
wait_between_sever_command = val;
|
||||
public static void set_wait_between_sever_command(final int val) {
|
||||
Env.wait_between_sever_command = val;
|
||||
}
|
||||
|
||||
public static int get_wait_between_sever_command() {
|
||||
return wait_between_sever_command;
|
||||
return Env.wait_between_sever_command;
|
||||
}
|
||||
public static String filter_command = "";
|
||||
|
||||
public static void set_filter_command(String val) {
|
||||
filter_command = val;
|
||||
public static void set_filter_command(final String val) {
|
||||
Env.filter_command = val;
|
||||
}
|
||||
public static String get_filter_command() {
|
||||
return filter_command;
|
||||
return Env.filter_command;
|
||||
}
|
||||
public static boolean need_process_with_filter(String data) {
|
||||
if (filter_command.equals("")) {
|
||||
public static boolean need_process_with_filter(final String data) {
|
||||
if (Env.filter_command.equals("")) {
|
||||
return true;
|
||||
}
|
||||
if (data.length() < filter_command.length()) {
|
||||
if (data.length() < Env.filter_command.length()) {
|
||||
return false;
|
||||
}
|
||||
if (data.substring(0,filter_command.length()).equals(filter_command)) {
|
||||
if (data.substring(0,Env.filter_command.length()).equals(Env.filter_command)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -81,11 +81,11 @@ public class Env {
|
||||
|
||||
private static boolean display_folder_instead_of_git_name = true;
|
||||
|
||||
public static void set_display_folder_instead_of_git_name(boolean val) {
|
||||
display_folder_instead_of_git_name = val;
|
||||
public static void set_display_folder_instead_of_git_name(final boolean val) {
|
||||
Env.display_folder_instead_of_git_name = val;
|
||||
}
|
||||
public static boolean get_display_folder_instead_of_git_name() {
|
||||
return display_folder_instead_of_git_name;
|
||||
return Env.display_folder_instead_of_git_name;
|
||||
}
|
||||
|
||||
private static Path island_root_path = null;
|
||||
@ -97,50 +97,51 @@ public class Env {
|
||||
|
||||
static {
|
||||
//String tmp = island_root_path.toAbsolutePath().toString();
|
||||
//Log.info("Current absolute path is: " + tmp);
|
||||
island_root_path = Paths.get("");
|
||||
Path tmpPath = island_root_path;
|
||||
while (!Files.isDirectory(tmpPath.resolve("." + get_system_base_name()))) {
|
||||
Env.island_root_path = Paths.get("");
|
||||
Path tmpPath = Env.island_root_path.toAbsolutePath();
|
||||
Log.info("Current absolute path is: " + tmpPath);
|
||||
while (!Files.isDirectory(tmpPath.resolve("." + Env.get_system_base_name()))) {
|
||||
tmpPath = tmpPath.getParent();
|
||||
Log.info("test upper path: " + tmpPath);
|
||||
if (tmpPath == null) {
|
||||
Log.critical("the root path of " + get_system_base_name() + " must not be upper parent paths of (" + 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() + ")");
|
||||
}
|
||||
}
|
||||
island_root_path = tmpPath;
|
||||
island_path_user_config = island_root_path.resolve(get_system_config_name());
|
||||
island_path = island_root_path.resolve("." + get_system_base_name());
|
||||
island_path_config = island_path.resolve("config.xml");
|
||||
island_path_manifest = island_path.resolve("manifest");
|
||||
Env.island_root_path = tmpPath;
|
||||
Env.island_path_user_config = Env.island_root_path.resolve(Env.get_system_config_name());
|
||||
Env.island_path = Env.island_root_path.resolve("." + Env.get_system_base_name());
|
||||
Env.island_path_config = Env.island_path.resolve("config.xml");
|
||||
Env.island_path_manifest = Env.island_path.resolve("manifest");
|
||||
}
|
||||
/**
|
||||
* To use later to know where the ".island" parent path is ...
|
||||
* @return the parent path of the ".island"
|
||||
*/
|
||||
public static Path get_island_root_path() {
|
||||
return island_root_path;
|
||||
return Env.island_root_path;
|
||||
}
|
||||
public static Path get_island_path() {
|
||||
return island_path;
|
||||
return Env.island_path;
|
||||
}
|
||||
public static Path get_island_path_config() {
|
||||
return island_path_config;
|
||||
return Env.island_path_config;
|
||||
}
|
||||
|
||||
public static Path get_island_path_manifest() {
|
||||
return island_path_manifest;
|
||||
return Env.island_path_manifest;
|
||||
}
|
||||
public static Path get_island_path_user_config() {
|
||||
return island_path_user_config;
|
||||
return Env.island_path_user_config;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Log.error("island_root_path = " + island_root_path.toAbsolutePath());
|
||||
Log.error("island_path_user_config = " + island_path_user_config.toAbsolutePath());
|
||||
Log.error("island_path = " + island_path.toAbsolutePath());
|
||||
Log.error("island_path_config = " + island_path_config.toAbsolutePath());
|
||||
Log.error("island_path_manifest = " + island_path_manifest.toAbsolutePath());
|
||||
public static void main(final String[] args) {
|
||||
Log.error("island_root_path = " + Env.island_root_path.toAbsolutePath());
|
||||
Log.error("island_path_user_config = " + Env.island_path_user_config.toAbsolutePath());
|
||||
Log.error("island_path = " + Env.island_path.toAbsolutePath());
|
||||
Log.error("island_path_config = " + Env.island_path_config.toAbsolutePath());
|
||||
Log.error("island_path_manifest = " + Env.island_path_manifest.toAbsolutePath());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
34
src/org/atriasoft/island/IncludeConfig.java
Normal file
34
src/org/atriasoft/island/IncludeConfig.java
Normal file
@ -0,0 +1,34 @@
|
||||
package org.atriasoft.island;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
class IncludeConfig {
|
||||
private String name;
|
||||
private Path path;
|
||||
private Manifest manifest;
|
||||
|
||||
public IncludeConfig(final String name, final Path path, final Manifest manifest) {
|
||||
this.name = name;
|
||||
this.path = path;
|
||||
this.manifest = manifest;
|
||||
}
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public Path getPath() {
|
||||
return this.path;
|
||||
}
|
||||
public void setPath(final Path path) {
|
||||
this.path = path;
|
||||
}
|
||||
public Manifest getManifest() {
|
||||
return this.manifest;
|
||||
}
|
||||
public void setManifest(final Manifest manifest) {
|
||||
this.manifest = manifest;
|
||||
}
|
||||
|
||||
}
|
@ -1,189 +1,228 @@
|
||||
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.IslandActionStatus;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
|
||||
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 {
|
||||
my_args.addSection("option", "Can be set one time in all case");
|
||||
my_args.add("h", "help", null, "Display this help");
|
||||
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","Log"),
|
||||
new ArgChoice("5","verbose"),
|
||||
new ArgChoice("6","extreme_verbose")), "display Log level (verbose) default =2");
|
||||
my_args.add("c", "color", null, "Display message in color");
|
||||
my_args.add("n", "no-fetch-manifest", null, "Disable the fetch of the manifest", false);
|
||||
my_args.add("F", "filter", null, "Filter the action on a list of path or subpath: -f library", true);
|
||||
my_args.add("f", "folder", null, "Display the folder instead of the git repository name", false);
|
||||
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=" + str(env.get_wait_between_sever_command()) + ")", false);
|
||||
my_args.set_stop_at(new ArrayList<Actions.getListOfAction()));
|
||||
//
|
||||
// @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 ?????");
|
||||
}
|
||||
}
|
||||
/*
|
||||
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);
|
||||
}
|
||||
|
||||
local_argument = my_args.parse();
|
||||
public boolean check_boolean(final String value) {
|
||||
if (value.isEmpty() || value.equals("1") || value.equalsIgnoreCase("true")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// @brief Display the help of this makefile.
|
||||
//
|
||||
public void usage():
|
||||
color = Log.get_color_set()
|
||||
// generic argument displayed :
|
||||
my_args.display()
|
||||
print(" Action availlable" )
|
||||
list_actions = actions.get_list_of_action();
|
||||
for elem in list_actions:
|
||||
print(" " + color['green'] + elem + color['default'])
|
||||
print(" " + actions.get_action_help(elem))
|
||||
"""
|
||||
print(" " + color['green'] + "init" + color['default'])
|
||||
print(" initialize a 'island' interface with a manifest in a git ")
|
||||
print(" " + color['green'] + "sync" + color['default'])
|
||||
print(" Syncronise the currect environement")
|
||||
print(" " + color['green'] + "status" + color['default'])
|
||||
print(" Dump the status of the environement")
|
||||
"""
|
||||
print(" ex: " + sys.argv[0] + " -c init http://github.com/atria-soft/manifest.git")
|
||||
print(" ex: " + sys.argv[0] + " sync")
|
||||
exit(0)
|
||||
// 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;
|
||||
}
|
||||
|
||||
public void check_boolean(value):
|
||||
if value == "" \
|
||||
or value == "1" \
|
||||
or value == "true" \
|
||||
or value == "true" \
|
||||
or value == true:
|
||||
return true
|
||||
return false
|
||||
|
||||
// preparse the argument to get the verbose element for Log mode
|
||||
public void parse_generic_arg(argument, active):
|
||||
Log.extreme_verbose("parse arg : " + argument.getOptionName() + " " + argument.getArg() + " active=" + str(active))
|
||||
if argument.getOptionName() == "help":
|
||||
if active == false:
|
||||
usage()
|
||||
return true
|
||||
} else if argument.getOptionName()=="jobs":
|
||||
if active == true:
|
||||
//multiprocess.set_core_number(int(argument.getArg()))
|
||||
pass
|
||||
return true
|
||||
} else if argument.getOptionName()=="wait":
|
||||
if active == true:
|
||||
env.set_wait_between_sever_command(int(argument.getArg()))
|
||||
return true
|
||||
} else if argument.getOptionName() == "verbose":
|
||||
if active == true:
|
||||
Log.set_level(int(argument.getArg()))
|
||||
return true
|
||||
} else if argument.getOptionName() == "folder":
|
||||
if active == true:
|
||||
env.set_display_folder_instead_of_git_name(true)
|
||||
return true
|
||||
} else if argument.getOptionName() == "color":
|
||||
if active == true:
|
||||
if check_boolean(argument.getArg()) == true:
|
||||
Log.enable_color()
|
||||
else:
|
||||
Log.disable_color()
|
||||
return true
|
||||
} else if argument.getOptionName() == "filter":
|
||||
if active == true:
|
||||
env.set_filter_command(str(argument.getArg()))
|
||||
return true
|
||||
} else if argument.getOptionName() == "no-fetch-manifest":
|
||||
if active == false:
|
||||
env.set_fetch_manifest(false)
|
||||
return true
|
||||
return false
|
||||
|
||||
// open configuration of island:
|
||||
config_file = env.get_island_path_user_config()
|
||||
if os.path.isfile(config_file) == true:
|
||||
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])
|
||||
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("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()));
|
||||
}
|
||||
|
||||
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)
|
||||
void run(final String[] args) throws ActionException {
|
||||
List<String> argss = Arrays.asList(args);
|
||||
List<ArgElement> local_argument = this.my_args.parse(argss);
|
||||
|
||||
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)
|
||||
// parse default unique argument:
|
||||
for (ArgElement argument : local_argument) {
|
||||
parse_generic_arg(argument, true);
|
||||
}
|
||||
// remove all generic arguments:
|
||||
List<ArgElement> new_argument_list = new ArrayList<>();
|
||||
for (ArgElement argument : local_argument) {
|
||||
if (parse_generic_arg(argument, false)) {
|
||||
continue;
|
||||
}
|
||||
new_argument_list.add(argument);
|
||||
}
|
||||
|
||||
if "get_default_Log_level" in dir(configuration_file):
|
||||
data = configuration_file.get_default_Log_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)
|
||||
// now the first argument is: the action:
|
||||
if (new_argument_list.size() == 0) {
|
||||
Log.warning("--------------------------------------");
|
||||
Log.warning("Missing the action to do ...");
|
||||
Log.warning("--------------------------------------");
|
||||
usage();
|
||||
}
|
||||
String action_to_do = new_argument_list.get(0).getArg();
|
||||
new_argument_list.remove(0);
|
||||
if (!Actions.exist(action_to_do)) {
|
||||
Log.warning("--------------------------------------");
|
||||
Log.warning("Wrong action type : '" + action_to_do + "' availlable list: " + Actions.getListOfAction());
|
||||
Log.warning("--------------------------------------");
|
||||
usage();
|
||||
}
|
||||
// todo : Remove this
|
||||
if (!action_to_do.equals("init") && !Files.exists(Env.get_island_path())) {
|
||||
Log.error("Can not execute a island cmd if we have not initialize a config: '" + "." + Env.get_system_base_name() + "' in upper 6 parent path");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// parse default unique argument:
|
||||
for argument in local_argument:
|
||||
parse_generic_arg(argument, true)
|
||||
|
||||
// remove all generic arguments:
|
||||
new_argument_list = []
|
||||
for argument in local_argument:
|
||||
if parse_generic_arg(argument, false) == true:
|
||||
continue
|
||||
new_argument_list.append(argument)
|
||||
|
||||
// now the first argument is: the action:
|
||||
if len(new_argument_list) == 0:
|
||||
Log.warning("--------------------------------------")
|
||||
Log.warning("Missing the action to do ...")
|
||||
Log.warning("--------------------------------------")
|
||||
usage()
|
||||
|
||||
|
||||
// TODO : move tin in actions ...
|
||||
list_actions = actions.get_list_of_action();
|
||||
|
||||
action_to_do = new_argument_list[0].getArg()
|
||||
new_argument_list = new_argument_list[1:]
|
||||
if action_to_do not in list_actions:
|
||||
Log.warning("--------------------------------------")
|
||||
Log.warning("Wrong action type : '" + str(action_to_do) + "' availlable list: " + str(list_actions) )
|
||||
Log.warning("--------------------------------------")
|
||||
usage()
|
||||
|
||||
// todo : Remove this
|
||||
if action_to_do != "init" \
|
||||
and os.path.exists(env.get_island_path()) == false:
|
||||
Log.error("Can not execute a island cmd if we have not initialize a config: '" + str("." + env.get_system_base_name()) + "' in upper 6 parent path")
|
||||
exit(-1)
|
||||
|
||||
|
||||
ret = actions.execute(action_to_do, my_args.get_last_parsed()+1)
|
||||
|
||||
exit (ret)
|
||||
// stop all started threads;
|
||||
//multiprocess.un_init()
|
||||
|
||||
|
||||
}
|
@ -1,35 +1,28 @@
|
||||
package org.atriasoft.island;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.exml.Exml;
|
||||
import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||
import org.atriasoft.exml.exception.ExmlParserErrorMulti;
|
||||
import org.atriasoft.exml.model.XmlAttribute;
|
||||
import org.atriasoft.exml.model.XmlElement;
|
||||
import org.atriasoft.exml.model.XmlNode;
|
||||
import org.atriasoft.exml.model.XmlNodeType;
|
||||
import org.atriasoft.exml.parser.ParseXml;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.Link;
|
||||
import org.atriasoft.island.model.MirrorConfig;
|
||||
import org.atriasoft.island.model.ProjectConfig;
|
||||
import org.atriasoft.island.model.RemoteConfig;
|
||||
import org.atriasoft.island.model.RepositoryConfig;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.RemoteListCommand;
|
||||
|
||||
class RepositoryCongig {
|
||||
String remote = "origin";
|
||||
String revision = "master";
|
||||
boolean sync = false;
|
||||
}
|
||||
|
||||
record MirrorConfig(String name, String fetch) {
|
||||
}
|
||||
|
||||
record RemoteConfig(String name, String fetch, List<MirrorConfig> mirror) {
|
||||
}
|
||||
record IncludeConfig(String name, String path, Object manifest) {
|
||||
}
|
||||
|
||||
public class Manifest {
|
||||
public static boolean isInit() {
|
||||
if (!Files.exists(Env.get_island_path())){
|
||||
@ -48,7 +41,7 @@ public class Manifest {
|
||||
}
|
||||
public static void checkIsInit() {
|
||||
// check if .XXX exist (create it if needed)
|
||||
if (!isInit()) {
|
||||
if (!Manifest.isInit()) {
|
||||
Log.error("System not init: missing config: '" + Env.get_island_path() + "'. Call <island init> first");
|
||||
System.exit(-1);
|
||||
}
|
||||
@ -57,34 +50,40 @@ public class Manifest {
|
||||
private String deliver_master = "master";
|
||||
private String deliver_develop = "develop";
|
||||
private String deliver_mode = "merge";
|
||||
private Path manifestXml;
|
||||
private final Path manifestXml;
|
||||
|
||||
List<Object> projects = new ArrayList<>();
|
||||
RepositoryCongig defaultWhat = null;
|
||||
RepositoryCongig default_base = new RepositoryCongig();
|
||||
List<ProjectConfig> projects = new ArrayList<>();
|
||||
RepositoryConfig defaultWhat = null;
|
||||
RepositoryConfig default_base = new RepositoryConfig();
|
||||
List<RemoteConfig> remotes = new ArrayList<>();
|
||||
List<IncludeConfig> includes = new ArrayList<>();
|
||||
List<Object> links = new ArrayList<>();
|
||||
public Manifest(Path manifest_xml) {
|
||||
manifestXml = manifest_xml;
|
||||
List<Link> links = new ArrayList<>();
|
||||
public Manifest(final Path manifestXml) throws IOException {
|
||||
this.manifestXml = manifestXml;
|
||||
// load the manifest
|
||||
load();
|
||||
try {
|
||||
load();
|
||||
} catch (ExmlBuilderException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
// check error in manifest (double path ...)
|
||||
// TODO checkDoublePath();
|
||||
}
|
||||
|
||||
public List<Object> getLinks() {
|
||||
public List<Link> getLinks() {
|
||||
return this.links;
|
||||
}
|
||||
String removeEndSlash(String value) {
|
||||
while (value.length() > 1
|
||||
&& ( value.charAt(value.length()-1) == '\\'
|
||||
|| value.charAt(value.length()-1) == '/')) {
|
||||
|| value.charAt(value.length()-1) == '/') ) {
|
||||
value = value.substring(0, value.length()-1);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
public void load() {
|
||||
|
||||
public void load() throws ExmlParserErrorMulti, ExmlBuilderException, IOException {
|
||||
XmlElement rootNode = Exml.parse(this.manifestXml);
|
||||
Log.debug("manifest : '" + this.manifestXml + "'");
|
||||
if (!rootNode.getValue().equals("manifest")) {
|
||||
@ -115,11 +114,11 @@ public class Manifest {
|
||||
// Log.verbose("base_origin=" + base_origin[1])
|
||||
// base_origin = base_origin[1]
|
||||
// while len(fetch) >= 2 \
|
||||
// and fetch[:2] == "..":
|
||||
// and fetch[:2].equals("..":
|
||||
// fetch = fetch[2:]
|
||||
// while len(fetch) >= 1 \
|
||||
// and ( fetch[0] == "/" \
|
||||
// or fetch[0] == "\\"):
|
||||
// and ( fetch[0].equals("/" \
|
||||
// or fetch[0].equals("\\"):
|
||||
// fetch = fetch[1:]
|
||||
// offset_1 = base_origin.rfind('/')
|
||||
// offset_2 = base_origin.rfind(':')
|
||||
@ -137,14 +136,14 @@ public class Manifest {
|
||||
}
|
||||
fetch = removeEndSlash(fetch);
|
||||
} else {
|
||||
Log.error("Parsing the manifest : Unknow '" + child.getName() + "' attibute : '" + attr.getName() + "', availlable:[name,fetch]")
|
||||
Log.error("Parsing the manifest : Unknow '" + child.getValue() + "' attibute : '" + attr.getName() + "', availlable:[name,fetch]");
|
||||
}
|
||||
}
|
||||
Log.debug(" find '" + child.getName() + "' : name='" + name + "' fetch='" + fetch + "'");
|
||||
Log.debug(" find '" + child.getValue() + "' : name='" + name + "' fetch='" + fetch + "'");
|
||||
// parse the sub global mirror list
|
||||
List<MirrorConfig> mirror_list = new ArrayList<>();
|
||||
for (XmlNode child_2 : child.toElement().getNodes()) {
|
||||
if (child_2.getValue().equals("mirror")):
|
||||
if (child_2.getValue().equals("mirror")) {
|
||||
// find a new mirror
|
||||
String mirror_name = "";
|
||||
String mirror_fetch = "";
|
||||
@ -167,147 +166,156 @@ public class Manifest {
|
||||
}
|
||||
mirror_list.add(new MirrorConfig(mirror_name, mirror_fetch));
|
||||
} else {
|
||||
Log.critical("Parsing the manifest : Unknow '" + child_2.getName() + "', availlable:[mirror]");
|
||||
Log.critical("Parsing the manifest : Unknow '" + child_2.getValue() + "', availlable:[mirror]");
|
||||
}
|
||||
}
|
||||
this.remotes.add(new RemoteConfig(name, fetch, mirror_list));
|
||||
continue;
|
||||
}
|
||||
if (child.getName().equals("include") {
|
||||
}
|
||||
if (child.getValue().equals("include")) {
|
||||
String name = "";
|
||||
for (XmlAttribute attr : child.toElement.getAttributes()) {
|
||||
for (XmlAttribute attr : child.toElement().getAttributes()) {
|
||||
if (attr.getName().equals("name")) {
|
||||
name = attr.getValue();
|
||||
} else {
|
||||
Log.error("Parsing the manifest : Unknow '" + child.getName() + "' attibute : '" + attr + "', availlable:[name]")
|
||||
Log.error("Parsing the manifest : Unknow '" + child.getValue() + "' attibute : '" + attr + "', availlable:[name]");
|
||||
}
|
||||
}
|
||||
Log.debug(" find '" + child.getName() + "' : name='" + name + "'");
|
||||
Log.debug(" find '" + child.getValue() + "' : name='" + name + "'");
|
||||
// check if the file exist ...
|
||||
Path new_name_xml = this.manifest_xml.resolve(name);
|
||||
Path new_name_xml = this.manifestXml.resolve(name);
|
||||
if (!Files.exists(new_name_xml)) {
|
||||
Log.critical("The file does not exist: " + new_name_xml)
|
||||
Log.critical("The file does not exist: " + new_name_xml);
|
||||
}
|
||||
this.includes.add(new IncludeConfig(name, new_name_xml, null));
|
||||
continue;
|
||||
}
|
||||
if (child.getName().equals("default") {
|
||||
if (child.getValue().equals("default")) {
|
||||
String remote = "origin";
|
||||
String revision = "master";
|
||||
boolean sync = false;
|
||||
for (XmlAttribute attr : child.toElement.getAttributes()) {
|
||||
for (XmlAttribute attr : child.toElement().getAttributes()) {
|
||||
if (attr.getName().equals("remote")) {
|
||||
remote = attr.getValue();
|
||||
} else if (attr.getName().equals("revision")) {
|
||||
revision = attr.getValue();
|
||||
} else if (attr.getName().equals("sync-s")) { // synchronize submodule ... automaticaly
|
||||
sync = attr.getValue();
|
||||
if (sync.lower().equals("true")
|
||||
|| sync.equals("1")
|
||||
|| sync.lower().equals("yes")) {
|
||||
String syncBase = attr.getValue();
|
||||
if (syncBase.equalsIgnoreCase("true")
|
||||
|| syncBase.equals("1")
|
||||
|| syncBase.toLowerCase().equals("yes")) {
|
||||
sync = true;
|
||||
} else if (sync.lower().equals("false")
|
||||
|| sync.equals("0")
|
||||
|| sync.lower().equals("no")) {
|
||||
sync = false
|
||||
} else {
|
||||
Log.critical("Parsing the manifest : Unknow '" + child.getName() + "' attibute : '" + attr + "', value:'" + sync + "' availlable:[true,1,yes,false,0,no]");
|
||||
} else if (syncBase.equalsIgnoreCase("false")
|
||||
|| syncBase.equals("0")
|
||||
|| syncBase.equalsIgnoreCase("no")) {
|
||||
sync = false;
|
||||
} else {
|
||||
Log.critical("Parsing the manifest : Unknow '" + child.getValue() + "' attibute : '" + attr + "', value:'" + sync + "' availlable:[true,1,yes,false,0,no]");
|
||||
}
|
||||
} else {
|
||||
Log.error("Parsing the manifest : Unknow '" + child.getName() + "' attibute : '" + attr + "', availlable:[remote,revision,sync-s]");
|
||||
} else {
|
||||
Log.error("Parsing the manifest : Unknow '" + child.getValue() + "' attibute : '" + attr + "', availlable:[remote,revision,sync-s]");
|
||||
}
|
||||
}
|
||||
if (this.defaultWhat != null) {
|
||||
Log.error("Parsing the manifest : Node '" + child.getName() + "' already set")
|
||||
Log.error("Parsing the manifest : Node '" + child.getValue() + "' already set");
|
||||
}
|
||||
this.defaultWhat = new RepositoryCongig(remote, revision, sync));
|
||||
Log.debug(" find '" + child.getName() + "' : remote='" + remote + "' revision='" + revision + "' sync=" + sync);
|
||||
this.defaultWhat = new RepositoryConfig(remote, revision, sync);
|
||||
Log.debug(" find '" + child.getValue() + "' : remote='" + remote + "' revision='" + revision + "' sync=" + sync);
|
||||
continue;
|
||||
}
|
||||
if child.tag == "project":
|
||||
name = ""
|
||||
path = ""
|
||||
tag_sha1 = None
|
||||
for attr in child.attrib:
|
||||
if attr == "name":
|
||||
name = child.attrib[attr]
|
||||
} else if attr == "path":
|
||||
path = child.attrib[attr]
|
||||
} else if attr == "tag":
|
||||
tag_sha1 = child.attrib[attr]
|
||||
else:
|
||||
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name,tag,sync-s]")
|
||||
if name == "":
|
||||
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: '" + child.tag + "' missing attribute: 'name' ==> specify the git to clone ...")
|
||||
this.projects.append({
|
||||
"name":name,
|
||||
"path":path,
|
||||
"tag":tag_sha1,
|
||||
})
|
||||
Log.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : name='" + name + "' path='" + path + "' tag='" + str(tag_sha1) + "'");
|
||||
continue
|
||||
if child.tag == "option":
|
||||
if (child.getValue().equals("project")) {
|
||||
String name = "";
|
||||
String path = "";
|
||||
String tag_sha1 = null;
|
||||
for (XmlAttribute attr : child.toElement().getAttributes()) {
|
||||
if (attr.getName().equals("name")) {
|
||||
name = attr.getValue();
|
||||
} else if (attr.getName().equals("path")) {
|
||||
path = attr.getValue();
|
||||
} else if (attr.getName().equals("tag")) {
|
||||
tag_sha1 = attr.getValue();
|
||||
} else {
|
||||
Log.error("Parsing the manifest: Unknow '" + child.getValue() + "' attibute : '" + attr + "', availlable:[name,tag,sync-s]");
|
||||
}
|
||||
}
|
||||
if (name.isEmpty()) {
|
||||
Log.error("Parsing the manifest: '" + child.getValue() + "' missing attribute: 'name' ==> specify the git to clone ...");
|
||||
}
|
||||
this.projects.add(new ProjectConfig(name, path, tag_sha1));
|
||||
Log.debug(" find '" + child.getValue() + "' : name='" + name + "' path='" + path + "' tag='" + tag_sha1 + "'");
|
||||
continue;
|
||||
}
|
||||
if (child.getValue().equals("option")) {
|
||||
// not managed ==> future use
|
||||
type_option = ""
|
||||
value_option = ""
|
||||
for attr in child.attrib:
|
||||
if attr == "type":
|
||||
type_option = child.attrib[attr]
|
||||
} else if attr == "value":
|
||||
value_option = child.attrib[attr]
|
||||
else:
|
||||
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[type,value]")
|
||||
if type_option == "deliver_master":
|
||||
this.deliver_master = value_option
|
||||
} else if type_option == "deliver_develop":
|
||||
this.deliver_develop = value_option
|
||||
} else if type_option == "deliver_mode":
|
||||
this.deliver_mode = value_option
|
||||
if this.deliver_mode not in ["merge","fast_forward"]:
|
||||
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: option 'deliver_mode' value availlable: [merge,fast_forward]")
|
||||
else:
|
||||
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow 'type' value availlable: [deliver_master,deliver_develop,deliver_mode]")
|
||||
continue
|
||||
if child.tag == "link":
|
||||
String type_option = "";
|
||||
String value_option = "";
|
||||
for (XmlAttribute attr : child.toElement().getAttributes()) {
|
||||
if (attr.getName().equals("type")) {
|
||||
type_option = attr.getValue();
|
||||
} else if (attr.getName().equals("value")) {
|
||||
value_option = attr.getValue();
|
||||
} else {
|
||||
Log.error("Parsing the manifest: Unknow '" + child.getValue() + "' attibute : '" + attr + "', availlable:[type,value]");
|
||||
}
|
||||
}
|
||||
if (type_option.equals("deliver_master")) {
|
||||
this.deliver_master = value_option;
|
||||
} else if (type_option.equals("deliver_develop")) {
|
||||
this.deliver_develop = value_option;
|
||||
} else if (type_option.equals("deliver_mode")) {
|
||||
this.deliver_mode = value_option;
|
||||
if (this.deliver_mode.equals("merge") || this.deliver_mode.equals("fast_forward")) {
|
||||
Log.critical("Parsing the manifest: option 'deliver_mode' value availlable: [merge,fast_forward]");
|
||||
}
|
||||
} else {
|
||||
Log.critical("Parsing the manifest: Unknow 'type' value availlable: [deliver_master,deliver_develop,deliver_mode]");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (child.getValue().equals("link")) {
|
||||
// not managed ==> future use
|
||||
source = ""
|
||||
destination = ""
|
||||
for attr in child.attrib:
|
||||
if attr == "source":
|
||||
source = child.attrib[attr]
|
||||
} else if attr == "destination":
|
||||
destination = child.attrib[attr]
|
||||
else:
|
||||
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[source,destination]")
|
||||
if source == "":
|
||||
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: '" + child.tag + "' missing attribute: 'source' ==> specify the git to clone ...")
|
||||
if destination == "":
|
||||
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: '" + child.tag + "' missing attribute: 'destination' ==> specify the git to clone ...")
|
||||
this.links.append({
|
||||
"source":source,
|
||||
"destination":destination,
|
||||
})
|
||||
Log.debug("Add link: '" + str(destination) + "' ==> '" + str(source) + "'")
|
||||
continue
|
||||
Log.info("(l:" + str(child.sourceline) + ") '" + str(child.tag) + "' values=" + str(child.attrib));
|
||||
Log.error("(l:" + str(child.sourceline) + ") Parsing error Unknow NODE : '" + str(child.tag) + "' availlable:[remote,include,default,project,option,link]")
|
||||
String source = "";
|
||||
String destination = "";
|
||||
for (XmlAttribute attr : child.toElement().getAttributes()) {
|
||||
if (attr.getName().equals("source")) {
|
||||
source = attr.getValue();
|
||||
} else if (attr.getName().equals("destination")) {
|
||||
destination = attr.getValue();
|
||||
} else {
|
||||
Log.critical("Parsing the manifest: Unknow '" + child.getValue() + "' attibute : '" + attr + "', availlable:[source,destination]");
|
||||
}
|
||||
}
|
||||
if (source.isEmpty()) {
|
||||
Log.error("Parsing the manifest: '" + child.getValue() + "' missing attribute: 'source' ==> specify the git to clone ...");
|
||||
}
|
||||
if (destination.isEmpty()) {
|
||||
Log.error("Parsing the manifest: '" + child.getValue() + "' missing attribute: 'destination' ==> specify the git to clone ...");
|
||||
}
|
||||
this.links.add(new Link(source, destination));
|
||||
Log.debug("Add link: '" + destination + "' ==> '" + source + "'");
|
||||
continue;
|
||||
}
|
||||
Log.info(" '" + child.getValue() + "' values=" + child.toElement().getAttributes());
|
||||
Log.error("Parsing error Unknow NODE : '" + child.getValue() + "' availlable:[remote,include,default,project,option,link]");
|
||||
}
|
||||
// now we parse all sub repo:
|
||||
for elem in this.includes:
|
||||
elem["manifest"] = Manifest(elem["path"])
|
||||
|
||||
|
||||
// inside data child.text
|
||||
for (IncludeConfig elem : this.includes) {
|
||||
elem.setManifest(new Manifest(elem.getPath()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// public void _create_path_with_elem(this, element):
|
||||
// path = element["path"]
|
||||
// if path == "":
|
||||
// path = element["name"]
|
||||
// if len(path) >= 4 \
|
||||
// and path[-4:] == ".git":
|
||||
// path = path[:-4]
|
||||
// return path
|
||||
//
|
||||
// public void checkDoublePath(this, list_path = [], space=""):
|
||||
public String createPathWithElem(final ProjectConfig element) {
|
||||
String path = element.getPath();
|
||||
if (path.isEmpty()) {
|
||||
path = element.getName();
|
||||
if (path.endsWith(".git")) {
|
||||
path = path.substring(0, path.length()-4);
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
// public void checkDoublePath(this, list_path = [], space="") {
|
||||
// Log.debug(space + "check path : '" + this.manifest_xml + "'")
|
||||
// for elem in this.projects:
|
||||
// path = this._create_path_with_elem(elem)
|
||||
@ -317,107 +325,126 @@ public class Manifest {
|
||||
// list_path.append(path)
|
||||
// for elem in this.includes:
|
||||
// elem["manifest"]._check_double_path(list_path, space + " ")
|
||||
//
|
||||
// public void get_all_configs(this, default=None, upper_remotes=[]):
|
||||
// out = []
|
||||
// if default == None:
|
||||
// if this.default != None:
|
||||
// default = copy.deepcopy(this.default)
|
||||
// else:
|
||||
// default = copy.deepcopy(this.default_base)
|
||||
// // Log.error(" this.default=" + str(this.default))
|
||||
// // add all local project
|
||||
// for elem in this.projects:
|
||||
// Log.verbose("parse element " + str(elem))
|
||||
// if Env.need_process_with_filter(elem["name"]) == false:
|
||||
// Log.info("Filter repository: " + str(elem["name"]))
|
||||
// continue
|
||||
// conf = repo_config.RepoConfig()
|
||||
// conf.name = elem["name"]
|
||||
// conf.tag = elem["tag"]
|
||||
// conf.path = this._create_path_with_elem(elem)
|
||||
//
|
||||
// // add default remote for the project (search in herited element)
|
||||
// for remote in this.remotes:
|
||||
// Log.verbose(" Local Remote: " + str(remote))
|
||||
// if remote["name"] == default["remote"]:
|
||||
// conf.remotes.append(remote)
|
||||
// if len(conf.remotes) == 0:
|
||||
// for remote in upper_remotes:
|
||||
// Log.verbose(" upper Remote: " + str(remote))
|
||||
// if remote["name"] == default["remote"]:
|
||||
// conf.remotes.append(remote)
|
||||
// if len(conf.remotes) == 0:
|
||||
// Log.error(" No remote detected: " + str(len(conf.remotes)) + " for " + conf.name + " with default remote name : " + default["remote"] + " this remote: " + str(this.remotes))
|
||||
//
|
||||
// // select default remote:
|
||||
// conf.select_remote = None
|
||||
// Log.debug(" remotes count: " + str(len(conf.remotes)))
|
||||
// for remote in conf.remotes:
|
||||
// Log.debug(" remote=" + str(remote))
|
||||
// Log.debug(" Ckeck remote : " + remote["name"] + " == " + default["remote"])
|
||||
// Log.verbose(" remote=" + str(remote))
|
||||
// Log.verbose(" default=" + str(default))
|
||||
// if remote["name"] == default["remote"]:
|
||||
// conf.select_remote = copy.deepcopy(remote)
|
||||
// Log.debug(" copy select=" + str(conf.select_remote))
|
||||
//
|
||||
// // copy the submodule synchronisation
|
||||
// conf.select_remote["sync"] = default["sync"]
|
||||
// break
|
||||
// if conf.select_remote == None:
|
||||
// Log.error("missing remote for project: " + str(conf.name))
|
||||
//
|
||||
// conf.branch = default["revision"]
|
||||
// out.append(conf)
|
||||
// // create a temporary variable to transmit the remote to includes
|
||||
// upper_remotes_forward = copy.deepcopy(upper_remotes)
|
||||
// for remote in this.remotes:
|
||||
// upper_remotes_forward.append(remote)
|
||||
// // add all include project
|
||||
// for elem in this.includes:
|
||||
// list_project = elem["manifest"].get_all_configs(default, upper_remotes_forward)
|
||||
// for elem_proj in list_project:
|
||||
// out.append(elem_proj)
|
||||
//
|
||||
// //# -------------------------------------------------------------
|
||||
// //# -- add Volatile ...
|
||||
// //# -------------------------------------------------------------
|
||||
// Log.verbose("include volatile config")
|
||||
// // TODO: maybe find a better way to do this...
|
||||
// conf_global = config.get_unique_config()
|
||||
// for elem in conf_global.get_volatile():
|
||||
// conf = repo_config.RepoConfig()
|
||||
// base_volatile, repo_volatile = repo_config.split_repo(elem["git_address"])
|
||||
// conf.name = repo_volatile
|
||||
// conf.path = elem["path"]
|
||||
// conf.branch = "master"
|
||||
// conf.volatile = true
|
||||
// conf.remotes = [
|
||||
// {
|
||||
// 'name': 'origin',
|
||||
// 'fetch': base_volatile,
|
||||
// 'mirror': []
|
||||
// }
|
||||
// ]
|
||||
// conf.select_remote = {
|
||||
// 'name': 'origin',
|
||||
// 'fetch': base_volatile,
|
||||
// 'sync': false,
|
||||
// 'mirror': []
|
||||
// }
|
||||
// out.append(conf)
|
||||
// //# -------------------------------------------------------------
|
||||
// if false:
|
||||
// Log.info("list of all repo:")
|
||||
// for elem in out:
|
||||
// Log.info(" '" + elem.name + "'")
|
||||
// Log.info(" path: " + elem.path)
|
||||
// Log.info(" remotes: " + str(elem.remotes))
|
||||
// Log.info(" select_remote: " + str(elem.select_remote))
|
||||
// Log.info(" branch: " + elem.branch)
|
||||
// return out
|
||||
//
|
||||
// }
|
||||
|
||||
public List<ProjectConfig> get_all_configs() {
|
||||
return get_all_configs(null, new ArrayList<>());
|
||||
}
|
||||
|
||||
public List<ProjectConfig> get_all_configs(RepositoryConfig defaultPlouf, final List<RemoteConfig> upper_remotes) {
|
||||
List<ProjectConfig> out = new ArrayList<>();
|
||||
if (defaultPlouf == null) {
|
||||
if (this.defaultWhat != null) {
|
||||
defaultPlouf = this.defaultWhat.clone();
|
||||
} else {
|
||||
defaultPlouf = this.default_base.clone();
|
||||
}
|
||||
}
|
||||
// Log.error(" this.default=" + str(this.default))
|
||||
// add all local project
|
||||
for (ProjectConfig elem : this.projects) {
|
||||
Log.verbose("parse element " + elem);
|
||||
if (!Env.need_process_with_filter(elem.getName())) {
|
||||
Log.info("Filter repository: " + elem.getName());
|
||||
continue;
|
||||
}
|
||||
ProjectConfig conf = new ProjectConfig(elem.getName(), createPathWithElem(elem), elem.getTag());
|
||||
|
||||
// add default remote for the project (search in herited element)
|
||||
for (RemoteConfig remote : this.remotes) {
|
||||
Log.verbose(" Local Remote: " + remote);
|
||||
if (remote.getName().equals(defaultPlouf.getRemote())) {
|
||||
conf.getRemotes().add(remote);
|
||||
}
|
||||
}
|
||||
if (conf.getRemotes().size() == 0) {
|
||||
for (RemoteConfig remote : upper_remotes) {
|
||||
Log.verbose(" upper Remote: " + remote);
|
||||
if (remote.getName().equals(defaultPlouf.getRemote())) {
|
||||
conf.getRemotes().add(remote);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (conf.getRemotes().size() == 0) {
|
||||
Log.error(" No remote detected: " + conf.getRemotes().size() + " for " + conf.getName() + " with default remote name : " + defaultPlouf.getRemote() + " this remote: " + this.remotes);
|
||||
}
|
||||
// select default remote:
|
||||
Log.debug(" remotes count: " + conf.getRemotes().size());
|
||||
for (RemoteConfig remote : conf.getRemotes()) {
|
||||
Log.debug(" remote=" + remote);
|
||||
Log.debug(" Ckeck remote : " + remote.getName() + ".equals(" + defaultPlouf.getRemote());
|
||||
Log.verbose(" remote=" + remote);
|
||||
Log.verbose(" default=" + defaultPlouf);
|
||||
if (remote.getName().equals(defaultPlouf.getRemote())) {
|
||||
conf.setSelectRemotes(remote.clone());
|
||||
Log.debug(" copy select=" + conf.getSelectRemotes());
|
||||
|
||||
// copy the submodule synchronisation
|
||||
// TODO: ????? conf.getSelectRemotes().setSync(defaultPlouf.isSync());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (conf.getSelectRemotes() == null) {
|
||||
Log.error("missing remote for project: " + conf.getName());
|
||||
}
|
||||
conf.setBranch(defaultPlouf.getRevision());
|
||||
out.add(conf);
|
||||
}
|
||||
// create a temporary variable to transmit the remote to includes
|
||||
List<RemoteConfig> upper_remotes_forward = new ArrayList<>(upper_remotes);
|
||||
for (RemoteConfig remote : this.remotes) {
|
||||
upper_remotes_forward.add(remote);
|
||||
}
|
||||
// add all include project
|
||||
for (IncludeConfig elem : this.includes) {
|
||||
List<ProjectConfig> list_project = elem.getManifest().get_all_configs(defaultPlouf, upper_remotes_forward);
|
||||
for (ProjectConfig elem_proj : list_project) {
|
||||
out.add(elem_proj);
|
||||
}
|
||||
}
|
||||
|
||||
// DEPRECIATE volatile for a while?.????
|
||||
//# -------------------------------------------------------------
|
||||
//# -- add Volatile ...
|
||||
//# -------------------------------------------------------------
|
||||
Log.verbose("include volatile config");
|
||||
// TODO: maybe find a better way to do this...
|
||||
/*
|
||||
conf_global = config.get_unique_config()
|
||||
for elem in conf_global.get_volatile():
|
||||
conf = repo_config.RepoConfig()
|
||||
base_volatile, repo_volatile = repo_config.split_repo(elem["git_address"])
|
||||
conf.name = repo_volatile
|
||||
conf.path = elem["path"]
|
||||
conf.branch = "master"
|
||||
conf.volatile = true
|
||||
conf.remotes = [
|
||||
{
|
||||
'name': 'origin',
|
||||
'fetch': base_volatile,
|
||||
'mirror': []
|
||||
}
|
||||
]
|
||||
conf.select_remote = {
|
||||
'name': 'origin',
|
||||
'fetch': base_volatile,
|
||||
'sync': false,
|
||||
'mirror': []
|
||||
}
|
||||
out.append(conf)
|
||||
//# -------------------------------------------------------------
|
||||
if false:
|
||||
Log.info("list of all repo:")
|
||||
for elem in out:
|
||||
Log.info(" '" + elem.name + "'")
|
||||
Log.info(" path: " + elem.path)
|
||||
Log.info(" remotes: " + str(elem.remotes))
|
||||
Log.info(" select_remote: " + str(elem.select_remote))
|
||||
Log.info(" branch: " + elem.branch)
|
||||
*/
|
||||
return out;
|
||||
}
|
||||
|
||||
//
|
||||
//public void tag_manifest(manifest_xml_filename, all_tags):
|
||||
// tree = etree.parse(manifest_xml_filename)
|
||||
@ -431,12 +458,12 @@ public class Manifest {
|
||||
// if type(child) == etree._Comment:
|
||||
// Log.verbose("(l:" + str(child.sourceline) + ") comment='" + str(child.text) + "'");
|
||||
// continue
|
||||
// if child.tag == "remote":
|
||||
// if child.tag.equals("remote":
|
||||
// continue
|
||||
// if child.tag == "include":
|
||||
// if child.tag.equals("include":
|
||||
// name = ""
|
||||
// for attr in child.attrib:
|
||||
// if attr == "name":
|
||||
// if attr.equals("name":
|
||||
// name = child.attrib[attr]
|
||||
// else:
|
||||
// Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name]")
|
||||
@ -451,31 +478,31 @@ public class Manifest {
|
||||
// "manifest":None
|
||||
// })
|
||||
// continue
|
||||
// if child.tag == "default":
|
||||
// if child.tag.equals("default":
|
||||
// continue
|
||||
// if child.tag == "project":
|
||||
// if child.tag.equals("project":
|
||||
// name = ""
|
||||
// path = ""
|
||||
// tag_sha1 = None
|
||||
// for attr in child.attrib:
|
||||
// if attr == "name":
|
||||
// if attr.equals("name":
|
||||
// name = child.attrib[attr]
|
||||
// } else if attr == "path":
|
||||
// } else if attr.equals("path":
|
||||
// path = child.attrib[attr]
|
||||
// } else if attr == "tag":
|
||||
// } else if attr.equals("tag":
|
||||
// tag_sha1 = child.attrib[attr]
|
||||
// else:
|
||||
// Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name,tag,sync-s]")
|
||||
// if name == "":
|
||||
// if name.equals("":
|
||||
// Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: '" + child.tag + "' missing attribute: 'name' ==> specify the git to clone ...")
|
||||
// for elem_tag in all_tags:
|
||||
// if elem_tag["name"] == name:
|
||||
// child.set("tag", elem_tag["tag"])
|
||||
// continue
|
||||
// if child.tag == "option":
|
||||
// if child.tag.equals("option":
|
||||
// // not managed ==> future use
|
||||
// continue
|
||||
// if child.tag == "link":
|
||||
// if child.tag.equals("link":
|
||||
// continue
|
||||
// Log.info("(l:" + str(child.sourceline) + ") '" + str(child.tag) + "' values=" + str(child.attrib));
|
||||
// Log.error("(l:" + str(child.sourceline) + ") Parsing error Unknow NODE : '" + str(child.tag) + "' availlable:[remote,include,default,project,option,link]")
|
||||
@ -498,12 +525,12 @@ public class Manifest {
|
||||
// if type(child) == etree._Comment:
|
||||
// Log.verbose("(l:" + str(child.sourceline) + ") comment='" + str(child.text) + "'");
|
||||
// continue
|
||||
// if child.tag == "remote":
|
||||
// if child.tag.equals("remote":
|
||||
// continue
|
||||
// if child.tag == "include":
|
||||
// if child.tag.equals("include":
|
||||
// name = ""
|
||||
// for attr in child.attrib:
|
||||
// if attr == "name":
|
||||
// if attr.equals("name":
|
||||
// name = child.attrib[attr]
|
||||
// else:
|
||||
// Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name]")
|
||||
@ -518,14 +545,14 @@ public class Manifest {
|
||||
// "manifest":None
|
||||
// })
|
||||
// continue
|
||||
// if child.tag == "default":
|
||||
// if child.tag.equals("default":
|
||||
// continue
|
||||
// if child.tag == "project":
|
||||
// if child.tag.equals("project":
|
||||
// child.attrib.pop("tag", None)
|
||||
// continue
|
||||
// if child.tag == "option":
|
||||
// if child.tag.equals("option":
|
||||
// continue
|
||||
// if child.tag == "link":
|
||||
// if child.tag.equals("link":
|
||||
// continue
|
||||
// Log.info("(l:" + str(child.sourceline) + ") '" + str(child.tag) + "' values=" + str(child.attrib));
|
||||
// Log.error("(l:" + str(child.sourceline) + ") Parsing error Unknow NODE : '" + str(child.tag) + "' availlable:[remote,include,default,project,option,link]")
|
||||
@ -533,4 +560,6 @@ public class Manifest {
|
||||
// // now we parse all sub repo:
|
||||
// for elem in includes:
|
||||
// tag_clear(elem["path"])
|
||||
//
|
||||
//
|
||||
|
||||
}
|
||||
|
14
src/org/atriasoft/island/Tools.java
Normal file
14
src/org/atriasoft/island/Tools.java
Normal file
@ -0,0 +1,14 @@
|
||||
package org.atriasoft.island;
|
||||
|
||||
import org.atriasoft.island.model.ProjectConfig;
|
||||
|
||||
public class Tools {
|
||||
|
||||
|
||||
public static String get_list_base_display(final int id, final int count, final ProjectConfig elem) {
|
||||
if (!Env.get_display_folder_instead_of_git_name()) {
|
||||
return id + "/" + count + " : " + elem.getName();
|
||||
}
|
||||
return id + "/" + count + " : " + elem.getPath();
|
||||
}
|
||||
}
|
@ -8,12 +8,14 @@ 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 implements ActionInterface {
|
||||
public class IslandActionCheckout extends ActionInterface {
|
||||
|
||||
@Override
|
||||
public String help() {
|
||||
@ -21,7 +23,7 @@ public class islandActionCheckout implements ActionInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add_specific_arguments(Arguments myArgs, String section) {
|
||||
public void add_specific_arguments(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)");
|
||||
}
|
||||
@ -33,18 +35,18 @@ public class islandActionCheckout implements ActionInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(List<ArgElement> _arguments) throws ActionException {
|
||||
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() + "'");
|
||||
Log.info("find remote name{ '" + elem.getArg() + "'");
|
||||
argument_remote_name = elem.getArg();
|
||||
} else if (elem.getOptionName().equals("branch")) {
|
||||
branch_to_checkout = elem.getArg()
|
||||
branch_to_checkout = elem.getArg();
|
||||
} else {
|
||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'");
|
||||
Log.error("Wrong argument{ '" + elem.getOptionName() + "' '" + elem.getArg() + "'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -53,27 +55,30 @@ public class islandActionCheckout implements ActionInterface {
|
||||
|
||||
ConfigManifest configuration = Config.getUniqueConfig();
|
||||
|
||||
// update the local configuration file:
|
||||
// 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() + "'");
|
||||
Log.critical("Missing manifest file { '" + file_source_manifest.toAbsolutePath() + "'");
|
||||
}
|
||||
Manifest mani = new Manifest(file_source_manifest);
|
||||
|
||||
all_project = mani.getAllConfigs();
|
||||
Log.info("checkout of: " + str(len(all_project)) + " projects")
|
||||
id_element = 0
|
||||
have_error = false
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
if status.checkout_elem(elem, argument_remote_name, branch_to_checkout, base_display) == false:
|
||||
have_error = true
|
||||
if have_error == true:
|
||||
return env.ret_action_fail
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
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;
|
||||
}
|
||||
|
||||
}
|
214
src/org/atriasoft/island/actions/Status.java
Normal file
214
src/org/atriasoft/island/actions/Status.java
Normal file
@ -0,0 +1,214 @@
|
||||
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 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.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;
|
||||
|
||||
public class Log {
|
||||
private static final boolean FORCE = true;
|
||||
private static final String LIB_NAME = "island";
|
||||
private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME);
|
||||
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL);
|
||||
private static final boolean PRINT_ERROR = Logger.getNeedPrint(LIB_NAME, LogLevel.ERROR);
|
||||
private static final boolean PRINT_WARNING = Logger.getNeedPrint(LIB_NAME, LogLevel.WARNING);
|
||||
private static final boolean PRINT_INFO = Logger.getNeedPrint(LIB_NAME, LogLevel.INFO);
|
||||
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG);
|
||||
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LIB_NAME, LogLevel.VERBOSE);
|
||||
private static final boolean PRINT_TODO = Logger.getNeedPrint(LIB_NAME, LogLevel.TODO);
|
||||
private static final boolean PRINT_PRINT = Logger.getNeedPrint(LIB_NAME, LogLevel.PRINT);
|
||||
private static final String LIB_NAME_DRAW = Logger.getDrawableName(Log.LIB_NAME);
|
||||
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.CRITICAL);
|
||||
private static final boolean PRINT_ERROR = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.ERROR);
|
||||
private static final boolean PRINT_WARNING = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.WARNING);
|
||||
private static final boolean PRINT_INFO = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.INFO);
|
||||
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.DEBUG);
|
||||
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.VERBOSE);
|
||||
private static final boolean PRINT_TODO = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.TODO);
|
||||
private static final boolean PRINT_PRINT = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.PRINT);
|
||||
|
||||
public static void critical(final String data) {
|
||||
if (PRINT_CRITICAL) {
|
||||
Logger.critical(LIB_NAME_DRAW, data);
|
||||
if (Log.PRINT_CRITICAL || Log.FORCE) {
|
||||
Logger.critical(Log.LIB_NAME_DRAW, data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void critical(final String data, final Exception e) {
|
||||
e.printStackTrace();
|
||||
if (PRINT_CRITICAL) {
|
||||
Logger.critical(LIB_NAME_DRAW, data + " : " + e.getMessage());
|
||||
if (Log.PRINT_CRITICAL || Log.FORCE) {
|
||||
Logger.critical(Log.LIB_NAME_DRAW, data + " : " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void debug(final String data) {
|
||||
if (PRINT_DEBUG) {
|
||||
Logger.debug(LIB_NAME_DRAW, data);
|
||||
if (Log.PRINT_DEBUG || Log.FORCE) {
|
||||
Logger.debug(Log.LIB_NAME_DRAW, data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void error(final String data) {
|
||||
if (PRINT_ERROR) {
|
||||
Logger.error(LIB_NAME_DRAW, data);
|
||||
if (Log.PRINT_ERROR || Log.FORCE) {
|
||||
Logger.error(Log.LIB_NAME_DRAW, data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void info(final String data) {
|
||||
if (PRINT_INFO) {
|
||||
Logger.info(LIB_NAME_DRAW, data);
|
||||
if (Log.PRINT_INFO || Log.FORCE) {
|
||||
Logger.info(Log.LIB_NAME_DRAW, data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void print(final String data) {
|
||||
if (PRINT_PRINT) {
|
||||
Logger.print(LIB_NAME_DRAW, data);
|
||||
if (Log.PRINT_PRINT || Log.FORCE) {
|
||||
Logger.print(Log.LIB_NAME_DRAW, data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void todo(final String data) {
|
||||
if (PRINT_TODO) {
|
||||
Logger.todo(LIB_NAME_DRAW, data);
|
||||
if (Log.PRINT_TODO || Log.FORCE) {
|
||||
Logger.todo(Log.LIB_NAME_DRAW, data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void verbose(final String data) {
|
||||
if (PRINT_VERBOSE) {
|
||||
Logger.verbose(LIB_NAME_DRAW, data);
|
||||
if (Log.PRINT_VERBOSE || Log.FORCE) {
|
||||
Logger.verbose(Log.LIB_NAME_DRAW, data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void warning(final String data) {
|
||||
if (PRINT_WARNING) {
|
||||
Logger.warning(LIB_NAME_DRAW, data);
|
||||
if (Log.PRINT_WARNING || Log.FORCE) {
|
||||
Logger.warning(Log.LIB_NAME_DRAW, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,19 +5,19 @@ import java.util.List;
|
||||
import org.atriasoft.death.ArgElement;
|
||||
import org.atriasoft.death.Arguments;
|
||||
|
||||
public interface ActionInterface {
|
||||
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)
|
||||
*/
|
||||
String help();
|
||||
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
|
||||
*/
|
||||
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
|
||||
* @return Have parameter without arguments
|
||||
*/
|
||||
default boolean haveUnknowArgument() {
|
||||
public boolean haveUnknowArgument() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ public interface ActionInterface {
|
||||
* @param myArgs (death.Arguments) Argument manager
|
||||
* @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.
|
||||
@ -44,9 +44,9 @@ public interface ActionInterface {
|
||||
* -11 : ACTION execution system error
|
||||
* -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();
|
||||
|
||||
|
||||
|
||||
|
@ -21,35 +21,35 @@ public class ConfigManifest {
|
||||
}
|
||||
|
||||
public String getRepo() {
|
||||
return repo;
|
||||
return this.repo;
|
||||
}
|
||||
public void setRepo(String repo) {
|
||||
public void setRepo(final String repo) {
|
||||
this.repo = repo;
|
||||
}
|
||||
public String getBranch() {
|
||||
return branch;
|
||||
return this.branch;
|
||||
}
|
||||
public void setBranch(String branch) {
|
||||
public void setBranch(final String branch) {
|
||||
this.branch = branch;
|
||||
}
|
||||
public String getManifestName() {
|
||||
return manifestName;
|
||||
return this.manifestName;
|
||||
}
|
||||
public void setManifestName(String manifestName) {
|
||||
public void setManifestName(final String manifestName) {
|
||||
this.manifestName = manifestName;
|
||||
}
|
||||
public List<Volatile> getVolatiles() {
|
||||
return volatiles;
|
||||
return this.volatiles;
|
||||
}
|
||||
public void setVolatiles(List<Volatile> volatiles) {
|
||||
public void setVolatiles(final List<Volatile> volatiles) {
|
||||
this.volatiles = volatiles;
|
||||
}
|
||||
public void addVolatile(String gitAddress, String path) {
|
||||
public void addVolatile(final String gitAddress, final String path) {
|
||||
rmVolatile(path);
|
||||
this.volatiles.add(new Volatile(gitAddress, path));
|
||||
}
|
||||
private void rmVolatile(String path) {
|
||||
ListIterator<Volatile> it = volatiles.listIterator();
|
||||
private void rmVolatile(final String path) {
|
||||
ListIterator<Volatile> it = this.volatiles.listIterator();
|
||||
while (it.hasNext()) {
|
||||
Volatile elem = it.next();
|
||||
if (elem.path.equals(path)) {
|
||||
@ -58,29 +58,29 @@ public class ConfigManifest {
|
||||
}
|
||||
}
|
||||
public List<Link> getCurentLink() {
|
||||
return curentLink;
|
||||
return this.curentLink;
|
||||
}
|
||||
public void setCurentLink(List<Link> curentLink) {
|
||||
public void setCurentLink(final List<Link> curentLink) {
|
||||
this.curentLink = curentLink;
|
||||
}
|
||||
public void addLink(String source, String destination) {
|
||||
public void addLink(final String source, final String destination) {
|
||||
rmLink(destination);
|
||||
this.curentLink.add(new Link(source, destination));
|
||||
}
|
||||
private void rmLink(String destination) {
|
||||
ListIterator<Link> it = curentLink.listIterator();
|
||||
private void rmLink(final String destination) {
|
||||
ListIterator<Link> it = this.curentLink.listIterator();
|
||||
while (it.hasNext()) {
|
||||
Link elem = it.next();
|
||||
if (elem.destination.equals(destination)) {
|
||||
if (elem.getDestination().equals(destination)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ConfigManifest load() {
|
||||
return load(Env.get_island_path_config());
|
||||
return ConfigManifest.load(Env.get_island_path_config());
|
||||
}
|
||||
public static ConfigManifest load(Path path) {
|
||||
public static ConfigManifest load(final Path path) {
|
||||
ConfigManifest[] root = null;
|
||||
try {
|
||||
root = Exml.parse(path, ConfigManifest.class, "config-island");
|
||||
@ -96,7 +96,7 @@ public class ConfigManifest {
|
||||
public void store() {
|
||||
store(Env.get_island_path_config());
|
||||
}
|
||||
public void store(Path path) {
|
||||
public void store(final Path path) {
|
||||
Log.todo("unimplemented model...");
|
||||
}
|
||||
|
||||
@ -104,13 +104,13 @@ 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:
|
||||
// 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:
|
||||
// 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:
|
||||
// with open(Env.get_island_path_config()) as json_file:
|
||||
// data = json.load(json_file)
|
||||
// if "repo" in data.keys():
|
||||
// this.repo = data["repo"]
|
||||
@ -135,7 +135,7 @@ public class ConfigManifest {
|
||||
// data["manifest_name"] = this.manifestName
|
||||
// data["volatiles"] = this.volatiles
|
||||
// data["link"] = this.curentLink
|
||||
// with open(env.get_island_path_config(), 'w') as outfile:
|
||||
// with open(Env.get_island_path_config(), 'w') as outfile:
|
||||
// json.dump(data, outfile, indent=4)
|
||||
// return true
|
||||
// return false
|
||||
@ -184,7 +184,7 @@ public class ConfigManifest {
|
||||
// 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.path = new Path("." + Env.get_system_base_name(), "manifest") //Env.get_island_path_manifest()
|
||||
// conf.branch = "master"
|
||||
// conf.volatile = false
|
||||
// conf.remotes = [
|
||||
|
@ -1,9 +1,9 @@
|
||||
package org.atriasoft.island.model;
|
||||
|
||||
class Link {
|
||||
public String source;
|
||||
public String destination;
|
||||
public Link(String source, String destination) {
|
||||
public class Link {
|
||||
private String source;
|
||||
private String destination;
|
||||
public Link(final String source, final String destination) {
|
||||
this.source = source;
|
||||
this.destination = destination;
|
||||
}
|
||||
@ -11,5 +11,17 @@ class Link {
|
||||
this.source = "";
|
||||
this.destination = "";
|
||||
}
|
||||
public String getSource() {
|
||||
return this.source;
|
||||
}
|
||||
public void setSource(final String source) {
|
||||
this.source = source;
|
||||
}
|
||||
public String getDestination() {
|
||||
return this.destination;
|
||||
}
|
||||
public void setDestination(final String destination) {
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
}
|
25
src/org/atriasoft/island/model/MirrorConfig.java
Normal file
25
src/org/atriasoft/island/model/MirrorConfig.java
Normal file
@ -0,0 +1,25 @@
|
||||
package org.atriasoft.island.model;
|
||||
|
||||
public class MirrorConfig {
|
||||
private String name;
|
||||
private String fetch;
|
||||
|
||||
public MirrorConfig(final String name, final String fetch) {
|
||||
this.name = name;
|
||||
this.fetch = fetch;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getFetch() {
|
||||
return this.fetch;
|
||||
}
|
||||
public void setFetch(final String fetch) {
|
||||
this.fetch = fetch;
|
||||
}
|
||||
|
||||
}
|
57
src/org/atriasoft/island/model/ProjectConfig.java
Normal file
57
src/org/atriasoft/island/model/ProjectConfig.java
Normal file
@ -0,0 +1,57 @@
|
||||
package org.atriasoft.island.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ProjectConfig {
|
||||
private String name;
|
||||
private String path;
|
||||
private String tag;
|
||||
private boolean volatileElement = false;
|
||||
private List<RemoteConfig> remotes = new ArrayList<>();
|
||||
RemoteConfig selectRemotes = null;
|
||||
public ProjectConfig(final String name, final String path, final String tag) {
|
||||
this.name = name;
|
||||
this.path = path;
|
||||
this.tag = tag;
|
||||
}
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
public void setPath(final String path) {
|
||||
this.path = path;
|
||||
}
|
||||
public String getTag() {
|
||||
return this.tag;
|
||||
}
|
||||
public void setTag(final String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
public void setBranch(final String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
public List<RemoteConfig> getRemotes() {
|
||||
return this.remotes;
|
||||
}
|
||||
public void setRemotes(final List<RemoteConfig> remotes) {
|
||||
this.remotes = remotes;
|
||||
}
|
||||
public RemoteConfig getSelectRemotes() {
|
||||
return this.selectRemotes;
|
||||
}
|
||||
public void setSelectRemotes(final RemoteConfig selectRemotes) {
|
||||
this.selectRemotes = selectRemotes;
|
||||
}
|
||||
public boolean isVolatile() {
|
||||
return this.volatileElement;
|
||||
}
|
||||
public void setVolatile(final boolean volatileElement) {
|
||||
this.volatileElement = volatileElement;
|
||||
}
|
||||
}
|
40
src/org/atriasoft/island/model/RemoteConfig.java
Normal file
40
src/org/atriasoft/island/model/RemoteConfig.java
Normal file
@ -0,0 +1,40 @@
|
||||
package org.atriasoft.island.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RemoteConfig {
|
||||
private String name;
|
||||
private String fetch;
|
||||
List<MirrorConfig> mirror;
|
||||
|
||||
public RemoteConfig(final String name, final String fetch, final List<MirrorConfig> mirror) {
|
||||
this.name = name;
|
||||
this.fetch = fetch;
|
||||
this.mirror = mirror;
|
||||
}
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getFetch() {
|
||||
return this.fetch;
|
||||
}
|
||||
public void setFetch(final String fetch) {
|
||||
this.fetch = fetch;
|
||||
}
|
||||
public List<MirrorConfig> getMirror() {
|
||||
return this.mirror;
|
||||
}
|
||||
public void setMirror(final List<MirrorConfig> mirror) {
|
||||
this.mirror = mirror;
|
||||
}
|
||||
@Override
|
||||
public RemoteConfig clone() {
|
||||
// TODO Auto-generated method stub
|
||||
return new RemoteConfig(this.name, this.fetch, new ArrayList<>(this.mirror));
|
||||
}
|
||||
|
||||
}
|
40
src/org/atriasoft/island/model/RepositoryConfig.java
Normal file
40
src/org/atriasoft/island/model/RepositoryConfig.java
Normal file
@ -0,0 +1,40 @@
|
||||
package org.atriasoft.island.model;
|
||||
|
||||
public class RepositoryConfig {
|
||||
private String remote = "origin";
|
||||
private String revision = "master";
|
||||
private boolean sync = false;
|
||||
|
||||
public RepositoryConfig(final String remote, final String revision, final boolean sync) {
|
||||
this.remote = remote;
|
||||
this.revision = revision;
|
||||
this.sync = sync;
|
||||
}
|
||||
public RepositoryConfig() {
|
||||
|
||||
}
|
||||
public String getRemote() {
|
||||
return this.remote;
|
||||
}
|
||||
public void setRemote(final String remote) {
|
||||
this.remote = remote;
|
||||
}
|
||||
public String getRevision() {
|
||||
return this.revision;
|
||||
}
|
||||
public void setRevision(final String revision) {
|
||||
this.revision = revision;
|
||||
}
|
||||
public boolean isSync() {
|
||||
return this.sync;
|
||||
}
|
||||
public void setSync(final boolean sync) {
|
||||
this.sync = sync;
|
||||
}
|
||||
@Override
|
||||
public RepositoryConfig clone() {
|
||||
// TODO Auto-generated method stub
|
||||
return new RepositoryConfig(this.remote, this.revision, this.sync);
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package org.atriasoft.island.model;
|
||||
|
||||
class Volatile {
|
||||
public class Volatile {
|
||||
public String gitAddress;
|
||||
public String path;
|
||||
public Volatile(String gitAddress, String path) {
|
||||
public Volatile(final String gitAddress, final String path) {
|
||||
this.gitAddress = gitAddress;
|
||||
this.path = path;
|
||||
}
|
||||
|
@ -48,11 +48,11 @@ public void execute(_arguments):
|
||||
cmd += elem.getArg() + " "
|
||||
|
||||
// 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:
|
||||
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
|
||||
@ -68,7 +68,7 @@ public void execute(_arguments):
|
||||
Log.info("execute command : " + 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)
|
||||
git_repo_path = new Path(Env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == false:
|
||||
Log.info("" + base_display + "\r\t\t\t\t\t\t\t\t\t" + " (not download)")
|
||||
continue
|
||||
|
@ -49,22 +49,22 @@ public void execute(_arguments):
|
||||
argument_amend = ""
|
||||
argument_all = ""
|
||||
for elem in _arguments:
|
||||
if elem.getOptionName() == "message":
|
||||
if elem.getOptionName().equals("message":
|
||||
Log.info("find message: '" + elem.getArg() + "'")
|
||||
argument_message = " --message \"" + elem.getArg() + "\" ";
|
||||
} else if elem.getOptionName() == "all":
|
||||
} else if elem.getOptionName().equals("all":
|
||||
argument_all = " --all "
|
||||
} else if elem.getOptionName() == "amend":
|
||||
} else if elem.getOptionName().equals("amend":
|
||||
argument_amend = " --amend "
|
||||
else:
|
||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||
|
||||
// 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:
|
||||
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
mani = manifest.Manifest(file_source_manifest)
|
||||
@ -76,7 +76,7 @@ public void execute(_arguments):
|
||||
id_element += 1
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
Log.info("commit: " + base_display)
|
||||
git_repo_path = new Path(env.get_island_root_path(), elem.path)
|
||||
git_repo_path = new Path(Env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == false:
|
||||
Log.error("can not commit project that not exist")
|
||||
continue
|
||||
|
@ -45,18 +45,18 @@ public void add_specific_arguments(my_args, section):
|
||||
public void execute(_arguments):
|
||||
argument_remote_name = ""
|
||||
for elem in _arguments:
|
||||
if elem.getOptionName() == "remote":
|
||||
if elem.getOptionName().equals("remote":
|
||||
Log.info("find remote name: '" + elem.getArg() + "'")
|
||||
argument_remote_name = elem.getArg()
|
||||
else:
|
||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||
|
||||
// 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:
|
||||
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
mani = manifest.Manifest(file_source_manifest)
|
||||
@ -70,7 +70,7 @@ public void execute(_arguments):
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
// configure remote name:
|
||||
if argument_remote_name == "":
|
||||
if argument_remote_name.equals("":
|
||||
argument_remote_name = elem.select_remote["name"]
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
Log.info("deliver-push: " + base_display)
|
||||
|
@ -48,21 +48,21 @@ public void execute(_arguments):
|
||||
argument_from = None
|
||||
argument_to = None
|
||||
for elem in _arguments:
|
||||
if elem.getOptionName() == "from":
|
||||
if elem.getOptionName().equals("from":
|
||||
Log.info("find source branch name: '" + elem.getArg() + "'")
|
||||
argument_from = elem.getArg()
|
||||
} else if elem.getOptionName() == "to":
|
||||
} else if elem.getOptionName().equals("to":
|
||||
Log.info("find destination branch name: '" + elem.getArg() + "'")
|
||||
argument_to = elem.getArg()
|
||||
else:
|
||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||
|
||||
// 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:
|
||||
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
|
||||
@ -94,10 +94,10 @@ public void execute(_arguments):
|
||||
id_element += 1
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
Log.info("deliver: ========================================================================")
|
||||
Log.info("deliver: == " + base_display)
|
||||
Log.info("deliver:.equals(" + base_display)
|
||||
Log.info("deliver: ========================================================================")
|
||||
|
||||
git_repo_path = new Path(env.get_island_root_path(), elem.path)
|
||||
git_repo_path = new Path(Env.get_island_root_path(), elem.path)
|
||||
// Check the validity of the version,
|
||||
version_description, add_in_version_management = status.get_current_version_repo(git_repo_path)
|
||||
if version_description == None:
|
||||
@ -116,7 +116,7 @@ public void execute(_arguments):
|
||||
if new_version_description == None:
|
||||
continue
|
||||
// merge branch
|
||||
if mani.deliver_mode == "merge":
|
||||
if mani.deliver_mode.equals("merge":
|
||||
merge_force = true
|
||||
else:
|
||||
merge_force = false
|
||||
|
@ -45,20 +45,20 @@ public void add_specific_arguments(my_args, section):
|
||||
public void execute(_arguments):
|
||||
argument_remote_name = ""
|
||||
for elem in _arguments:
|
||||
if elem.getOptionName() == "remote":
|
||||
if elem.getOptionName().equals("remote":
|
||||
Log.info("find remote name: '" + elem.getArg() + "'")
|
||||
argument_remote_name = elem.getArg()
|
||||
else:
|
||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||
|
||||
// check system is OK
|
||||
manifest.check_lutin_is_init()
|
||||
Manifest.checkIsInit();
|
||||
|
||||
Log.info("fetch manifest : '" + str(env.get_island_path_manifest()) + "'")
|
||||
commands.fetch(env.get_island_path_manifest(), "origin")
|
||||
Log.info("fetch manifest : '" + str(Env.get_island_path_manifest()) + "'")
|
||||
commands.fetch(Env.get_island_path_manifest(), "origin")
|
||||
|
||||
configuration = config.get_unique_config()
|
||||
file_source_manifest = new Path(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||
ConfigManifest configuration = Config.getUniqueConfig();
|
||||
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)
|
||||
@ -69,14 +69,14 @@ public void execute(_arguments):
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
// configure remote name:
|
||||
if argument_remote_name == "":
|
||||
if argument_remote_name.equals("":
|
||||
argument_remote_name = elem.select_remote["name"]
|
||||
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
Log.info("fetch: " + 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)
|
||||
git_repo_path = new Path(Env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == false:
|
||||
Log.error("can not fetch project that not exist")
|
||||
continue
|
||||
|
@ -51,20 +51,20 @@ public void execute(_arguments):
|
||||
manifest_name = "default.xml"
|
||||
address_manifest = ""
|
||||
for elem in _arguments:
|
||||
if elem.getOptionName() == "branch":
|
||||
if elem.getOptionName().equals("branch":
|
||||
Log.info("find branch name: '" + elem.getArg() + "'")
|
||||
branch = elem.getArg()
|
||||
} else if elem.getOptionName() == "manifest":
|
||||
} else if elem.getOptionName().equals("manifest":
|
||||
Log.info("find mmanifest name: '" + elem.getArg() + "'")
|
||||
manifest_name = elem.getArg()
|
||||
} else if elem.getOptionName() == "":
|
||||
} else if elem.getOptionName().equals("":
|
||||
if address_manifest != "":
|
||||
Log.error("Manifest adress already set : '" + address_manifest + "' !!! '" + elem.getArg() + "'")
|
||||
address_manifest = elem.getArg()
|
||||
else:
|
||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||
|
||||
if address_manifest == "":
|
||||
if address_manifest.equals("":
|
||||
Log.error("Init: Missing manifest name")
|
||||
|
||||
Log.info("Init with: '" + address_manifest + "' branch='" + branch + "' name of manifest='" + manifest_name + "'")
|
||||
@ -72,9 +72,9 @@ public void execute(_arguments):
|
||||
|
||||
// check if .XXX exist (create it if needed)
|
||||
if manifest.is_lutin_init() == true:
|
||||
Log.error("System already init: path already exist: '" + str(env.get_island_path()) + "'")
|
||||
Log.error("System already init: path already exist: '" + str(Env.get_island_path()) + "'")
|
||||
|
||||
tools.create_directory(env.get_island_path())
|
||||
tools.create_directory(Env.get_island_path())
|
||||
// check if the git of the manifest if availlable
|
||||
|
||||
// create the file configuration:
|
||||
@ -85,7 +85,7 @@ public void execute(_arguments):
|
||||
conf.store()
|
||||
|
||||
Log.info("Clone the manifest")
|
||||
ret_values = commands.clone(env.get_island_path_manifest(), address_manifest, branch_name=branch)
|
||||
ret_values = commands.clone(Env.get_island_path_manifest(), address_manifest, branch_name=branch)
|
||||
|
||||
if ret_values == false:
|
||||
Log.info("'" + str(ret_values) + "'")
|
||||
|
@ -48,24 +48,24 @@ public void execute(_arguments):
|
||||
argument_remote_name = ""
|
||||
branch_to_checkout = ""
|
||||
for elem in _arguments:
|
||||
if elem.getOptionName() == "remote":
|
||||
if elem.getOptionName().equals("remote":
|
||||
Log.info("find remote name: '" + elem.getArg() + "'")
|
||||
argument_remote_name = elem.getArg()
|
||||
} else if elem.getOptionName() == "branch":
|
||||
} else if elem.getOptionName().equals("branch":
|
||||
branch_to_checkout = elem.getArg()
|
||||
else:
|
||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||
|
||||
// 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()
|
||||
base_display = tools.get_list_base_display(0, 0, elem)
|
||||
if status.checkout_elem(elem, argument_remote_name, branch_to_checkout, base_display) == false:
|
||||
return env.ret_action_fail
|
||||
return Env.ret_action_fail
|
||||
|
||||
|
||||
|
||||
|
@ -48,11 +48,11 @@ public void execute(_arguments):
|
||||
Log.error("pull Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||
|
||||
// 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:
|
||||
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
|
||||
|
@ -52,11 +52,11 @@ public void execute(_arguments):
|
||||
Log.error("pull Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||
|
||||
// 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:
|
||||
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
|
||||
@ -72,27 +72,27 @@ public void execute(_arguments):
|
||||
Log.verbose("deliver-ckeck: " + base_display)
|
||||
if status.deliver_check(elem, argument_remote_name, 0, base_display, source_branch, destination_branch) == false:
|
||||
Log.error("Can not deliver a MANIFEST that is not ready to merge", crash=false)
|
||||
return env.ret_action_fail
|
||||
return Env.ret_action_fail
|
||||
|
||||
|
||||
all_tags = check_all_tags(mani)
|
||||
if all_tags == None:
|
||||
Log.error("Need the Tags are set in sub-repository", crash=false)
|
||||
return env.ret_action_fail
|
||||
return Env.ret_action_fail
|
||||
|
||||
|
||||
// deliver the manifest (if Needed ...)
|
||||
base_display = tools.get_list_base_display(0, 0, elem)
|
||||
|
||||
Log.info("manifest-deliver: ========================================================================")
|
||||
Log.info("manifest-deliver: == " + base_display)
|
||||
Log.info("manifest-deliver:.equals(" + base_display)
|
||||
Log.info("manifest-deliver: ========================================================================")
|
||||
|
||||
git_repo_path = new Path(env.get_island_root_path(), elem.path)
|
||||
git_repo_path = new Path(Env.get_island_root_path(), elem.path)
|
||||
// Check the validity of the version,
|
||||
version_description, add_in_version_management = status.get_current_version_repo(git_repo_path)
|
||||
if version_description == None:
|
||||
return env.ret_action_fail
|
||||
return Env.ret_action_fail
|
||||
Log.info("manifest-deliver: ==> version: " + str(version_description))
|
||||
|
||||
// go to the dev branch
|
||||
@ -106,7 +106,7 @@ public void execute(_arguments):
|
||||
return
|
||||
// merge branch
|
||||
commands.checkout(git_repo_path, destination_branch)
|
||||
if mani.deliver_mode == "merge":
|
||||
if mani.deliver_mode.equals("merge":
|
||||
merge_force = true
|
||||
else:
|
||||
merge_force = false
|
||||
@ -147,7 +147,7 @@ public void check_all_tags(mani):
|
||||
Log.info(base_display + "\r\t\t\t\t\t\t\t\t\t" + " (Not Managed)")
|
||||
continue
|
||||
tags_comment = ""
|
||||
git_repo_path = new Path(env.get_island_root_path(), elem.path)
|
||||
git_repo_path = new Path(Env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == false:
|
||||
Log.error(base_display + volatile + "\r\t\t\t\t\t\t\t\t\t" + " (not download)", crash=false)
|
||||
check_have_error = true
|
||||
|
@ -47,17 +47,17 @@ public void execute(_arguments):
|
||||
argument_remote_name = ""
|
||||
argument_display_tag = false
|
||||
for elem in _arguments:
|
||||
if elem.getOptionName() == "tags":
|
||||
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()
|
||||
Manifest.checkIsInit();
|
||||
|
||||
configuration = config.get_unique_config()
|
||||
ConfigManifest configuration = Config.getUniqueConfig();
|
||||
elem = configuration.get_manifest_config()
|
||||
base_display = tools.get_list_base_display(0, 0, elem)
|
||||
ret = status.display_status(elem, argument_remote_name, argument_display_tag, 0, base_display)
|
||||
if ret != None:
|
||||
return env.ret_action_need_updtate
|
||||
return Env.ret_action_need_updtate
|
@ -47,14 +47,14 @@ public void execute(_arguments):
|
||||
Log.error("pull Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||
|
||||
// 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()) + "'")
|
||||
is_modify_manifest = commands.check_repository_is_modify(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())
|
||||
if is_modify_manifest == true:
|
||||
commands.fetch(env.get_island_path_manifest(), "origin")
|
||||
commands.fetch(Env.get_island_path_manifest(), "origin")
|
||||
else:
|
||||
commands.pull(env.get_island_path_manifest(), "origin")
|
||||
commands.pull(Env.get_island_path_manifest(), "origin")
|
||||
|
@ -45,18 +45,18 @@ public void add_specific_arguments(_my_args, _section):
|
||||
public void execute(_arguments):
|
||||
argument_remote_name = ""
|
||||
for elem in _arguments:
|
||||
if elem.getOptionName() == "remote":
|
||||
if elem.getOptionName().equals("remote":
|
||||
Log.info("find remote name: '" + elem.getArg() + "'")
|
||||
argument_remote_name = elem.getArg()
|
||||
else:
|
||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||
|
||||
// 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:
|
||||
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
mani = manifest.Manifest(file_source_manifest)
|
||||
@ -70,7 +70,7 @@ public void execute(_arguments):
|
||||
Log.info("push: " + 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)
|
||||
git_repo_path = new Path(Env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == false:
|
||||
Log.error("can not push project that not exist")
|
||||
continue
|
||||
@ -91,9 +91,9 @@ public void execute(_arguments):
|
||||
for elem_branch in list_branch:
|
||||
if len(elem_branch.split(" -> ")) != 1:
|
||||
continue
|
||||
if elem_branch[2:10] == "remotes/":
|
||||
if elem_branch[2:10].equals("remotes/":
|
||||
elem_branch = elem_branch[:2] + elem_branch[10:]
|
||||
if elem_branch[:2] == "* ":
|
||||
if elem_branch[:2].equals("* ":
|
||||
list_branch2.append([elem_branch[2:], true])
|
||||
select_branch = elem_branch[2:]
|
||||
else:
|
||||
|
@ -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() == "remote":
|
||||
Log.info("find remote name: '" + elem.getArg() + "'")
|
||||
argument_remote_name = elem.getArg()
|
||||
} else if elem.getOptionName() == "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
|
||||
|
||||
|
@ -39,53 +39,53 @@ public void add_specific_arguments(my_args, section):
|
||||
//#
|
||||
//# @return error value [0 .. 50] the <0 value is reserved system ==> else, what you want.
|
||||
//# None : No error (return program out 0)
|
||||
//# -5 : env.ret_manifest_is_not_existing : Manifest does not exit
|
||||
//# -10 : env.ret_action_is_not_existing : ACTION is not existing
|
||||
//# -11 : env.ret_action_executing_system_error : ACTION execution system error
|
||||
//# -12 : env.ret_action_wrong_parameters : ACTION Wrong parameters
|
||||
//# -13 : env.ret_action_partial_done : ACTION partially done
|
||||
//# -5 : Env.ret_manifest_is_not_existing : Manifest does not exit
|
||||
//# -10 : Env.ret_action_is_not_existing : ACTION is not existing
|
||||
//# -11 : Env.ret_action_executing_system_error : ACTION execution system error
|
||||
//# -12 : Env.ret_action_wrong_parameters : ACTION Wrong parameters
|
||||
//# -13 : Env.ret_action_partial_done : ACTION partially done
|
||||
//#
|
||||
public void execute(_arguments):
|
||||
reset_instead_of_rebase = false
|
||||
for elem in _arguments:
|
||||
if elem.getOptionName() == "rebase":
|
||||
if elem.getOptionName().equals("rebase":
|
||||
reset_instead_of_rebase = true
|
||||
Log.info("==> Request reset instead of rebase")
|
||||
else:
|
||||
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
|
||||
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()) + "'")
|
||||
is_modify_manifest = commands.check_repository_is_modify(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())
|
||||
if is_modify_manifest == true:
|
||||
Log.warning("Manifest is modify")
|
||||
else:
|
||||
ret_track = commands.get_current_tracking_branch(env.get_island_path_manifest())
|
||||
is_forward = commands.is_forward(env.get_island_path_manifest(), ret_track)
|
||||
ret_track = commands.get_current_tracking_branch(Env.get_island_path_manifest())
|
||||
is_forward = commands.is_forward(Env.get_island_path_manifest(), ret_track)
|
||||
if is_forward == true:
|
||||
// fetch the repository
|
||||
Log.warning("sync-local: Not update ==> the MANIFEST is forward the remote branch " + str(commands.get_forward(env.get_island_path_manifest(), ret_track)))
|
||||
Log.warning("sync-local: Not update ==> the MANIFEST is forward the remote branch " + str(commands.get_forward(Env.get_island_path_manifest(), ret_track)))
|
||||
else:
|
||||
Log.verbose("Check behind:")
|
||||
is_behind = commands.is_behind(env.get_island_path_manifest(), ret_track)
|
||||
is_behind = commands.is_behind(Env.get_island_path_manifest(), ret_track)
|
||||
if is_behind == false:
|
||||
// fetch the repository
|
||||
Log.info("sync-local: MANIFEST is up-to-date")
|
||||
else:
|
||||
if reset_instead_of_rebase == true:
|
||||
Log.info("sync-local: MANIFEST Reset to " + ret_track)
|
||||
commands.reset_hard(env.get_island_path_manifest(), ret_track)
|
||||
commands.reset_hard(Env.get_island_path_manifest(), ret_track)
|
||||
else:
|
||||
Log.info("sync-local: MANIFEST Rebase to " + ret_track)
|
||||
commands.rebase(env.get_island_path_manifest(), ret_track)
|
||||
commands.rebase(Env.get_island_path_manifest(), ret_track)
|
||||
|
||||
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:
|
||||
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'", ret_value=env.ret_manifest_is_not_existing)
|
||||
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'", ret_value=Env.ret_manifest_is_not_existing)
|
||||
|
||||
mani = manifest.Manifest(file_source_manifest)
|
||||
|
||||
@ -99,7 +99,7 @@ public void execute(_arguments):
|
||||
Log.info("----------------------------------------------------------------")
|
||||
Log.info("sync-local: " + base_display)
|
||||
//Log.debug("elem : " + str(elem))
|
||||
git_repo_path = new Path(env.get_island_root_path(), elem.path)
|
||||
git_repo_path = new Path(Env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == false:
|
||||
// The Repository does not exist ==> Nothing to do...
|
||||
Log.warning("sync-local: ==> Not download")
|
||||
@ -148,7 +148,7 @@ public void execute(_arguments):
|
||||
Log.info(" ***********************************************************")
|
||||
Log.info(" ** local sync partial warning on " + str(count_error) + " repository")
|
||||
Log.info(" ***********************************************************")
|
||||
return env.ret_action_partial_done
|
||||
return Env.ret_action_partial_done
|
||||
|
||||
//# Update the links:
|
||||
have_error = update_links.update(configuration, mani, "sync-local")
|
||||
|
@ -52,27 +52,27 @@ public void add_specific_arguments(my_args, section):
|
||||
public void execute(_arguments):
|
||||
just_download = false
|
||||
for elem in _arguments:
|
||||
if elem.getOptionName() == "download":
|
||||
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.check_lutin_is_init()
|
||||
Manifest.checkIsInit();
|
||||
|
||||
configuration = config.get_unique_config()
|
||||
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())
|
||||
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")
|
||||
commands.fetch(Env.get_island_path_manifest(), "origin")
|
||||
else:
|
||||
commands.pull(env.get_island_path_manifest(), "origin")
|
||||
commands.pull(Env.get_island_path_manifest(), "origin")
|
||||
|
||||
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:
|
||||
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
|
||||
@ -87,7 +87,7 @@ public void execute(_arguments):
|
||||
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)
|
||||
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:
|
||||
@ -96,7 +96,7 @@ public void execute(_arguments):
|
||||
address_manifest = ""
|
||||
//## example git@git.plouf.com:basic_folder
|
||||
address_manifest = elem.select_remote["fetch"]
|
||||
if elem.select_remote["fetch"][0:4] == "git@" \
|
||||
if elem.select_remote["fetch"][0:4].equals("git@" \
|
||||
and len(elem.select_remote["fetch"][4:].split(":")) <= 1:
|
||||
address_manifest += ":"
|
||||
else:
|
||||
@ -114,7 +114,7 @@ public void execute(_arguments):
|
||||
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] == "git@":
|
||||
if mirror["fetch"][0:4].equals("git@":
|
||||
cmd += ":"
|
||||
else:
|
||||
cmd += "/"
|
||||
@ -142,7 +142,7 @@ public void execute(_arguments):
|
||||
continue
|
||||
cmd = "git submodule update"
|
||||
ret = multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||
if ret[:16] == "Submodule path '":
|
||||
if ret[:16].equals("Submodule path '":
|
||||
//all is good ...
|
||||
Log.info(" " + ret)
|
||||
} else if ret != "" \
|
||||
|
@ -45,11 +45,11 @@ public void help_example():
|
||||
//#
|
||||
//# @return error value [0 .. 50] the <0 value is reserved system ==> else, what you want.
|
||||
//# None : No error (return program out 0)
|
||||
//# -5 : env.ret_manifest_is_not_existing : Manifest does not exit
|
||||
//# -10 : env.ret_action_is_not_existing : ACTION is not existing
|
||||
//# -11 : env.ret_action_executing_system_error : ACTION execution system error
|
||||
//# -12 : env.ret_action_wrong_parameters : ACTION Wrong parameters
|
||||
//# -13 : env.ret_action_partial_done : ACTION partially done
|
||||
//# -5 : Env.ret_manifest_is_not_existing : Manifest does not exit
|
||||
//# -10 : Env.ret_action_is_not_existing : ACTION is not existing
|
||||
//# -11 : Env.ret_action_executing_system_error : ACTION execution system error
|
||||
//# -12 : Env.ret_action_wrong_parameters : ACTION Wrong parameters
|
||||
//# -13 : Env.ret_action_partial_done : ACTION partially done
|
||||
//#
|
||||
public void execute(_arguments):
|
||||
if len(_arguments) == 0:
|
||||
@ -59,27 +59,27 @@ public void execute(_arguments):
|
||||
path = ""
|
||||
address_git = ""
|
||||
for elem in _arguments:
|
||||
if elem.getOptionName() == "git repository":
|
||||
if elem.getOptionName().equals("git repository":
|
||||
address_git = elem.getArg()
|
||||
} else if elem.getOptionName() == "path":
|
||||
} else if elem.getOptionName().equals("path":
|
||||
path = elem.getArg()
|
||||
else:
|
||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||
|
||||
if address_git == "":
|
||||
Log.error("volatile-add: Missing git repository address", env.ret_action_wrong_parameters)
|
||||
if address_git.equals("":
|
||||
Log.error("volatile-add: Missing git repository address", Env.ret_action_wrong_parameters)
|
||||
|
||||
Log.info("Add 'volatile' repository: '" + address_git + "' path='" + path + "'")
|
||||
|
||||
// check system is OK
|
||||
manifest.check_lutin_is_init()
|
||||
Manifest.checkIsInit();
|
||||
|
||||
// Update the current configuration:
|
||||
conf = config.get_unique_config()
|
||||
// TODO: Check if the local path does not exist in the manifest
|
||||
|
||||
if false == conf.add_volatile(address_git, path):
|
||||
return env.ret_action_executing_system_error
|
||||
return Env.ret_action_executing_system_error
|
||||
conf.store()
|
||||
return None
|
||||
|
||||
|
@ -29,18 +29,18 @@ public void help():
|
||||
//#
|
||||
//# @return error value [0 .. 50] the <0 value is reserved system ==> else, what you want.
|
||||
//# None : No error (return program out 0)
|
||||
//# -5 : env.ret_manifest_is_not_existing : Manifest does not exit
|
||||
//# -10 : env.ret_action_is_not_existing : ACTION is not existing
|
||||
//# -11 : env.ret_action_executing_system_error : ACTION execution system error
|
||||
//# -12 : env.ret_action_wrong_parameters : ACTION Wrong parameters
|
||||
//# -13 : env.ret_action_partial_done : ACTION partially done
|
||||
//# -5 : Env.ret_manifest_is_not_existing : Manifest does not exit
|
||||
//# -10 : Env.ret_action_is_not_existing : ACTION is not existing
|
||||
//# -11 : Env.ret_action_executing_system_error : ACTION execution system error
|
||||
//# -12 : Env.ret_action_wrong_parameters : ACTION Wrong parameters
|
||||
//# -13 : Env.ret_action_partial_done : ACTION partially done
|
||||
//#
|
||||
public void execute(_arguments):
|
||||
for elem in _arguments:
|
||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||
|
||||
// check system is OK
|
||||
manifest.check_lutin_is_init()
|
||||
Manifest.checkIsInit();
|
||||
|
||||
conf = config.get_unique_config()
|
||||
volatiles = conf.get_volatile()
|
||||
|
@ -18,87 +18,6 @@ from island import commands
|
||||
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):
|
||||
@ -106,7 +25,7 @@ public void deliver_check(elem, argument_remote_name, id_element, base_display,
|
||||
Log.debug("deliver-ckeck: " + base_display)
|
||||
Log.debug(" ==> check repo exist")
|
||||
// Check the repo exist
|
||||
git_repo_path = new Path(env.get_island_root_path(), elem.path)
|
||||
git_repo_path = new Path(Env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == false:
|
||||
Log.warning("deliver-ckeck: " + base_display + " ==> MUST be download")
|
||||
return false
|
||||
@ -169,98 +88,6 @@ public void deliver_check(elem, argument_remote_name, id_element, base_display,
|
||||
return deliver_availlable
|
||||
|
||||
|
||||
public void checkout_elem(elem, argument_remote_name, branch_to_checkout, base_display):
|
||||
Log.verbose("checkout : " + base_display)
|
||||
git_repo_path = new Path(env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == false:
|
||||
Log.warning("checkout " + base_display + " ==> repository does not exist ...")
|
||||
return false
|
||||
|
||||
// check if the repository is modify
|
||||
is_modify = commands.check_repository_is_modify(git_repo_path)
|
||||
if is_modify == true:
|
||||
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)
|
||||
|
||||
is_tag = false
|
||||
if branch_to_checkout == "__TAG__":
|
||||
branch_to_checkout = base_name_of_a_tagged_branch + str(elem.tag)
|
||||
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
|
||||
|
||||
// check if we have already checkout the branch before
|
||||
Log.verbose(" check : " + branch_to_checkout + " in " + str(list_branch_local))
|
||||
if branch_to_checkout in list_branch_local:
|
||||
cmd = "git checkout " + branch_to_checkout
|
||||
Log.verbose("execute : " + cmd)
|
||||
ret = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||
if ret[0] != 0 \
|
||||
and ret[1] != "" \
|
||||
and ret != false:
|
||||
Log.info("'" + str(ret) + "'")
|
||||
Log.error("checkout " + base_display + " ==> Can not checkout to the correct branch")
|
||||
return false
|
||||
Log.info("checkout " + base_display + " ==> switch branch")
|
||||
// TODO : Check the number of commit to the origin/XXX branch ....
|
||||
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 ...
|
||||
if is_tag == false:
|
||||
list_branch_remote = commands.get_list_branch_remote(git_repo_path)
|
||||
if elem.select_remote["name"] + "/" + branch_to_checkout in list_branch_remote:
|
||||
Log.info(" ==> find ...")
|
||||
else:
|
||||
Log.info("checkout " + base_display + " ==> NO remote branch")
|
||||
return true
|
||||
// checkout the new branch:
|
||||
cmd = "git checkout --quiet " + elem.select_remote["name"] + "/" + branch_to_checkout + " -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 branch")
|
||||
return false
|
||||
Log.info("checkout " + base_display + " ==> create new branch")
|
||||
return true
|
||||
// Checkout a specific tags:
|
||||
if elem.tag in list_tags:
|
||||
Log.info(" ==> find ...")
|
||||
else:
|
||||
Log.info("checkout " + base_display + " ==> NO remote tags")
|
||||
return true
|
||||
// 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 void get_current_version_repo(git_repo_path):
|
||||
@ -280,10 +107,10 @@ public void get_current_version_repo(git_repo_path):
|
||||
valid = true
|
||||
else:
|
||||
Log.info("!!! Must select in range " + str(["1", "2"]))
|
||||
if input1 == "1":
|
||||
if input1.equals("1":
|
||||
version_description = [0, 0, 0]
|
||||
add_in_version_management = true
|
||||
} else if input1 == "2":
|
||||
} else if input1.equals("2":
|
||||
Log.info("Continue Not managing for this repository")
|
||||
return (None, None)
|
||||
else:
|
||||
@ -358,16 +185,16 @@ public void create_new_version_repo(git_repo_path, version_description, add_in_v
|
||||
version_description.append(0)
|
||||
Log.info("update version: curent: " + str(version_description))
|
||||
// increment the version
|
||||
if input1 == "1":
|
||||
if input1.equals("1":
|
||||
version_description[0] += 1
|
||||
version_description[1] = 0
|
||||
version_description[2] = 0
|
||||
} else if input1 == "2":
|
||||
} else if input1.equals("2":
|
||||
version_description[1] += 1
|
||||
version_description[2] = 0
|
||||
} else if input1 == "3":
|
||||
} else if input1.equals("3":
|
||||
version_description[2] += 1
|
||||
} else if input1 == "4":
|
||||
} else if input1.equals("4":
|
||||
Log.info("No release for this repository")
|
||||
return None
|
||||
else:
|
||||
@ -379,7 +206,7 @@ public void create_new_version_repo(git_repo_path, version_description, add_in_v
|
||||
|
||||
public void deliver_push(elem, argument_remote_name, destination_branch, source_branch, base_display):
|
||||
// Check the repo exist
|
||||
git_repo_path = new Path(env.get_island_root_path(), elem.path)
|
||||
git_repo_path = new Path(Env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == false:
|
||||
Log.warning("deliver-push: " + base_display + " ==> MUST be download")
|
||||
return
|
||||
|
@ -20,7 +20,7 @@ public void update(configuration, mani, type_call):
|
||||
or len(mani.get_links()) != 0:
|
||||
Log.info(type_call + ": remove old links ...")
|
||||
for elem in configuration.get_links():
|
||||
base_path = new Path(env.get_island_root_path(), elem["destination"])
|
||||
base_path = new Path(Env.get_island_root_path(), elem["destination"])
|
||||
Log.info(type_call + ": link: " + str(base_path))
|
||||
if os.path.islink(base_path) == true:
|
||||
os.unlink(base_path)
|
||||
@ -30,8 +30,8 @@ public void update(configuration, mani, type_call):
|
||||
configuration.clear_links()
|
||||
Log.info(type_call + ": add new links ...")
|
||||
for elem in mani.get_links():
|
||||
base_path = new Path(env.get_island_root_path(), elem["destination"])
|
||||
source_path = new Path(env.get_island_root_path(), elem["source"])
|
||||
base_path = new Path(Env.get_island_root_path(), elem["destination"])
|
||||
source_path = new Path(Env.get_island_root_path(), elem["source"])
|
||||
Log.info(type_call + ": link: " + str(base_path))
|
||||
if os.path.exists(base_path) == true:
|
||||
Log.error(type_call + ": create link is not possible ==> path already exist", crash=false)
|
||||
|
@ -53,11 +53,11 @@ public void get_list_branch_meta(path_repository):
|
||||
if len(elem_branch.split(" -> ")) != 1:
|
||||
continue
|
||||
// separate the remote element
|
||||
if elem_branch[2:10] == "remotes/":
|
||||
if elem_branch[2:10].equals("remotes/":
|
||||
elem_branch = elem_branch[:2] + elem_branch[10:]
|
||||
is_remote = true
|
||||
// separate select branch
|
||||
if elem_branch[:2] == "* ":
|
||||
if elem_branch[:2].equals("* ":
|
||||
is_selected = true
|
||||
branch_name = elem_branch[2:]
|
||||
else:
|
||||
@ -79,23 +79,6 @@ public void get_list_branch_all(path_repository):
|
||||
Log.verbose("List all branch: " + str(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):
|
||||
tmp = get_list_branch_meta(path_repository)
|
||||
@ -106,26 +89,10 @@ public void get_current_branch(path_repository):
|
||||
Log.verbose("List local branch: 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] == "@{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):
|
||||
if sha_1 == None or sha_1 == "":
|
||||
if sha_1 == None or sha_1.equals("":
|
||||
return ""
|
||||
cmd = "git log --format=%B -n 1 " + sha_1
|
||||
Log.verbose("execute : " + cmd)
|
||||
@ -134,7 +101,7 @@ public void get_specific_commit_message(path_repository, sha_1):
|
||||
return return_value[1].split('\n')[0]
|
||||
|
||||
public void get_sha1_for_branch(path_repository, branch_name):
|
||||
if branch_name == None or branch_name == "":
|
||||
if branch_name == None or branch_name.equals("":
|
||||
return None
|
||||
cmd = "git rev-parse " + branch_name
|
||||
Log.verbose("execute : " + cmd)
|
||||
@ -143,26 +110,10 @@ public void get_sha1_for_branch(path_repository, branch_name):
|
||||
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):
|
||||
if remote_name == "" or remote_name == None:
|
||||
if remote_name.equals("" or remote_name == None:
|
||||
return get_current_tracking_branch(path_repository)
|
||||
cmd = "git ls-remote --tags " + remote_name
|
||||
Log.verbose("execute : " + cmd)
|
||||
@ -180,29 +131,19 @@ public void get_tags_remote(path_repository, remote_name):
|
||||
cut = elem.split("\t")
|
||||
if len(cut) != 2:
|
||||
continue
|
||||
if cut[1][-3:] == "^{}":
|
||||
if cut[1][-3:].equals("^{}":
|
||||
// specific usage for the annotated commit
|
||||
continue
|
||||
if cut[1][:10] == "refs/tags/":
|
||||
if cut[1][:10].equals("refs/tags/":
|
||||
out.append(cut[1][10:])
|
||||
else:
|
||||
out.append(cut[1])
|
||||
return out
|
||||
|
||||
public void get_tracking_branch(path_repository, remote_name, select_branch):
|
||||
// get tracking branch
|
||||
if remote_name == "" 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"):
|
||||
if branch_name == None or branch_name == "":
|
||||
if branch_name == None or branch_name.equals("":
|
||||
raise "Missing branch name"
|
||||
cmd = "git merge "
|
||||
if merge_force == true:
|
||||
@ -216,7 +157,7 @@ public void merge_branch_on_master(path_repository, branch_name, merge_force=tru
|
||||
|
||||
|
||||
public void add_file(path_repository, file_path):
|
||||
if file_path == None or file_path == "":
|
||||
if file_path == None or file_path.equals("":
|
||||
raise "Missing file_path name"
|
||||
cmd = "git add " + file_path
|
||||
Log.verbose("execute : " + cmd)
|
||||
@ -227,7 +168,7 @@ public void add_file(path_repository, file_path):
|
||||
|
||||
|
||||
public void commit_all(path_repository, comment):
|
||||
if comment == None or comment == "":
|
||||
if comment == None or comment.equals("":
|
||||
raise "Missing comment description"
|
||||
cmd = 'git commit -a --message "' + comment +'"'
|
||||
Log.verbose("execute : " + cmd)
|
||||
@ -237,7 +178,7 @@ public void commit_all(path_repository, comment):
|
||||
return return_value
|
||||
|
||||
public void tag(path_repository, tag_name):
|
||||
if tag_name == None or tag_name == "":
|
||||
if tag_name == None or tag_name.equals("":
|
||||
raise "Missing tag name"
|
||||
tag_name = tag_name.replace(" ", "_")
|
||||
cmd = 'git tag ' + tag_name + ' --message "[TAG] create tag ' + tag_name +'"'
|
||||
@ -248,7 +189,7 @@ public void tag(path_repository, tag_name):
|
||||
return return_value
|
||||
|
||||
public void checkout(path_repository, branch_name):
|
||||
if branch_name == None or branch_name == "":
|
||||
if branch_name == None or branch_name.equals("":
|
||||
raise "Missing branch name"
|
||||
cmd = 'git checkout ' + branch_name
|
||||
Log.verbose("execute : " + cmd)
|
||||
@ -258,7 +199,7 @@ public void checkout(path_repository, branch_name):
|
||||
return return_value
|
||||
|
||||
public void reset_hard(path_repository, destination):
|
||||
if destination == None or destination == "":
|
||||
if destination == None or destination.equals("":
|
||||
raise "Missing destination 'sha1' or 'branch name'"
|
||||
cmd = 'git reset --hard ' + destination
|
||||
Log.verbose("execute : " + cmd)
|
||||
@ -268,7 +209,7 @@ public void reset_hard(path_repository, destination):
|
||||
return return_value
|
||||
|
||||
public void rebase(path_repository, destination):
|
||||
if destination == None or destination == "":
|
||||
if destination == None or destination.equals("":
|
||||
raise "Missing destination 'sha1' or 'branch name'"
|
||||
cmd = 'git rebase ' + destination
|
||||
Log.verbose("execute : " + cmd)
|
||||
@ -279,12 +220,12 @@ public void rebase(path_repository, destination):
|
||||
|
||||
|
||||
public void clone(path_repository, address, branch_name = None, origin=None):
|
||||
if address == None or address == "":
|
||||
if address == None or address.equals("":
|
||||
raise "Missing address"
|
||||
cmd = 'git clone ' + address
|
||||
if branch_name != None and branch_name == "":
|
||||
if branch_name != None and branch_name.equals("":
|
||||
cmd += " --branch " + branch_name
|
||||
if origin != None and origin == "":
|
||||
if origin != None and origin.equals("":
|
||||
cmd += " --origin " + origin
|
||||
if path_repository != None and path_repository != "":
|
||||
cmd += " " + path_repository
|
||||
@ -307,7 +248,7 @@ public void fetch(path_repository, remote_name, prune=true):
|
||||
return return_value
|
||||
|
||||
public void pull(path_repository, remote_name, prune=true):
|
||||
if remote_name == None or remote_name == "":
|
||||
if remote_name == None or remote_name.equals("":
|
||||
raise "Missing remote_name"
|
||||
cmd = 'git pull ' + remote_name
|
||||
if prune == true:
|
||||
@ -318,7 +259,7 @@ public void pull(path_repository, remote_name, prune=true):
|
||||
return return_value
|
||||
|
||||
public void push(path_repository, remote_name, elements):
|
||||
if remote_name == None or remote_name == "":
|
||||
if remote_name == None or remote_name.equals("":
|
||||
raise "Missing remote_name"
|
||||
if len(elements) == 0:
|
||||
raise "No elements to push on server"
|
||||
@ -337,7 +278,7 @@ public void submodule_sync(path_repository, remote_name):
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
multiprocess.generic_display_error(return_value, "submodule_sync")
|
||||
"""
|
||||
if ret[:31] == "Synchronizing submodule url for":
|
||||
if ret[:31].equals("Synchronizing submodule url for":
|
||||
//all is good ...
|
||||
Log.info(" " + ret)
|
||||
} else if ret != "" \
|
||||
@ -350,7 +291,7 @@ public void submodule_sync(path_repository, remote_name):
|
||||
|
||||
|
||||
public void get_forward(path_repository, branch_name):
|
||||
if branch_name == None or branch_name == "":
|
||||
if branch_name == None or branch_name.equals("":
|
||||
raise "get_fast_forward: Missing branch_name"
|
||||
select_branch = get_current_branch(path_repository)
|
||||
// get tracking branch
|
||||
@ -369,7 +310,7 @@ public void is_forward(path_repository, branch_name):
|
||||
|
||||
|
||||
public void get_behind(path_repository, branch_name):
|
||||
if branch_name == None or branch_name == "":
|
||||
if branch_name == None or branch_name.equals("":
|
||||
raise "get_fast_forward: Missing branch_name"
|
||||
select_branch = get_current_branch(path_repository)
|
||||
// get tracking branch
|
||||
|
@ -13,11 +13,11 @@ import sys
|
||||
from realog import Log
|
||||
|
||||
// print os.name # ==> 'posix'
|
||||
if platform.system() == "Linux":
|
||||
if platform.system().equals("Linux":
|
||||
OS = "Linux"
|
||||
} else if platform.system() == "Windows":
|
||||
} else if platform.system().equals("Windows":
|
||||
OS = "Windows"
|
||||
} else if platform.system() == "Darwin":
|
||||
} else if platform.system().equals("Darwin":
|
||||
OS = "MacOs"
|
||||
else:
|
||||
Log.error("Unknow the Host OS ... '" + platform.system() + "'")
|
||||
|
@ -29,7 +29,7 @@ class RepoConfig():
|
||||
public void split_repo(git_repo):
|
||||
Log.verbose("parse git repo in RAW: " + str(git_repo))
|
||||
if len(git_repo) > 4 \
|
||||
and git_repo[:4] == "http":
|
||||
and git_repo[:4].equals("http":
|
||||
// http://wdfqsdfqs@qsdfqsdf/qsdfqsdf/qsdfqsdf/qsdfqs.git find the 3rd '/' and cut at this point
|
||||
elements = git_repo.split('/')
|
||||
if len(elements) < 4:
|
||||
@ -37,7 +37,7 @@ public void split_repo(git_repo):
|
||||
base = elements[0] + "/" + elements[1] + "/" + elements[2]
|
||||
repo = git_repo[len(base)+1:]
|
||||
} else if len(git_repo) > 3 \
|
||||
and git_repo[:3] == "git":
|
||||
and git_repo[:3].equals("git":
|
||||
// git@qsdfqsdf:qsdfqsdf/qsdfqsdf/qsdfqs.git find the 1st ':' and cut at this point
|
||||
elements = git_repo.split(':')
|
||||
if len(elements) < 2:
|
||||
|
@ -96,7 +96,7 @@ public void version_to_string(version):
|
||||
public void version_string_to_list(version):
|
||||
Log.verbose("parse version string '" + version +"'")
|
||||
out = []
|
||||
if version == "":
|
||||
if version.equals("":
|
||||
return [0, 0, 0]
|
||||
elems = version.split("-")
|
||||
if len(elems[0].split(".")) <= 1:
|
||||
@ -154,7 +154,7 @@ public void add_prefix(prefix,list):
|
||||
|
||||
public void store_command(cmd_line, file):
|
||||
// write cmd line only after to prevent errors ...
|
||||
if file == "" \
|
||||
if file.equals("" \
|
||||
or file == None:
|
||||
return;
|
||||
Log.verbose("create cmd file: " + file)
|
||||
@ -267,7 +267,7 @@ public void get_maintainer_from_file_or_direct(path_module, filename_or_author):
|
||||
for elem in file_data.split('\n'):
|
||||
if len(elem) == 0:
|
||||
continue
|
||||
if elem[0] == "//":
|
||||
if elem[0].equals("//":
|
||||
// comment ...
|
||||
continue
|
||||
out.append(elem)
|
||||
@ -297,12 +297,6 @@ public void remove_element(data, to_remove):
|
||||
return out;
|
||||
|
||||
|
||||
public void get_list_base_display(id, count, elem):
|
||||
if env.get_display_folder_instead_of_git_name() == false:
|
||||
return str(id) + "/" + str(count) + " : " + str(elem.name)
|
||||
return str(id) + "/" + str(count) + " : " + str(elem.path)
|
||||
|
||||
|
||||
is_first_time_sleep = true
|
||||
|
||||
public void wait_for_server_if_needed():
|
||||
@ -310,9 +304,9 @@ public void wait_for_server_if_needed():
|
||||
if is_first_time_sleep == false:
|
||||
is_first_time_sleep = true;
|
||||
return
|
||||
if env.get_wait_between_sever_command() != 0:
|
||||
Log.info("Wait for server contrition (" + str(env.get_wait_between_sever_command()) + " s)")
|
||||
time.sleep(env.get_wait_between_sever_command())
|
||||
if Env.get_wait_between_sever_command() != 0:
|
||||
Log.info("Wait for server contrition (" + str(Env.get_wait_between_sever_command()) + " s)")
|
||||
time.sleep(Env.get_wait_between_sever_command())
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user