[DEV] continue REWORK, pb with EXML
This commit is contained in:
parent
9148d9242c
commit
1351757c48
@ -12,8 +12,8 @@ import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.ActionInterface;
|
||||
|
||||
public class Actions {
|
||||
private static Map<String, Class<ActionInterface>> actions = new HashMap<String,Class<ActionInterface>>();
|
||||
public static void addAction(final String name, final Class<ActionInterface> 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);
|
||||
}
|
||||
/**
|
||||
@ -52,7 +52,7 @@ public class Actions {
|
||||
* @throws ActionException
|
||||
*/
|
||||
private static String getFullActionHelp(final String action_name) throws ActionException {
|
||||
Class<ActionInterface> actionClass = Actions.actions.get(action_name);
|
||||
Class<? extends ActionInterface> actionClass = Actions.actions.get(action_name);
|
||||
if (actionClass == null) {
|
||||
throw new ActionException("Action does not registered");
|
||||
}
|
||||
@ -69,7 +69,7 @@ public class Actions {
|
||||
}
|
||||
|
||||
private static String getActionHelpExample(final String action_name) throws ActionException {
|
||||
Class<ActionInterface> actionClass = Actions.actions.get(action_name);
|
||||
Class<? extends ActionInterface> actionClass = Actions.actions.get(action_name);
|
||||
if (actionClass == null) {
|
||||
throw new ActionException("Action does not registered");
|
||||
}
|
||||
@ -111,7 +111,7 @@ public class Actions {
|
||||
}
|
||||
|
||||
public static void execute(final String action_name, final List<String> arguments) throws ActionException {
|
||||
Class<ActionInterface> actionClass = Actions.actions.get(action_name);
|
||||
Class<? extends ActionInterface> actionClass = Actions.actions.get(action_name);
|
||||
if (actionClass == null) {
|
||||
throw new ActionException("Action does not registered");
|
||||
}
|
||||
@ -132,7 +132,7 @@ public class Actions {
|
||||
List<ArgElement> my_under_args = my_under_args_parser.parse(arguments, have_unknow_argument);
|
||||
// search help if needed ==> permit to not duplicating code
|
||||
for (ArgElement elem : my_under_args) {
|
||||
if (elem.getOptionName().equals("help") {
|
||||
if (elem.getOptionName().equals("help")) {
|
||||
Actions.usage(action_name, my_under_args_parser);
|
||||
System.exit(0);
|
||||
}
|
||||
@ -142,7 +142,12 @@ 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;
|
||||
}
|
||||
}
|
||||
|
@ -97,11 +97,12 @@ public class Env {
|
||||
|
||||
static {
|
||||
//String tmp = island_root_path.toAbsolutePath().toString();
|
||||
//Log.info("Current absolute path is: " + tmp);
|
||||
Env.island_root_path = Paths.get("");
|
||||
Path tmpPath = Env.island_root_path;
|
||||
Path tmpPath = Env.island_root_path.toAbsolutePath();
|
||||
Log.info("Current absolute path is: " + tmpPath);
|
||||
while (!Files.isDirectory(tmpPath.resolve("." + Env.get_system_base_name()))) {
|
||||
tmpPath = tmpPath.getParent();
|
||||
Log.info("test upper path: " + tmpPath);
|
||||
if (tmpPath == null) {
|
||||
Log.critical("the root path of " + Env.get_system_base_name() + " must not be upper parent paths of (" + Env.island_root_path.toAbsolutePath() + ")");
|
||||
}
|
||||
|
@ -9,39 +9,20 @@ 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();
|
||||
|
||||
//Log.verbose("List of actions: " + str(actions.get_list_of_action()))
|
||||
static {
|
||||
MainIsland.my_args.addSection("option", "Can be set one time in all case");
|
||||
MainIsland.my_args.add("h", "help", null, "Display this help");
|
||||
MainIsland.my_args.add("v", "verbose", Arrays.asList(
|
||||
new ArgChoice("0","None"),
|
||||
new ArgChoice("1","error"),
|
||||
new ArgChoice("2","warning"),
|
||||
new ArgChoice("3","info"),
|
||||
new ArgChoice("4","debug"),
|
||||
new ArgChoice("5","verbose"),
|
||||
new ArgChoice("6","extreme_verbose")
|
||||
), "display debug level (verbose) default =2");
|
||||
MainIsland.my_args.add("c", "color", null, "Display message in color");
|
||||
MainIsland.my_args.add("n", "no-fetch-manifest", null, "Disable the fetch of the manifest", false);
|
||||
MainIsland.my_args.add("F", "filter", null, "Filter the action on a list of path or subpath: -f library", true);
|
||||
MainIsland.my_args.add("f", "folder", null, "Display the folder instead of the git repository name", false);
|
||||
MainIsland.my_args.add("w", "wait", null, "Wait between 2 acces on the server (needed when the server is really slow to remove ssh connection) (default=" + Env.get_wait_between_sever_command() + ")", true);
|
||||
//my_args.setStopAt(actions.get_list_of_action());
|
||||
}
|
||||
private final Arguments my_args = new Arguments();
|
||||
|
||||
//
|
||||
// @brief Display the help of this makefile.
|
||||
//
|
||||
public static void usage() {
|
||||
public void usage() {
|
||||
// generic argument displayed :
|
||||
MainIsland.my_args.display("");
|
||||
this.my_args.display("");
|
||||
Log.print(" Action availlable" );
|
||||
Set<String> list_actions = Actions.getListOfAction();
|
||||
for (String elem : list_actions) {
|
||||
@ -75,11 +56,11 @@ public class MainIsland {
|
||||
}
|
||||
|
||||
// preparse the argument to get the verbose element for Log mode
|
||||
public static boolean parse_generic_arg(final ArgElement argument, final boolean active) {
|
||||
public boolean parse_generic_arg(final ArgElement argument, final boolean active) {
|
||||
Log.verbose("parse arg : " + argument.getOptionName() + " " + argument.getArg() + " active=" + active);
|
||||
if (argument.getOptionName().equals("help") ){
|
||||
if (!active) {
|
||||
MainIsland.usage();
|
||||
usage();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -176,21 +157,39 @@ public class MainIsland {
|
||||
// }
|
||||
}
|
||||
public MainIsland() {
|
||||
|
||||
Actions.addAction("status", IslandActionStatus.class);
|
||||
Actions.addAction("checkout", IslandActionCheckout.class);
|
||||
this.my_args.addSection("option", "Can be set one time in all case");
|
||||
this.my_args.add("h", "help", null, "Display this help");
|
||||
this.my_args.add("v", "verbose", Arrays.asList(
|
||||
new ArgChoice("0","None"),
|
||||
new ArgChoice("1","error"),
|
||||
new ArgChoice("2","warning"),
|
||||
new ArgChoice("3","info"),
|
||||
new ArgChoice("4","debug"),
|
||||
new ArgChoice("5","verbose"),
|
||||
new ArgChoice("6","extreme_verbose")
|
||||
), "display debug level (verbose) default =2");
|
||||
this.my_args.add("c", "color", null, "Display message in color");
|
||||
this.my_args.add("n", "no-fetch-manifest", null, "Disable the fetch of the manifest", false);
|
||||
this.my_args.add("F", "filter", null, "Filter the action on a list of path or subpath: -f library", true);
|
||||
this.my_args.add("f", "folder", null, "Display the folder instead of the git repository name", false);
|
||||
this.my_args.add("w", "wait", null, "Wait between 2 acces on the server (needed when the server is really slow to remove ssh connection) (default=" + Env.get_wait_between_sever_command() + ")", true);
|
||||
this.my_args.setStopAt(List.copyOf(Actions.getListOfAction()));
|
||||
}
|
||||
|
||||
void run(final String[] args) throws ActionException {
|
||||
List<String> argss = Arrays.asList(args);
|
||||
List<ArgElement> local_argument = MainIsland.my_args.parse(argss);
|
||||
List<ArgElement> local_argument = this.my_args.parse(argss);
|
||||
|
||||
// parse default unique argument:
|
||||
for (ArgElement argument : local_argument) {
|
||||
MainIsland.parse_generic_arg(argument, true);
|
||||
parse_generic_arg(argument, true);
|
||||
}
|
||||
// remove all generic arguments:
|
||||
List<ArgElement> new_argument_list = new ArrayList<>();
|
||||
for (ArgElement argument : local_argument) {
|
||||
if (MainIsland.parse_generic_arg(argument, false)) {
|
||||
if (parse_generic_arg(argument, false)) {
|
||||
continue;
|
||||
}
|
||||
new_argument_list.add(argument);
|
||||
@ -201,7 +200,7 @@ public class MainIsland {
|
||||
Log.warning("--------------------------------------");
|
||||
Log.warning("Missing the action to do ...");
|
||||
Log.warning("--------------------------------------");
|
||||
MainIsland.usage();
|
||||
usage();
|
||||
}
|
||||
String action_to_do = new_argument_list.get(0).getArg();
|
||||
new_argument_list.remove(0);
|
||||
@ -209,7 +208,7 @@ public class MainIsland {
|
||||
Log.warning("--------------------------------------");
|
||||
Log.warning("Wrong action type : '" + action_to_do + "' availlable list: " + Actions.getListOfAction());
|
||||
Log.warning("--------------------------------------");
|
||||
MainIsland.usage();
|
||||
usage();
|
||||
}
|
||||
// todo : Remove this
|
||||
if (!action_to_do.equals("init") && !Files.exists(Env.get_island_path())) {
|
||||
@ -217,7 +216,7 @@ public class MainIsland {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
argss = argss.subList(MainIsland.my_args.getLastParsed()+1, argss.size());
|
||||
argss = argss.subList(this.my_args.getLastParsed()+1, argss.size());
|
||||
Actions.execute(action_to_do, argss);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ 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() {
|
||||
@ -35,18 +35,18 @@ public class islandActionCheckout implements ActionInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final List<ArgElement> _arguments) throws ActionException {
|
||||
public void execute(final List<ArgElement> _arguments) throws ActionException, Exception {
|
||||
|
||||
String argument_remote_name = "";
|
||||
String 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();
|
||||
} else {
|
||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'");
|
||||
Log.error("Wrong argument{ '" + elem.getOptionName() + "' '" + elem.getArg() + "'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -55,18 +55,18 @@ 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);
|
||||
|
||||
List<ProjectConfig> all_project = mani.get_all_configs();
|
||||
Log.info("checkout of: " + all_project.size() + " projects");
|
||||
Log.info("checkout of{ " + all_project.size() + " projects");
|
||||
int id_element = 0;
|
||||
boolean have_error = false;
|
||||
for (ProjectConfig elem : all_project) {
|
92
src/org/atriasoft/island/actions/IslandActionStatus.java
Normal file
92
src/org/atriasoft/island/actions/IslandActionStatus.java
Normal file
@ -0,0 +1,92 @@
|
||||
package org.atriasoft.island.actions;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.death.ArgElement;
|
||||
import org.atriasoft.death.Arguments;
|
||||
import org.atriasoft.island.Config;
|
||||
import org.atriasoft.island.Env;
|
||||
import org.atriasoft.island.Manifest;
|
||||
import org.atriasoft.island.Tools;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.ActionInterface;
|
||||
import org.atriasoft.island.model.ConfigManifest;
|
||||
import org.atriasoft.island.model.ProjectConfig;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
|
||||
public class IslandActionStatus extends ActionInterface {
|
||||
|
||||
@Override
|
||||
public String help() {
|
||||
return "Get the status of all the repositories";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add_specific_arguments(final Arguments myArgs, final String section) {
|
||||
myArgs.add("r", "remote", null, "Name of the remote server", true);
|
||||
myArgs.add("t", "tags", null, "Display if the commit is on a tag (and display it)", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final List<ArgElement> _arguments) throws ActionException, Exception {
|
||||
String argument_remote_name = "";
|
||||
boolean argument_display_tag = false;
|
||||
for (ArgElement elem : _arguments) {
|
||||
if (elem.getOptionName().equals("remote")) {
|
||||
Log.info("find remote name: '" + elem.getArg() + "'");
|
||||
argument_remote_name = elem.getArg();
|
||||
} else if (elem.getOptionName().equals("tags")) {
|
||||
argument_display_tag = true;
|
||||
} else {
|
||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'");
|
||||
}
|
||||
}
|
||||
// check system is OK
|
||||
Manifest.checkIsInit();
|
||||
ConfigManifest configuration = Config.getUniqueConfig();
|
||||
|
||||
Path file_source_manifest = Env.get_island_path_manifest().resolve(configuration.getManifestName());
|
||||
if (!Files.exists(file_source_manifest)) {
|
||||
Log.critical("Missing manifest file : '" + file_source_manifest + "'");
|
||||
}
|
||||
Manifest mani = new Manifest(file_source_manifest);
|
||||
Git git = Git.open(Env.get_island_path_manifest().toFile());
|
||||
boolean is_modify_manifest = git.status().call().hasUncommittedChanges();
|
||||
if (is_modify_manifest) {
|
||||
Log.info("!!!!!!!!!!!! MANIFEST is modify !!!!!!!!");
|
||||
}
|
||||
|
||||
List<ProjectConfig> all_project = mani.get_all_configs();
|
||||
Log.info("status of: " + all_project.size() + " projects");
|
||||
int id_element = 0;
|
||||
|
||||
/* Display status of manifest ==> todo later ...
|
||||
elem = configuration.get_manifest_config()
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
status.display_status(elem, argument_remote_name, argument_display_tag, id_element, base_display)
|
||||
*/
|
||||
boolean is_behind = false;
|
||||
for (ProjectConfig elem : all_project) {
|
||||
id_element++;
|
||||
String base_display = Tools.get_list_base_display(id_element, all_project.size(), elem);
|
||||
int ret = Status.displayStatus(elem, argument_remote_name, argument_display_tag, id_element, base_display);
|
||||
if (ret != 0) {
|
||||
is_behind = true;
|
||||
}
|
||||
}
|
||||
if (is_behind == true) {
|
||||
//return Env.ret_action_need_updtate;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String helpExample() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,102 +1,214 @@
|
||||
package org.atriasoft.island.actions;
|
||||
|
||||
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 {
|
||||
|
||||
public static boolean checkout_elem(final ProjectConfig elem, final String argument_remote_name, final String branch_to_checkout, final String base_display) {
|
||||
private static String default_behind_message = "[DEV] update dev tag version";
|
||||
private static String default_update_message = "[VERSION] update dev tag version";
|
||||
private static String base_name_of_a_tagged_branch = "branch_on_tag_";
|
||||
|
||||
public static boolean checkout_elem(final ProjectConfig elem, final String argument_remote_name, String branch_to_checkout, final String base_display) throws Exception {
|
||||
Log.verbose("checkout : " + base_display);
|
||||
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
|
||||
|
||||
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
|
||||
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.equals("__TAG__"):
|
||||
branch_to_checkout = base_name_of_a_tagged_branch + elem.getTag();
|
||||
is_tag = true
|
||||
if elem.volatile == true:
|
||||
Log.info("checkout " + base_display + " ==> Can not checkout for 'volatile' repository")
|
||||
return true
|
||||
if elem.tag == None:
|
||||
Log.info("checkout " + base_display + " ==> Can not checkout for '''None''' Tag")
|
||||
return true
|
||||
// check if we are on the good branch:
|
||||
if branch_to_checkout == select_branch:
|
||||
Log.info("checkout " + base_display + " ==> No change already on good branch")
|
||||
return true
|
||||
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 " + 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)
|
||||
|
||||
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 == 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 (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)
|
||||
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();
|
||||
|
||||
|
||||
|
||||
|
@ -7,6 +7,7 @@ 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) {
|
||||
@ -47,4 +48,10 @@ public class ProjectConfig {
|
||||
public void setSelectRemotes(final RemoteConfig selectRemotes) {
|
||||
this.selectRemotes = selectRemotes;
|
||||
}
|
||||
public boolean isVolatile() {
|
||||
return this.volatileElement;
|
||||
}
|
||||
public void setVolatile(final boolean volatileElement) {
|
||||
this.volatileElement = volatileElement;
|
||||
}
|
||||
}
|
@ -48,9 +48,9 @@ public void execute(_arguments):
|
||||
cmd += elem.getArg() + " "
|
||||
|
||||
// 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())
|
||||
if os.path.exists(file_source_manifest) == false:
|
||||
|
@ -60,9 +60,9 @@ public void execute(_arguments):
|
||||
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())
|
||||
if os.path.exists(file_source_manifest) == false:
|
||||
|
@ -52,9 +52,9 @@ public void execute(_arguments):
|
||||
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())
|
||||
if os.path.exists(file_source_manifest) == false:
|
||||
|
@ -58,9 +58,9 @@ public void execute(_arguments):
|
||||
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())
|
||||
if os.path.exists(file_source_manifest) == false:
|
||||
|
@ -52,12 +52,12 @@ public void execute(_arguments):
|
||||
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")
|
||||
|
||||
configuration = config.get_unique_config()
|
||||
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) + "'")
|
||||
|
@ -57,9 +57,9 @@ public void execute(_arguments):
|
||||
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()
|
||||
|
@ -48,9 +48,9 @@ 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())
|
||||
if os.path.exists(file_source_manifest) == false:
|
||||
|
@ -52,9 +52,9 @@ public void execute(_arguments):
|
||||
Log.error("pull Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||
|
||||
// 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())
|
||||
if os.path.exists(file_source_manifest) == false:
|
||||
|
@ -53,9 +53,9 @@ public void execute(_arguments):
|
||||
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)
|
||||
|
@ -47,9 +47,9 @@ 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())
|
||||
|
@ -52,9 +52,9 @@ public void execute(_arguments):
|
||||
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())
|
||||
if os.path.exists(file_source_manifest) == false:
|
||||
|
@ -1,92 +0,0 @@
|
||||
//!/usr/bin/python
|
||||
// -*- coding: utf-8 -*-
|
||||
//#
|
||||
//# @author Edouard DUPIN
|
||||
//#
|
||||
//# @copyright 2012, Edouard DUPIN, all right reserved
|
||||
//#
|
||||
//# @license MPL v2.0 (see license file)
|
||||
//#
|
||||
|
||||
from realog import Log
|
||||
from island import tools
|
||||
from island import env
|
||||
from island import multiprocess
|
||||
from island import config
|
||||
from island import manifest
|
||||
from island import commands
|
||||
import status
|
||||
import os
|
||||
|
||||
|
||||
//#
|
||||
//# @brief Get the global description of the current action
|
||||
//# @return (string) the description string (fist line if reserved for the overview, all is for the specific display)
|
||||
//#
|
||||
public void help():
|
||||
return "Get the status of all the repositories"
|
||||
|
||||
//#
|
||||
//# @brief Add argument to the specific action
|
||||
//# @param[in,out] my_args (death.Arguments) Argument manager
|
||||
//# @param[in] section Name of the currect action
|
||||
//#
|
||||
public void add_specific_arguments(_my_args, _section):
|
||||
_my_args.add("r", "remote", haveParam=true, desc="Name of the remote server")
|
||||
_my_args.add("t", "tags", haveParam=false, desc="Display if the commit is on a tag (and display it)")
|
||||
|
||||
//#
|
||||
//# @brief Execute the action required.
|
||||
//#
|
||||
//# @return error value [0 .. 50] the <0 value is reserved system ==> else, what you want.
|
||||
//# None : No error (return program out 0)
|
||||
//# -10 : ACTION is not existing
|
||||
//# -11 : ACTION execution system error
|
||||
//# -12 : ACTION Wrong parameters
|
||||
//#
|
||||
public void execute(_arguments):
|
||||
argument_remote_name = ""
|
||||
argument_display_tag = false
|
||||
for elem in _arguments:
|
||||
if elem.getOptionName().equals("remote":
|
||||
Log.info("find remote name: '" + elem.getArg() + "'")
|
||||
argument_remote_name = elem.getArg()
|
||||
} else if elem.getOptionName().equals("tags":
|
||||
argument_display_tag = true
|
||||
else:
|
||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||
|
||||
// check system is OK
|
||||
manifest.check_lutin_is_init()
|
||||
configuration = config.get_unique_config()
|
||||
|
||||
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||
if os.path.exists(file_source_manifest) == false:
|
||||
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
|
||||
mani = manifest.Manifest(file_source_manifest)
|
||||
is_modify_manifest = commands.check_repository_is_modify(Env.get_island_path_manifest())
|
||||
if is_modify_manifest == true:
|
||||
Log.info("!!!!!!!!!!!! MANIFEST is modify !!!!!!!!")
|
||||
|
||||
|
||||
all_project = mani.get_all_configs()
|
||||
Log.info("status of: " + str(len(all_project)) + " projects")
|
||||
id_element = 0
|
||||
|
||||
elem = configuration.get_manifest_config()
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
status.display_status(elem, argument_remote_name, argument_display_tag, id_element, base_display)
|
||||
|
||||
is_behind = false
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
ret = status.display_status(elem, argument_remote_name, argument_display_tag, id_element, base_display)
|
||||
if ret != None:
|
||||
is_behind = true
|
||||
|
||||
if is_behind == true:
|
||||
return Env.ret_action_need_updtate
|
||||
|
||||
|
@ -55,9 +55,9 @@ public void execute(_arguments):
|
||||
Log.error("SYNC Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'", ret_value=Env.ret_action_wrong_parameters)
|
||||
|
||||
// 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())
|
||||
|
@ -59,9 +59,9 @@ public void execute(_arguments):
|
||||
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 ...
|
||||
|
||||
|
@ -72,7 +72,7 @@ public void execute(_arguments):
|
||||
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()
|
||||
|
@ -40,7 +40,7 @@ public void execute(_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):
|
||||
|
@ -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,23 +89,7 @@ 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].equals("@{u}":
|
||||
Log.warning("in '" + path_repository + "' no tracking branch is specify")
|
||||
return None
|
||||
multiprocess.generic_display_error(return_value, "get_current_tracking_branch", error_only=true)
|
||||
return return_value[1]
|
||||
|
||||
public void get_revision_list_to_branch(path_repository, branch):
|
||||
cmd = "git rev-list " + branch
|
||||
Log.verbose("execute : " + cmd)
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
multiprocess.generic_display_error(return_value, "get_revision_list_to_branch", error_only=true)
|
||||
return return_value[1].split('\n')
|
||||
|
||||
public void get_specific_commit_message(path_repository, sha_1):
|
||||
if sha_1 == None or sha_1.equals("":
|
||||
@ -143,23 +110,7 @@ public void get_sha1_for_branch(path_repository, branch_name):
|
||||
return return_value[1].split('\n')[0]
|
||||
|
||||
|
||||
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.equals("" or remote_name == None:
|
||||
@ -189,16 +140,6 @@ public void get_tags_remote(path_repository, remote_name):
|
||||
out.append(cut[1])
|
||||
return out
|
||||
|
||||
public void get_tracking_branch(path_repository, remote_name, select_branch):
|
||||
// get tracking branch
|
||||
if remote_name.equals("" or remote_name == None:
|
||||
return get_current_tracking_branch(path_repository)
|
||||
list_branch_remote = get_list_branch_remote(path_repository)
|
||||
Log.extreme_verbose("check if exist " + remote_name + "/" + select_branch + " in " + str(list_branch_remote))
|
||||
if remote_name + "/" + select_branch not in list_branch_remote:
|
||||
Log.debug(" ==> can not get remote branch")
|
||||
return None
|
||||
return remote_name + "/" + select_branch
|
||||
|
||||
|
||||
public void merge_branch_on_master(path_repository, branch_name, merge_force=true, branch_destination = "master"):
|
||||
|
Loading…
Reference in New Issue
Block a user