Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
e0b67d62cd | |||
e1a043a34a | |||
0376dfacab | |||
f00acc0744 | |||
5e71f7673b | |||
cf7da8138d | |||
db54f8d50c | |||
381980372e | |||
42dd73995e | |||
62e1c3bd80 | |||
0a0889afa3 | |||
1e1b4b723e | |||
aefb938621 | |||
3553740686 | |||
9d0ea8000e | |||
9fae154bcd | |||
57121cd339 | |||
2b36761fa5 | |||
9be04fb7d7 | |||
cdbacb8bb5 | |||
c70d59c918 | |||
19fa1f3983 | |||
ea883353e1 | |||
1351757c48 | |||
9148d9242c | |||
5a05e0eb77 | |||
1bb1c4638e | |||
85fb5f5c81 |
24
.classpath
24
.classpath
@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="src" path="src">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="optional" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="module" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="test" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/scenarium-logger">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="module" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="output" path="out/eclipse/classes"/>
|
|
||||||
</classpath>
|
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
/__pycache__/
|
||||||
# Compiled python modules.
|
# Compiled python modules.
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|
||||||
@ -6,4 +8,6 @@
|
|||||||
/build/
|
/build/
|
||||||
|
|
||||||
# Python egg metadata, regenerated from source files by setuptools.
|
# Python egg metadata, regenerated from source files by setuptools.
|
||||||
/*.egg-info
|
/*.egg-info
|
||||||
|
|
||||||
|
target/
|
||||||
|
24
.project
24
.project
@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>atriasoft-island</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
<project>atriasoft-island</project>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<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>
|
|
40
README.md
40
README.md
@ -0,0 +1,40 @@
|
|||||||
|
Island (java version)
|
||||||
|
=====================
|
||||||
|
|
||||||
|
Island is a tool to manage big workspace with many dependency and life cycle for big project.
|
||||||
|
|
||||||
|
This is a re-implement of island in java with the benefit of managing the jgit interface and the "maven model" repository download for artefacts.
|
||||||
|
|
||||||
|
|
||||||
|
Install island
|
||||||
|
==============
|
||||||
|
|
||||||
|
Install with krypton
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
cf krypton repository ...
|
||||||
|
|
||||||
|
to install:
|
||||||
|
```{.bash}
|
||||||
|
krypton install island
|
||||||
|
```
|
||||||
|
|
||||||
|
to remove:
|
||||||
|
```{.bash}
|
||||||
|
krypton remove island
|
||||||
|
```
|
||||||
|
|
||||||
|
Manual installation
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
TBD...
|
||||||
|
|
||||||
|
|
||||||
|
Remove old island (python)
|
||||||
|
==========================
|
||||||
|
|
||||||
|
```
|
||||||
|
\rm -f /home/heero/.local/bin/island
|
||||||
|
\rm -f /usr/bin/island
|
||||||
|
```
|
||||||
|
|
2
generator_bundle_jgit/README.md
Normal file
2
generator_bundle_jgit/README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
mvn package
|
||||||
|
mv target/jgit-bundle-5.12.0-jar-with-dependencies.jar ../lib/jgit-bundle-5.12.0.jar
|
66
generator_bundle_jgit/pom.xml
Normal file
66
generator_bundle_jgit/pom.xml
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.atriasoft</groupId>
|
||||||
|
<artifactId>jgit_bundle</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<version>5.12.0</version>
|
||||||
|
<name>org.atriasoft.jgit_bundle</name>
|
||||||
|
<properties>
|
||||||
|
<jgit-version>5.12.0.202106070339-r</jgit-version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- logging -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-slf4j-impl</artifactId>
|
||||||
|
<version>2.13.3</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jgit</groupId>
|
||||||
|
<artifactId>org.eclipse.jgit</artifactId>
|
||||||
|
<version>${jgit-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jgit</groupId>
|
||||||
|
<artifactId>org.eclipse.jgit.http.apache</artifactId>
|
||||||
|
<version>${jgit-version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jgit</groupId>
|
||||||
|
<artifactId>org.eclipse.jgit.ssh.apache</artifactId>
|
||||||
|
<version>${jgit-version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<defaultGoal>install</defaultGoal>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>single</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<descriptorRefs>
|
||||||
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
|
</descriptorRefs>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
BIN
generator_bundle_jgit/target/jgit_bundle-5.12.0.jar
Normal file
BIN
generator_bundle_jgit/target/jgit_bundle-5.12.0.jar
Normal file
Binary file not shown.
@ -0,0 +1,5 @@
|
|||||||
|
#Generated by Maven
|
||||||
|
#Sun Sep 19 15:44:02 CEST 2021
|
||||||
|
groupId=org.atriasoft
|
||||||
|
artifactId=jgit_bundle
|
||||||
|
version=5.12.0
|
BIN
lib/jgit_bundle-5.12.0.jar
Normal file
BIN
lib/jgit_bundle-5.12.0.jar
Normal file
Binary file not shown.
BIN
lib/log4j-1.2.17.jar
Normal file
BIN
lib/log4j-1.2.17.jar
Normal file
Binary file not shown.
BIN
lib/org.eclipse.jgit-5.12.0.202106070339-r.jar
Normal file
BIN
lib/org.eclipse.jgit-5.12.0.202106070339-r.jar
Normal file
Binary file not shown.
BIN
lib/org.eclipse.jgit.ssh.jsch-5.12.0.202106070339-r.jar
Normal file
BIN
lib/org.eclipse.jgit.ssh.jsch-5.12.0.202106070339-r.jar
Normal file
Binary file not shown.
BIN
lib/slf4j-api-1.7.31.jar
Normal file
BIN
lib/slf4j-api-1.7.31.jar
Normal file
Binary file not shown.
BIN
lib/slf4j-log4j12-1.7.31.jar
Normal file
BIN
lib/slf4j-log4j12-1.7.31.jar
Normal file
Binary file not shown.
BIN
lib/slf4j-simple-1.7.31.jar
Normal file
BIN
lib/slf4j-simple-1.7.31.jar
Normal file
Binary file not shown.
@ -4,9 +4,17 @@
|
|||||||
|
|
||||||
open module org.atriasoft.island {
|
open module org.atriasoft.island {
|
||||||
exports org.atriasoft.island;
|
exports org.atriasoft.island;
|
||||||
//exports org.atriasoft.island.model;
|
exports org.atriasoft.island.model;
|
||||||
|
exports org.atriasoft.island.actions;
|
||||||
|
exports org.atriasoft.island.model.manifest;
|
||||||
//exports org.atriasoft.island.actions;
|
//exports org.atriasoft.island.actions;
|
||||||
|
|
||||||
requires transitive io.scenarium.logger;
|
requires transitive org.atriasoft.reggol;
|
||||||
requires java.base;
|
requires java.base;
|
||||||
|
requires org.atriasoft.death;
|
||||||
|
requires org.atriasoft.exml;
|
||||||
|
requires org.atriasoft.etk;
|
||||||
|
//requires org.eclipse.jgit;
|
||||||
|
requires jgit.bundle;
|
||||||
|
requires org.atriasoft.ejson;
|
||||||
}
|
}
|
||||||
|
512
src/org/atriasoft/island/Commands.java
Normal file
512
src/org/atriasoft/island/Commands.java
Normal file
@ -0,0 +1,512 @@
|
|||||||
|
package org.atriasoft.island;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.island.internal.Log;
|
||||||
|
import org.atriasoft.island.model.DeltaBranch;
|
||||||
|
import org.atriasoft.island.model.manifest.DeliverMode;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.api.Git;
|
||||||
|
import org.eclipse.jgit.api.ListBranchCommand.ListMode;
|
||||||
|
import org.eclipse.jgit.api.MergeCommand.FastForwardMode;
|
||||||
|
import org.eclipse.jgit.api.MergeResult;
|
||||||
|
import org.eclipse.jgit.api.Status;
|
||||||
|
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||||
|
import org.eclipse.jgit.api.errors.NoHeadException;
|
||||||
|
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||||
|
import org.eclipse.jgit.errors.MissingObjectException;
|
||||||
|
import org.eclipse.jgit.errors.NoWorkTreeException;
|
||||||
|
import org.eclipse.jgit.errors.RevisionSyntaxException;
|
||||||
|
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;
|
||||||
|
import org.eclipse.jgit.revwalk.RevWalk;
|
||||||
|
@SuppressWarnings("exports")
|
||||||
|
public class Commands {
|
||||||
|
private static final String default_behind_message = "[DEV] update dev tag version";
|
||||||
|
private static final String default_update_message = "[VERSION] update dev tag version";
|
||||||
|
private Commands() {}
|
||||||
|
public static List<String> getListBranchLocal(final Git git) throws GitAPIException {
|
||||||
|
List<String> remotes = Commands.getListBranchRemote(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> getListBranchAll(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> getListBranchRemote(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> getTags(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 getTrackingBranch(final Git git, final String remote_name, final String select_branch) throws GitAPIException, IOException {
|
||||||
|
// get tracking branch
|
||||||
|
if (remote_name == null || remote_name.isEmpty()) {
|
||||||
|
return Commands.getCurrentTrackingBranch(git);
|
||||||
|
}
|
||||||
|
List<String> list_branch_remote = Commands.getListBranchRemote(git);
|
||||||
|
LOGGER.trace("check if exist " + remote_name + "/" + select_branch + " in " + list_branch_remote);
|
||||||
|
String tmpBranchName = remote_name + "/" + select_branch;
|
||||||
|
if (!list_branch_remote.contains("refs/remotes/" + tmpBranchName)) {
|
||||||
|
LOGGER.debug(" ==> can not get remote branch");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return remote_name + "/" + select_branch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getCurrentTrackingBranch(final Git git) throws IOException {
|
||||||
|
Repository repo = git.getRepository();
|
||||||
|
return new BranchConfig(repo.getConfig(), repo.getBranch()).getTrackingBranch();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ObjectId> getRevisionListToBranch(final Git git, final String branch) throws NoHeadException, GitAPIException {
|
||||||
|
List<ObjectId> out = new ArrayList<>();
|
||||||
|
Iterable<RevCommit> commits;
|
||||||
|
try {
|
||||||
|
commits = git.log().add(git.getRepository().resolve(branch)).call();
|
||||||
|
} catch (RevisionSyntaxException | GitAPIException | IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
for(RevCommit commit : commits ) {
|
||||||
|
ObjectId tmp = commit.toObjectId();
|
||||||
|
out.add(tmp);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getTagsCurrent(final Git git) {
|
||||||
|
List<String> out = new ArrayList<>();
|
||||||
|
RevCommit latestCommit;
|
||||||
|
try {
|
||||||
|
latestCommit = git.log().setMaxCount(1).call().iterator().next();
|
||||||
|
} catch (GitAPIException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
String latestCommitHash = latestCommit.getName();
|
||||||
|
|
||||||
|
List<Ref> list;
|
||||||
|
try {
|
||||||
|
list = git.tagList().call();
|
||||||
|
} catch (GitAPIException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
ObjectId commitId = ObjectId.fromString(latestCommit.getName());
|
||||||
|
Collection<ObjectId> commits = new LinkedList<ObjectId>();
|
||||||
|
for (Ref tag : list) {
|
||||||
|
ObjectId object = tag.getObjectId();
|
||||||
|
if (object.equals(commitId)) {
|
||||||
|
//commits.add(object.getId());
|
||||||
|
if (tag.getName().startsWith("refs/tags/")) {
|
||||||
|
out.add(tag.getName().substring(10));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
public static void getDiff(final Git git) {
|
||||||
|
try {
|
||||||
|
Status status = git.status().call();
|
||||||
|
if (status.getAdded().size() != 0) {
|
||||||
|
LOGGER.print(" * Added: (" + status.getAdded().size() + ")");
|
||||||
|
for (String elem : status.getAdded()) {
|
||||||
|
LOGGER.print(" - " + elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (status.getChanged().size() != 0) {
|
||||||
|
LOGGER.print(" * Changed: (" + status.getChanged().size() + ")");
|
||||||
|
for (String elem : status.getChanged()) {
|
||||||
|
LOGGER.print(" - " + elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (status.getConflicting().size() != 0) {
|
||||||
|
LOGGER.print(" * Conflicting: (" + status.getConflicting().size() + ")");
|
||||||
|
for (String elem : status.getConflicting()) {
|
||||||
|
LOGGER.print(" - " + elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if (status.getIgnoredNotInIndex().size() != 0) {
|
||||||
|
LOGGER.print(" * Ignored not in index: (" + status.getIgnoredNotInIndex().size() + ")");
|
||||||
|
for (String elem : status.getIgnoredNotInIndex()) {
|
||||||
|
LOGGER.print(" - " + elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if (status.getMissing().size() != 0) {
|
||||||
|
LOGGER.print(" * Missing: (" + status.getMissing().size() + ")");
|
||||||
|
for (String elem : status.getMissing()) {
|
||||||
|
LOGGER.print(" - " + elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (status.getModified().size() != 0) {
|
||||||
|
LOGGER.print(" * Modified: (" + status.getModified().size() + ")");
|
||||||
|
for (String elem : status.getModified()) {
|
||||||
|
LOGGER.print(" - " + elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (status.getRemoved().size() != 0) {
|
||||||
|
LOGGER.print(" * Removed: (" + status.getRemoved().size() + ")");
|
||||||
|
for (String elem : status.getRemoved()) {
|
||||||
|
LOGGER.print(" - " + elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (status.getUntracked().size() != 0) {
|
||||||
|
LOGGER.print(" * Untracked: (" + status.getUntracked().size() + ")");
|
||||||
|
for (String elem : status.getUntracked()) {
|
||||||
|
LOGGER.print(" - " + elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (status.getUntrackedFolders().size() != 0) {
|
||||||
|
LOGGER.print(" * Untracked Folders: (" + status.getUntrackedFolders().size() + ")");
|
||||||
|
for (String elem : status.getUntrackedFolders()) {
|
||||||
|
LOGGER.print(" - " + elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (NoWorkTreeException | GitAPIException e) {
|
||||||
|
LOGGER.error("can not retrive the satus of the repository ... " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Check if it is a Git repository with checking if the path exist and if the .git path exist.
|
||||||
|
* @param path Path to check the git repository existence.
|
||||||
|
* @return true if it is a git repository, false otherwise.
|
||||||
|
*/
|
||||||
|
public static boolean isGitRepository(final String path) {
|
||||||
|
Path git_repo_path = Env.getIslandRootPath().resolve(path);
|
||||||
|
if (!Files.exists(git_repo_path)) {
|
||||||
|
LOGGER.warn("Path Does not Exist ... " + git_repo_path + " ==> skip");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!Files.exists(git_repo_path.resolve(".git"))) {
|
||||||
|
// path already exist but it is not used to as a git repo ==> this is an error
|
||||||
|
LOGGER.warn("path '" + git_repo_path + "' Not a git repository ==> skip");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean historyContains(final List<ObjectId> values, final ObjectId checkElem) {
|
||||||
|
for (ObjectId elemSha2 : values) {
|
||||||
|
if (elemSha2.equals(checkElem)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get deltas between 2 branches.
|
||||||
|
* @param git JGit interface of the current repository.
|
||||||
|
* @param branch1 Name of the branch 1.
|
||||||
|
* @param branch2 Name of the Branch 2.
|
||||||
|
* @return The value of behind and forward of the 2 branches
|
||||||
|
* @throws IOException
|
||||||
|
* @throws GitAPIException
|
||||||
|
*/
|
||||||
|
public static DeltaBranch getDeltaBranch(final Git git, final String branch1, final String branch2) throws IOException, GitAPIException {
|
||||||
|
List<ObjectId> retCurrentBranchSha1 = Commands.getRevisionListToBranch(git, branch1);
|
||||||
|
List<ObjectId> retTrackBranchSha1 = Commands.getRevisionListToBranch(git, branch2);
|
||||||
|
// remove all identical sha1 ==> not needed for this
|
||||||
|
int inForward = 0;
|
||||||
|
for (ObjectId elemSha1 : retCurrentBranchSha1) {
|
||||||
|
if (!Commands.historyContains(retTrackBranchSha1, elemSha1)) {
|
||||||
|
inForward++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int inBehind = 0;
|
||||||
|
for (ObjectId elemSha1 : retTrackBranchSha1) {
|
||||||
|
if (!Commands.historyContains(retCurrentBranchSha1, elemSha1)) {
|
||||||
|
inBehind++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new DeltaBranch(inForward, inBehind);
|
||||||
|
}
|
||||||
|
public static void checkout(final Git git, final String destination_branch) {
|
||||||
|
try {
|
||||||
|
git.checkout().setCreateBranch(false).setName("refs/heads/" + destination_branch).call();
|
||||||
|
} catch (GitAPIException e) {
|
||||||
|
LOGGER.error("can not checkout branch:" + destination_branch);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String input() {
|
||||||
|
// Enter data using BufferReader
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
|
||||||
|
// Reading data using readLine
|
||||||
|
try {
|
||||||
|
return reader.readLine();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static boolean stringInList(final String[] elements, final String value) {
|
||||||
|
for (int iii=0; iii<elements.length; iii++) {
|
||||||
|
if (elements[iii].equals(value)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public record CreateVersion(String[] version, boolean addInManagement) {}
|
||||||
|
public static CreateVersion get_current_version_repo(final Path git_repo_path) {
|
||||||
|
Path version_path_file = git_repo_path.resolve("version.txt");
|
||||||
|
boolean add_in_version_management = false;
|
||||||
|
String[] version_description = null;
|
||||||
|
if (!Files.exists(version_path_file)) {
|
||||||
|
LOGGER.info("deliver: ==> No 'version.txt' file ==> not manage release version....");
|
||||||
|
// Action to do:
|
||||||
|
boolean valid = false;
|
||||||
|
String input1 = null;
|
||||||
|
while (!valid) {
|
||||||
|
LOGGER.print("Create a new version: (0.0.0)");
|
||||||
|
LOGGER.print(" (1) Add in managing version");
|
||||||
|
LOGGER.print(" (2) Do NOTHING & continue");
|
||||||
|
input1 = Commands.input();
|
||||||
|
if (Commands.stringInList(new String[]{"1", "2"}, input1)) {
|
||||||
|
valid = true;
|
||||||
|
} else {
|
||||||
|
LOGGER.print("!!! Must select in range [1..2]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (input1.equals("1")) {
|
||||||
|
version_description = new String[]{"0", "0", "0"};
|
||||||
|
add_in_version_management = true;
|
||||||
|
} else if (input1.equals("1")) {
|
||||||
|
LOGGER.info("Continue Not managing for this repository");
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
LOGGER.warn("An error occured for this repository");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
version_description = Tools.versionStringToList(Tools.readFile(version_path_file, Charset.defaultCharset()));
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new CreateVersion(version_description, add_in_version_management);
|
||||||
|
}
|
||||||
|
public static int[] create_new_version_repo(
|
||||||
|
final Git git,
|
||||||
|
final String[] version_description,
|
||||||
|
final boolean add_in_version_management,
|
||||||
|
final String source_branch,
|
||||||
|
final String destination_branch) {
|
||||||
|
// get tracking branch
|
||||||
|
List<ObjectId> ret_destination_branch_sha1 = null;
|
||||||
|
List<ObjectId> ret_source_branch_sha1 = null;
|
||||||
|
try {
|
||||||
|
ret_destination_branch_sha1 = Commands.getRevisionListToBranch(git, destination_branch);
|
||||||
|
ret_source_branch_sha1 = Commands.getRevisionListToBranch(git, source_branch);
|
||||||
|
} catch (NoHeadException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
LOGGER.critical("dfghdsfghdfgh");
|
||||||
|
} catch (GitAPIException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
LOGGER.critical("sdgfhdgfhsdfhsdf");
|
||||||
|
}
|
||||||
|
// remove all identical sha1 ==> not needed for this
|
||||||
|
boolean have_forward = false;
|
||||||
|
for (ObjectId elem_sha1 : ret_destination_branch_sha1) {
|
||||||
|
if (!Commands.historyContains(ret_source_branch_sha1, elem_sha1)) {
|
||||||
|
RevCommit message = Commands.get_specific_commit_message(git, elem_sha1);
|
||||||
|
LOGGER.warn("deliver: Forward commit: '" + message.getFullMessage() + "'");
|
||||||
|
have_forward = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (have_forward == true) {
|
||||||
|
LOGGER.error("'" + destination_branch + "' branch must not be forward '" + source_branch + "' branch");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String behind_message = "";
|
||||||
|
int behind_count = 0;
|
||||||
|
for (ObjectId elem_sha1 : ret_source_branch_sha1) {
|
||||||
|
if (!Commands.historyContains(ret_destination_branch_sha1, elem_sha1)) {
|
||||||
|
RevCommit message = Commands.get_specific_commit_message(git, elem_sha1);
|
||||||
|
behind_count += 1;
|
||||||
|
behind_message = message.getFullMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (behind_count == 0 && add_in_version_management == false) {
|
||||||
|
LOGGER.info("deliver: ==> Nothing to do (1).");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (behind_count == 1 && ( behind_message.equals(Commands.default_behind_message) || behind_message.equals(Commands.default_update_message))) {
|
||||||
|
LOGGER.info("deliver: ==> Nothing to do (2).");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (ObjectId elem_sha1 : ret_source_branch_sha1) {
|
||||||
|
if (!Commands.historyContains(ret_destination_branch_sha1, elem_sha1)) {
|
||||||
|
RevCommit message = Commands.get_specific_commit_message(git, elem_sha1);
|
||||||
|
LOGGER.print("deliver: Behind commit: '" + message.getFullMessage() + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Choice of the new version:
|
||||||
|
String input1 = null;
|
||||||
|
while (input1 == null) {
|
||||||
|
LOGGER.print("update version: curent: " + Arrays.toString(version_description));
|
||||||
|
LOGGER.print(" (1) Major version (change API)");
|
||||||
|
LOGGER.print(" (2) Medium version (add feature)");
|
||||||
|
LOGGER.print(" (3) Minor version (Bug fix & doc)");
|
||||||
|
LOGGER.print(" (4) Do not release & continue");
|
||||||
|
input1 = Commands.input();
|
||||||
|
if (!Commands.stringInList(new String[]{"1", "2", "3", "4"}, input1)) {
|
||||||
|
LOGGER.info("!!! Must select in range [1..4]");
|
||||||
|
input1 = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// limit and force at 3 the nuber of variables
|
||||||
|
String[] version_description_tmp = version_description;
|
||||||
|
int[] version_description_int = new int[version_description.length];
|
||||||
|
for (int iii=0; iii<version_description_tmp.length; iii++) {
|
||||||
|
version_description_int[iii] = Integer.parseInt(version_description_tmp[iii]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] new_version_descrtiption = new int[version_description.length];
|
||||||
|
if (version_description_int.length >= 1) {
|
||||||
|
new_version_descrtiption[0] = version_description_int[0];
|
||||||
|
} else {
|
||||||
|
new_version_descrtiption[0] = 0;
|
||||||
|
}
|
||||||
|
if (version_description_int.length >= 2) {
|
||||||
|
new_version_descrtiption[1] = version_description_int[1];
|
||||||
|
} else {
|
||||||
|
new_version_descrtiption[1] = 0;
|
||||||
|
}
|
||||||
|
if (version_description_int.length >= 3) {
|
||||||
|
new_version_descrtiption[2] = version_description_int[2];
|
||||||
|
} else {
|
||||||
|
new_version_descrtiption[2] = 0;
|
||||||
|
}
|
||||||
|
LOGGER.info("update version: curent: " + Arrays.toString(new_version_descrtiption));
|
||||||
|
// increment the version
|
||||||
|
if (input1.equals("1")) {
|
||||||
|
new_version_descrtiption[0] += 1;
|
||||||
|
new_version_descrtiption[1] = 0;
|
||||||
|
new_version_descrtiption[2] = 0;
|
||||||
|
} else if (input1.equals("2")) {
|
||||||
|
version_description[1] += 1;
|
||||||
|
new_version_descrtiption[2] = 0;
|
||||||
|
} else if (input1.equals("3")) {
|
||||||
|
version_description[2] += 1;
|
||||||
|
} else if (input1.equals("4")) {
|
||||||
|
LOGGER.info("No release for this repository");
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
LOGGER.warn("An error occured for this repository");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
LOGGER.info("update version: curent: " + Arrays.toString(new_version_descrtiption));
|
||||||
|
return new_version_descrtiption;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static RevCommit get_specific_commit_message(final Git git, final ObjectId elem_sha1) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
try (RevWalk walk = new RevWalk(git.getRepository())) {
|
||||||
|
RevCommit commit = walk.parseCommit(elem_sha1);
|
||||||
|
System.out.println("\nCommit-Message: " + commit.getFullMessage());
|
||||||
|
walk.dispose();
|
||||||
|
return commit;
|
||||||
|
} catch (MissingObjectException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IncorrectObjectTypeException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public static void merge_branch_on_master(final Git git, final String from, final DeliverMode deliverModeMerge, final String to) {
|
||||||
|
ObjectId objectIdFrom = null;
|
||||||
|
try {
|
||||||
|
objectIdFrom = git.getRepository().resolve(from);
|
||||||
|
} catch (RevisionSyntaxException | IOException e1) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e1.printStackTrace();
|
||||||
|
LOGGER.error("Merge error: can not retrive the source branch");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Commands.checkout(git, to);
|
||||||
|
MergeResult res = null;
|
||||||
|
try {
|
||||||
|
res = git.merge()
|
||||||
|
.include(objectIdFrom)
|
||||||
|
.setMessage("Merge branch '" + from + "' into '" + to + "'")
|
||||||
|
.setFastForward(deliverModeMerge==DeliverMode.MERGE?FastForwardMode.NO_FF:FastForwardMode.FF_ONLY)
|
||||||
|
.call();
|
||||||
|
} catch (GitAPIException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res == null || !res.getMergeStatus().isSuccessful()) {
|
||||||
|
LOGGER.error("Merge error:" + res.getConflicts().toString());
|
||||||
|
// inform the user he has to handle the conflicts
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
19
src/org/atriasoft/island/Config.java
Normal file
19
src/org/atriasoft/island/Config.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package org.atriasoft.island;
|
||||||
|
|
||||||
|
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||||
|
|
||||||
|
public class Config {
|
||||||
|
private static ConfigManifest config;
|
||||||
|
public static synchronized ConfigManifest getUniqueConfig() {
|
||||||
|
if (config == null) {
|
||||||
|
config = ConfigManifest.load();
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
public static synchronized ConfigManifest createUniqueConfig() {
|
||||||
|
if (config == null) {
|
||||||
|
config = new ConfigManifest();
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package org.atriasoft.island;
|
package org.atriasoft.island;
|
||||||
//!/usr/bin/python
|
//!/usr/bin/python
|
||||||
|
|
||||||
// -*- coding: utf-8 -*-
|
// -*- coding: utf-8 -*-
|
||||||
//#
|
//#
|
||||||
//# @author Edouard DUPIN
|
//# @author Edouard DUPIN
|
||||||
@ -17,135 +18,157 @@ import java.nio.file.Paths;
|
|||||||
import org.atriasoft.island.internal.Log;
|
import org.atriasoft.island.internal.Log;
|
||||||
|
|
||||||
public class Env {
|
public class Env {
|
||||||
|
public static final int RET_MANIFEST_IS_NOT_EXISTING = -5;
|
||||||
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_is_not_existing = -10;
|
public static final int RET_ACTION_EXECUTING_SYSTEM_ERROR = -11;
|
||||||
public static final int ret_action_executing_system_error = -11;
|
public static final int RET_ACTION_WRONG_PARAMETERS = -12;
|
||||||
public static final int ret_action_wrong_parameters = -12;
|
public static final int RET_ACTION_PARTIAL_DONE = -13;
|
||||||
public static final int ret_action_partial_done = -13;
|
public static final int RET_ACTION_FAIL = -14;
|
||||||
public static final int ret_action_fail = -14;
|
public static final int RET_ACTION_NEED_UPDTATE = 15;
|
||||||
|
|
||||||
public static int ret_action_need_updtate = 15;
|
public static String systemBaseName = "island";
|
||||||
|
|
||||||
public static String system_base_name = "island";
|
public static String artifactoryBaseFolder = "artifact";
|
||||||
|
private static boolean fetchManifest = true;
|
||||||
public static void set_system_base_name(String val) {
|
|
||||||
system_base_name = val;
|
private static int waitBetweenSeverCommand = 0;
|
||||||
}
|
public static String filterCommand = null;
|
||||||
public static String get_system_base_name() {
|
|
||||||
return system_base_name;
|
private static boolean displayFolderInsteadOfGitName = true;
|
||||||
}
|
|
||||||
|
private static Path islandRootPath = null;
|
||||||
public static String get_system_config_name() {
|
|
||||||
return "." + system_base_name + "Config.json";
|
private static Path islandPathUserConfig = null;
|
||||||
}
|
private static Path islandPath = null;
|
||||||
|
|
||||||
private static boolean fetch_manifest = true;
|
private static Path islandPathConfig = null;
|
||||||
|
|
||||||
public static void set_fetch_manifest(boolean val) {
|
private static Path islandPathManifest = null;
|
||||||
fetch_manifest = val;
|
|
||||||
}
|
private static Path islandPathArtifactoryLink = null;
|
||||||
public static boolean get_fetch_manifest() {
|
private static Path islandPathArtifactory = null;
|
||||||
return 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 int get_wait_between_sever_command() {
|
|
||||||
return wait_between_sever_command;
|
|
||||||
}
|
|
||||||
public static String filter_command = "";
|
|
||||||
|
|
||||||
public static void set_filter_command(String val) {
|
|
||||||
filter_command = val;
|
|
||||||
}
|
|
||||||
public static String get_filter_command() {
|
|
||||||
return filter_command;
|
|
||||||
}
|
|
||||||
public static boolean need_process_with_filter(String data) {
|
|
||||||
if (filter_command.equals("")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (data.length() < filter_command.length()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (data.substring(0,filter_command.length()).equals(filter_command)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 boolean get_display_folder_instead_of_git_name() {
|
|
||||||
return display_folder_instead_of_git_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Path island_root_path = null;
|
|
||||||
private static Path island_path_user_config = null;
|
|
||||||
private static Path island_path = null;
|
|
||||||
private static Path island_path_config_old = null;
|
|
||||||
private static Path island_path_config = null;
|
|
||||||
private static Path island_path_manifest = null;
|
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
//String tmp = island_root_path.toAbsolutePath().toString();
|
//String tmp = island_root_path.toAbsolutePath().toString();
|
||||||
//Log.info("Current absolute path is: " + tmp);
|
Env.islandRootPath = Paths.get("");
|
||||||
island_root_path = Paths.get("");
|
Path tmpPath = Env.islandRootPath.toAbsolutePath();
|
||||||
Path tmpPath = island_root_path;
|
LOGGER.debug("Current absolute path is: " + tmpPath);
|
||||||
while (!Files.isDirectory(tmpPath.resolve("." + get_system_base_name()))) {
|
while (!Files.isDirectory(tmpPath.resolve("." + Env.getSystemBaseName()))) {
|
||||||
tmpPath = tmpPath.getParent();
|
tmpPath = tmpPath.getParent();
|
||||||
|
LOGGER.debug("test upper path: " + tmpPath);
|
||||||
if (tmpPath == null) {
|
if (tmpPath == null) {
|
||||||
Log.critical("the root path of " + get_system_base_name() + " must not be upper parent paths of (" + island_root_path.toAbsolutePath() + ")");
|
LOGGER.debug("the root path of " + Env.getSystemBaseName() + " must not be upper parent paths of (" + Env.islandRootPath.toAbsolutePath() + ")");
|
||||||
|
tmpPath = Env.islandRootPath.toAbsolutePath();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
island_root_path = tmpPath;
|
Env.islandRootPath = tmpPath;
|
||||||
island_path_user_config = island_root_path.resolve(get_system_config_name());
|
Env.islandPathUserConfig = Env.islandRootPath.resolve(Env.getSystemConfigName());
|
||||||
island_path = island_root_path.resolve("." + get_system_base_name());
|
Env.islandPath = Env.islandRootPath.resolve("." + Env.getSystemBaseName());
|
||||||
island_path_config_old = island_path.resolve("config.txt");
|
Env.islandPathConfig = Env.islandPath.resolve("config.xml");
|
||||||
island_path_config = island_path.resolve("config.json");
|
Env.islandPathManifest = Env.islandPath.resolve("manifest");
|
||||||
island_path_manifest = island_path.resolve("manifest");
|
Env.islandPathArtifactory = Env.islandPath.resolve(Env.artifactoryBaseFolder);
|
||||||
|
Env.islandPathArtifactoryLink = Env.islandRootPath.resolve(Env.artifactoryBaseFolder);
|
||||||
}
|
}
|
||||||
//#
|
|
||||||
//# @brief to use later to know where the ".island" parent path is ...
|
public static boolean getDisplayFolderInsteadOfGitName() {
|
||||||
//# @return the parent path of the ".island"
|
return Env.displayFolderInsteadOfGitName;
|
||||||
//#
|
}
|
||||||
public static Path get_island_root_path() {
|
|
||||||
return island_root_path;
|
public static boolean getFetchManifest() {
|
||||||
}
|
return Env.fetchManifest;
|
||||||
public static Path get_island_path() {
|
}
|
||||||
return island_path;
|
|
||||||
}
|
public static String getFilterCommand() {
|
||||||
public static Path get_island_path_config() {
|
return Env.filterCommand;
|
||||||
return island_path_config;
|
}
|
||||||
}
|
|
||||||
public static Path get_island_path_config_old() {
|
public static Path getIslandPath() {
|
||||||
return island_path_config_old;
|
return Env.islandPath;
|
||||||
}
|
}
|
||||||
public static Path get_island_path_manifest() {
|
|
||||||
return island_path_manifest;
|
public static Path getIslandPathArtifactory() {
|
||||||
}
|
return Env.islandPathArtifactory;
|
||||||
public static Path get_island_path_user_config() {
|
}
|
||||||
return island_path_user_config;
|
|
||||||
}
|
public static Path getIslandPathArtifactoryLink() {
|
||||||
|
return Env.islandPathArtifactoryLink;
|
||||||
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());
|
public static Path getIslandPathConfig() {
|
||||||
Log.error("island_path = " + island_path.toAbsolutePath());
|
return Env.islandPathConfig;
|
||||||
Log.error("island_path_config_old = " + island_path_config_old.toAbsolutePath());
|
}
|
||||||
Log.error("island_path_config = " + island_path_config.toAbsolutePath());
|
|
||||||
Log.error("island_path_manifest = " + island_path_manifest.toAbsolutePath());
|
public static Path getIslandPathManifest() {
|
||||||
|
return Env.islandPathManifest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Path getIslandPathUserConfig() {
|
||||||
|
return Env.islandPathUserConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To use later to know where the ".island" parent path is ...
|
||||||
|
* @return the parent path of the ".island"
|
||||||
|
*/
|
||||||
|
public static Path getIslandRootPath() {
|
||||||
|
return Env.islandRootPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getSystemBaseName() {
|
||||||
|
return Env.systemBaseName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getSystemConfigName() {
|
||||||
|
return "." + Env.systemBaseName + "Config.json";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getWaitBetweenSeverCommand() {
|
||||||
|
return Env.waitBetweenSeverCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(final String[] args) {
|
||||||
|
LOGGER.error("islandRootPath = {}", Env.islandRootPath.toAbsolutePath());
|
||||||
|
LOGGER.error("islandPathUserConfig = {}", Env.islandPathUserConfig.toAbsolutePath());
|
||||||
|
LOGGER.error("islandPath = {}", Env.islandPath.toAbsolutePath());
|
||||||
|
LOGGER.error("islandPathConfig = {}", Env.islandPathConfig.toAbsolutePath());
|
||||||
|
LOGGER.error("islandPathManifest = {}", Env.islandPathManifest.toAbsolutePath());
|
||||||
|
LOGGER.error("islandPathArtifactory = {}", Env.islandPathArtifactory.toAbsolutePath());
|
||||||
|
LOGGER.error("islandPathArtifactoryLink = {}", Env.islandPathArtifactoryLink.toAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean needProcessWithFilter(final String data) {
|
||||||
|
if (Env.filterCommand == null || Env.filterCommand.equals("")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (data.length() < Env.filterCommand.length()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (data.substring(0, Env.filterCommand.length()).equals(Env.filterCommand)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setDisplayFolderInstead_ofGitName(final boolean val) {
|
||||||
|
Env.displayFolderInsteadOfGitName = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setFetchManifest(final boolean val) {
|
||||||
|
Env.fetchManifest = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setFilterCommand(final String val) {
|
||||||
|
Env.filterCommand = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setSystemBaseName(final String val) {
|
||||||
|
Env.systemBaseName = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWaitBetweenSeverCommand(final int val) {
|
||||||
|
Env.waitBetweenSeverCommand = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Env() {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
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;
|
||||||
|
|
||||||
|
public 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,185 +1,135 @@
|
|||||||
package org.atriasoft.island;
|
package org.atriasoft.island;
|
||||||
|
|
||||||
|
import org.atriasoft.death.ActionList;
|
||||||
|
import org.atriasoft.death.ArgumentManager;
|
||||||
|
import org.atriasoft.death.annotation.ArgAlias;
|
||||||
|
import org.atriasoft.death.annotation.ArgChoice;
|
||||||
|
import org.atriasoft.death.annotation.ArgCommand;
|
||||||
|
import org.atriasoft.death.annotation.ArgDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgName;
|
||||||
|
import org.atriasoft.death.annotation.ArgSubActions;
|
||||||
|
import org.atriasoft.island.actions.BaseCheckout;
|
||||||
|
import org.atriasoft.island.actions.BaseCommit;
|
||||||
|
import org.atriasoft.island.actions.BaseFetch;
|
||||||
|
import org.atriasoft.island.actions.BaseInit;
|
||||||
|
import org.atriasoft.island.actions.BasePush;
|
||||||
|
import org.atriasoft.island.actions.BaseStatus;
|
||||||
|
import org.atriasoft.island.actions.BaseSync;
|
||||||
|
import org.atriasoft.island.actions.Deliver;
|
||||||
|
import org.atriasoft.island.actions.DependencySync;
|
||||||
|
import org.atriasoft.island.actions.ManifestCheckout;
|
||||||
|
import org.atriasoft.island.actions.ManifestStatus;
|
||||||
|
import org.atriasoft.island.actions.VolatileAdd;
|
||||||
|
import org.atriasoft.island.actions.VolatileList;
|
||||||
|
import org.atriasoft.island.actions.VolatileRemove;
|
||||||
|
import org.atriasoft.island.internal.Log;
|
||||||
|
import org.atriasoft.island.model.ActionException;
|
||||||
|
|
||||||
public class MainIsland {
|
public class MainIsland {
|
||||||
|
@ArgCommand("island")
|
||||||
|
@ArgDescription("Package management system: download a specific worktree composed on artefact or real sources")
|
||||||
|
public static class MainConfig {
|
||||||
|
@ArgSubActions
|
||||||
|
static public final ActionList subActions = new ActionList();
|
||||||
|
|
||||||
|
static {
|
||||||
|
MainConfig.subActions.add(BaseInit.class);
|
||||||
|
MainConfig.subActions.add(BaseStatus.class);
|
||||||
|
MainConfig.subActions.add(BaseCheckout.class);
|
||||||
|
MainConfig.subActions.add(BaseSync.class);
|
||||||
|
MainConfig.subActions.add(BaseFetch.class);
|
||||||
|
MainConfig.subActions.add(BaseCommit.class);
|
||||||
|
MainConfig.subActions.add(BasePush.class);
|
||||||
|
MainConfig.subActions.add(VolatileAdd.class);
|
||||||
|
MainConfig.subActions.add(VolatileRemove.class);
|
||||||
|
MainConfig.subActions.add(VolatileList.class);
|
||||||
|
MainConfig.subActions.add(ManifestCheckout.class);
|
||||||
|
MainConfig.subActions.add(ManifestStatus.class);
|
||||||
|
MainConfig.subActions.add(Deliver.class);
|
||||||
|
MainConfig.subActions.add(DependencySync.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ArgName("help")
|
||||||
|
@ArgAlias('h')
|
||||||
|
@ArgDescription("Display the application help")
|
||||||
|
public boolean help = false;
|
||||||
|
|
||||||
|
@ArgName("HELP")
|
||||||
|
@ArgAlias('H')
|
||||||
|
@ArgDescription("Display the application full help (with all actions helps)")
|
||||||
|
public boolean helpFull = false;
|
||||||
|
|
||||||
|
@ArgName("verbose")
|
||||||
|
@ArgAlias('v')
|
||||||
|
@ArgDescription("Display debug level (verbosity)")
|
||||||
|
@ArgChoice({ "none>>0", "error>>1", "warning>>2", "info>>3", "debug>>4", "verbose>>5", "extreme_verbose>>6" })
|
||||||
|
public int verbose = 2;
|
||||||
|
|
||||||
|
@ArgName("color")
|
||||||
|
@ArgAlias('c')
|
||||||
|
@ArgDescription("Display message in color")
|
||||||
|
public boolean color = false;
|
||||||
|
|
||||||
|
@ArgName("no-fetch-manifest")
|
||||||
|
@ArgAlias('n')
|
||||||
|
@ArgDescription("Disable the fetch of the manifest")
|
||||||
|
public boolean fetchManifest = false;
|
||||||
|
|
||||||
|
@ArgName("filter")
|
||||||
|
@ArgAlias('F')
|
||||||
|
@ArgDescription("Filter the action on a list of path or subpath: -f library")
|
||||||
|
public String filter;
|
||||||
|
|
||||||
|
@ArgName("folder")
|
||||||
|
@ArgAlias('f')
|
||||||
|
@ArgDescription("Display the folder instead of the git repository name")
|
||||||
|
public boolean folderDisplay = false;
|
||||||
|
|
||||||
|
@ArgName("wait")
|
||||||
|
@ArgAlias('w')
|
||||||
|
@ArgDescription("Wait between 2 access on the server (needed when the server is really slow to remove ssh connection)")
|
||||||
|
public int wait = 0;
|
||||||
|
|
||||||
|
public void applyConfig() {
|
||||||
|
Env.setWaitBetweenSeverCommand(this.wait);
|
||||||
|
// Logger.setLevel(this.verbose);
|
||||||
|
Env.setDisplayFolderInstead_ofGitName(this.folderDisplay);
|
||||||
|
// Logger.setColor(this.color);
|
||||||
|
Env.setFilterCommand(this.filter);
|
||||||
|
Env.setFetchManifest(this.fetchManifest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean check_boolean(final String value) {
|
||||||
|
if (value.isEmpty() || value.equals("1") || value.equalsIgnoreCase("true")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//debug.verbose("List of actions: " + str(actions.get_list_of_action()))
|
public static void main(final String[] args) throws ActionException {
|
||||||
|
final MainConfig tmp = new MainConfig();
|
||||||
my_args = arguments.Arguments()
|
final ArgumentManager parser = new ArgumentManager(args, tmp, true);
|
||||||
my_args.add_section("option", "Can be set one time in all case")
|
tmp.applyConfig();
|
||||||
my_args.add("h", "help", desc="Display this help")
|
if (tmp.helpFull) {
|
||||||
my_args.add("v", "verbose", list=[
|
parser.showHelpFull();
|
||||||
["0","None"],
|
System.exit(0);
|
||||||
["1","error"],
|
}
|
||||||
["2","warning"],
|
if (tmp.help) {
|
||||||
["3","info"],
|
parser.showHelp();
|
||||||
["4","debug"],
|
System.exit(0);
|
||||||
["5","verbose"],
|
}
|
||||||
["6","extreme_verbose"],
|
if (!parser.hasDetectedAction()) {
|
||||||
], desc="display debug level (verbose) default =2")
|
LOGGER.error("Call The application without require an action...");
|
||||||
my_args.add("c", "color", desc="Display message in color")
|
parser.showHelp();
|
||||||
my_args.add("n", "no-fetch-manifest", haveParam=false, desc="Disable the fetch of the manifest")
|
System.exit(-1);
|
||||||
my_args.add("F", "filter", haveParam=true, desc="Filter the action on a list of path or subpath: -f library")
|
}
|
||||||
my_args.add("f", "folder", haveParam=false, desc="Display the folder instead of the git repository name")
|
if (parser.hasArgumentDetected()) {
|
||||||
my_args.add("w", "wait", haveParam=true, desc="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()) + ")")
|
LOGGER.error("Detected armument unavaillable :" + parser.getArgumentDetected().toString());
|
||||||
my_args.set_stop_at(actions.get_list_of_action())
|
parser.showHelp();
|
||||||
local_argument = my_args.parse()
|
System.exit(-1);
|
||||||
|
}
|
||||||
//
|
parser.executeAction();
|
||||||
// @brief Display the help of this makefile.
|
}
|
||||||
//
|
|
||||||
public void usage():
|
|
||||||
color = debug.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)
|
|
||||||
|
|
||||||
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 debug mode
|
|
||||||
public void parse_generic_arg(argument, active):
|
|
||||||
debug.extreme_verbose("parse arg : " + argument.get_option_name() + " " + argument.get_arg() + " active=" + str(active))
|
|
||||||
if argument.get_option_name() == "help":
|
|
||||||
if active == false:
|
|
||||||
usage()
|
|
||||||
return true
|
|
||||||
elif argument.get_option_name()=="jobs":
|
|
||||||
if active == true:
|
|
||||||
//multiprocess.set_core_number(int(argument.get_arg()))
|
|
||||||
pass
|
|
||||||
return true
|
|
||||||
elif argument.get_option_name()=="wait":
|
|
||||||
if active == true:
|
|
||||||
env.set_wait_between_sever_command(int(argument.get_arg()))
|
|
||||||
return true
|
|
||||||
elif argument.get_option_name() == "verbose":
|
|
||||||
if active == true:
|
|
||||||
debug.set_level(int(argument.get_arg()))
|
|
||||||
return true
|
|
||||||
elif argument.get_option_name() == "folder":
|
|
||||||
if active == true:
|
|
||||||
env.set_display_folder_instead_of_git_name(true)
|
|
||||||
return true
|
|
||||||
elif argument.get_option_name() == "color":
|
|
||||||
if active == true:
|
|
||||||
if check_boolean(argument.get_arg()) == true:
|
|
||||||
debug.enable_color()
|
|
||||||
else:
|
|
||||||
debug.disable_color()
|
|
||||||
return true
|
|
||||||
elif argument.get_option_name() == "filter":
|
|
||||||
if active == true:
|
|
||||||
env.set_filter_command(str(argument.get_arg()))
|
|
||||||
return true
|
|
||||||
elif argument.get_option_name() == "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))
|
|
||||||
debug.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()
|
|
||||||
debug.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()
|
|
||||||
debug.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()
|
|
||||||
debug.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()
|
|
||||||
debug.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()
|
|
||||||
debug.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()
|
|
||||||
debug.debug(" get default config 'get_default_filter' val='" + str(data) + "'")
|
|
||||||
parse_generic_arg(arg_element.ArgElement("filter", str(data)), true)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 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:
|
|
||||||
debug.warning("--------------------------------------")
|
|
||||||
debug.warning("Missing the action to do ...")
|
|
||||||
debug.warning("--------------------------------------")
|
|
||||||
usage()
|
|
||||||
|
|
||||||
|
|
||||||
// TODO : move tin in actions ...
|
|
||||||
list_actions = actions.get_list_of_action();
|
|
||||||
|
|
||||||
action_to_do = new_argument_list[0].get_arg()
|
|
||||||
new_argument_list = new_argument_list[1:]
|
|
||||||
if action_to_do not in list_actions:
|
|
||||||
debug.warning("--------------------------------------")
|
|
||||||
debug.warning("Wrong action type : '" + str(action_to_do) + "' availlable list: " + str(list_actions) )
|
|
||||||
debug.warning("--------------------------------------")
|
|
||||||
usage()
|
|
||||||
|
|
||||||
// todo : Remove this
|
|
||||||
if action_to_do != "init" \
|
|
||||||
and os.path.exists(env.get_island_path()) == false:
|
|
||||||
debug.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()
|
|
||||||
|
|
||||||
|
|
317
src/org/atriasoft/island/Manifest.java
Normal file
317
src/org/atriasoft/island/Manifest.java
Normal file
@ -0,0 +1,317 @@
|
|||||||
|
package org.atriasoft.island;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.atriasoft.aknot.exception.AknotException;
|
||||||
|
import org.atriasoft.exml.XmlMapper;
|
||||||
|
import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||||
|
import org.atriasoft.exml.exception.ExmlException;
|
||||||
|
import org.atriasoft.exml.exception.ExmlParserErrorMulti;
|
||||||
|
import org.atriasoft.island.internal.Log;
|
||||||
|
import org.atriasoft.island.model.manifest.Artifactory;
|
||||||
|
import org.atriasoft.island.model.manifest.DeliverMode;
|
||||||
|
import org.atriasoft.island.model.manifest.Dependency;
|
||||||
|
import org.atriasoft.island.model.manifest.Link;
|
||||||
|
import org.atriasoft.island.model.manifest.ManifestFile;
|
||||||
|
import org.atriasoft.island.model.manifest.OptionRepository;
|
||||||
|
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||||
|
import org.atriasoft.island.model.manifest.RemoteConfig;
|
||||||
|
|
||||||
|
public class Manifest {
|
||||||
|
public static void checkIsInit() {
|
||||||
|
// check if .XXX exist (create it if needed)
|
||||||
|
if (!Manifest.isInit()) {
|
||||||
|
LOGGER.error("System not init: missing config: '" + Env.getIslandPath() + "'. Call <island init> first");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isInit() {
|
||||||
|
if (!Files.exists(Env.getIslandPath())) {
|
||||||
|
LOGGER.trace("Lutin is not init: path does not exist: '" + Env.getIslandPath() + "'");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!Files.exists(Env.getIslandPathConfig())) {
|
||||||
|
LOGGER.trace("Lutin is not init: config does not exist: '" + Env.getIslandPathConfig() + "'");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!Files.exists(Env.getIslandPathManifest())) {
|
||||||
|
LOGGER.trace("Lutin is not init: Manifest does not exist: '" + Env.getIslandPathManifest() + "'");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Path manifestXml;
|
||||||
|
|
||||||
|
private String rootManifest;
|
||||||
|
private final Map<String, ManifestFile> manifests = new HashMap<>();
|
||||||
|
|
||||||
|
OptionRepository defaultWhat = null;
|
||||||
|
|
||||||
|
OptionRepository defaultBase = new OptionRepository();
|
||||||
|
|
||||||
|
public Manifest(final Path manifestXml) throws IOException {
|
||||||
|
this.manifestXml = manifestXml;
|
||||||
|
// load the manifest
|
||||||
|
try {
|
||||||
|
load();
|
||||||
|
} catch (final ExmlBuilderException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// check error in manifest (double path ...)
|
||||||
|
// TODO checkDoublePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
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 List<ProjectConfig> get_all_configs() {
|
||||||
|
final ManifestFile mani = this.manifests.get(this.rootManifest);
|
||||||
|
return get_all_configs(mani, null, new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ProjectConfig> get_all_configs(final ManifestFile mani, OptionRepository defaultPlouf, final List<RemoteConfig> upper_remotes) {
|
||||||
|
final List<ProjectConfig> out = new ArrayList<>();
|
||||||
|
if (defaultPlouf == null) {
|
||||||
|
if (this.defaultWhat != null) {
|
||||||
|
defaultPlouf = this.defaultWhat.clone();
|
||||||
|
} else {
|
||||||
|
defaultPlouf = this.defaultBase.clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// LOGGER.error(" this.default=" + str(this.default))
|
||||||
|
// add all local project
|
||||||
|
for (final ProjectConfig elem : mani.getProjects()) {
|
||||||
|
LOGGER.trace("parse element " + elem);
|
||||||
|
if (!Env.needProcessWithFilter(elem.getName())) {
|
||||||
|
LOGGER.info("Filter repository: " + elem.getName());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final ProjectConfig conf = new ProjectConfig(elem.getName(), createPathWithElem(elem), elem.getTag());
|
||||||
|
|
||||||
|
// add default remote for the project (search in herited element)
|
||||||
|
for (final RemoteConfig remote : mani.getRemotes()) {
|
||||||
|
LOGGER.trace(" Local Remote: " + remote);
|
||||||
|
if (remote.getName().equals(defaultPlouf.getDefaultRemote())) {
|
||||||
|
conf.getRemotes().add(remote);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (conf.getRemotes().size() == 0) {
|
||||||
|
for (final RemoteConfig remote : upper_remotes) {
|
||||||
|
LOGGER.trace(" upper Remote: " + remote);
|
||||||
|
if (remote.getName() != null && remote.getName().equals(defaultPlouf.getDefaultRemote())) {
|
||||||
|
conf.getRemotes().add(remote);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (conf.getRemotes().size() == 0) {
|
||||||
|
LOGGER.error(" No remote detected: " + conf.getRemotes().size() + " for " + conf.getName() + " with default remote name : " + defaultPlouf.getDefaultRemote() + " this remote: "
|
||||||
|
+ mani.getRemotes());
|
||||||
|
}
|
||||||
|
// select default remote:
|
||||||
|
LOGGER.debug(" remotes count: " + conf.getRemotes().size());
|
||||||
|
for (final RemoteConfig remote : conf.getRemotes()) {
|
||||||
|
LOGGER.debug(" remote=" + remote);
|
||||||
|
LOGGER.debug(" Ckeck remote : " + remote.getName() + ".equals(" + defaultPlouf.getDefaultRemote());
|
||||||
|
LOGGER.trace(" remote=" + remote);
|
||||||
|
LOGGER.trace(" default=" + defaultPlouf);
|
||||||
|
if (remote.getName().equals(defaultPlouf.getDefaultRemote())) {
|
||||||
|
conf.setSelectRemotes(remote.clone());
|
||||||
|
LOGGER.debug(" copy select=" + conf.getSelectRemotes());
|
||||||
|
|
||||||
|
// copy the submodule synchronisation
|
||||||
|
// TODO: ????? conf.getSelectRemotes().setSync(defaultPlouf.isSync());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (conf.getSelectRemotes() == null) {
|
||||||
|
LOGGER.error("missing remote for project: " + conf.getName());
|
||||||
|
}
|
||||||
|
conf.setBranch(defaultPlouf.getDefaultBranch());
|
||||||
|
out.add(conf);
|
||||||
|
}
|
||||||
|
// create a temporary variable to transmit the remote to includes
|
||||||
|
final List<RemoteConfig> upper_remotes_forward = new ArrayList<>(upper_remotes);
|
||||||
|
for (final RemoteConfig remote : mani.getRemotes()) {
|
||||||
|
upper_remotes_forward.add(remote);
|
||||||
|
}
|
||||||
|
// add all include project
|
||||||
|
for (final String elemInclude : mani.getIncludes()) {
|
||||||
|
final ManifestFile mani2 = this.manifests.get(elemInclude);
|
||||||
|
final List<ProjectConfig> list_project = get_all_configs(mani2, defaultPlouf, upper_remotes_forward);
|
||||||
|
for (final ProjectConfig elem_proj : list_project) {
|
||||||
|
out.add(elem_proj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DEPRECIATE volatile for a while?.????
|
||||||
|
//# -------------------------------------------------------------
|
||||||
|
//# -- add Volatile ...
|
||||||
|
//# -------------------------------------------------------------
|
||||||
|
LOGGER.trace("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:
|
||||||
|
LOGGER.info("list of all repo:")
|
||||||
|
for elem in out:
|
||||||
|
LOGGER.info(" '" + elem.name + "'")
|
||||||
|
LOGGER.info(" path: " + elem.path)
|
||||||
|
LOGGER.info(" remotes: " + str(elem.remotes))
|
||||||
|
LOGGER.info(" select_remote: " + str(elem.select_remote))
|
||||||
|
LOGGER.info(" branch: " + elem.branch)
|
||||||
|
*/
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Artifactory> getAllArtefactories() {
|
||||||
|
final ManifestFile mani = this.manifests.get(this.rootManifest);
|
||||||
|
return getAllArtefactories(mani);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Artifactory> getAllArtefactories(final ManifestFile mani) {
|
||||||
|
final List<Artifactory> out = new ArrayList<>();
|
||||||
|
// add all local project
|
||||||
|
for (final Artifactory elem : mani.getArtefactories()) {
|
||||||
|
LOGGER.trace("parse a " + elem);
|
||||||
|
final Artifactory conf = elem.clone();
|
||||||
|
out.add(conf);
|
||||||
|
}
|
||||||
|
// add all include project
|
||||||
|
for (final String elemInclude : mani.getIncludes()) {
|
||||||
|
final ManifestFile mani2 = this.manifests.get(elemInclude);
|
||||||
|
final List<Artifactory> list_project = getAllArtefactories(mani2);
|
||||||
|
for (final Artifactory elem_proj : list_project) {
|
||||||
|
out.add(elem_proj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Dependency> getAllDependencies() {
|
||||||
|
final ManifestFile mani = this.manifests.get(this.rootManifest);
|
||||||
|
return getAllDependencies(mani);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Dependency> getAllDependencies(final ManifestFile mani) {
|
||||||
|
final List<Dependency> out = new ArrayList<>(mani.getDependencies());
|
||||||
|
// add all include project
|
||||||
|
for (final String elemInclude : mani.getIncludes()) {
|
||||||
|
final ManifestFile mani2 = this.manifests.get(elemInclude);
|
||||||
|
out.addAll(getAllDependencies(mani2));
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBranchRelease() {
|
||||||
|
OptionRepository defaultPlouf = this.defaultBase;
|
||||||
|
if (this.defaultWhat != null) {
|
||||||
|
defaultPlouf = this.defaultWhat;
|
||||||
|
}
|
||||||
|
return defaultPlouf.getBranchRelease();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeliverDevelop() {
|
||||||
|
OptionRepository defaultPlouf = this.defaultBase;
|
||||||
|
if (this.defaultWhat != null) {
|
||||||
|
defaultPlouf = this.defaultWhat;
|
||||||
|
}
|
||||||
|
return defaultPlouf.getBranchDevelop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeliverMode getDeliverModeMerge() {
|
||||||
|
OptionRepository defaultPlouf = this.defaultBase;
|
||||||
|
if (this.defaultWhat != null) {
|
||||||
|
defaultPlouf = this.defaultWhat;
|
||||||
|
}
|
||||||
|
return defaultPlouf.getDeliverMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Link> getLinks() {
|
||||||
|
final List<Link> out = new ArrayList<>();
|
||||||
|
for (final Entry<String, ManifestFile> elem : this.manifests.entrySet()) {
|
||||||
|
for (final Link link : elem.getValue().getLinks()) {
|
||||||
|
out.add(link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load() throws ExmlParserErrorMulti, ExmlBuilderException, IOException {
|
||||||
|
Path rootDirectory = this.manifestXml.toAbsolutePath();
|
||||||
|
this.rootManifest = rootDirectory.getFileName().toString();
|
||||||
|
rootDirectory = rootDirectory.getParent();
|
||||||
|
|
||||||
|
LOGGER.debug("PArse main XML config " + rootDirectory);
|
||||||
|
ManifestFile parsedElements = null;
|
||||||
|
final XmlMapper mapper = new XmlMapper();
|
||||||
|
try {
|
||||||
|
parsedElements = mapper.parse(this.manifestXml, ManifestFile.class);
|
||||||
|
} catch (final ExmlException | AknotException e1) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
parsedElements.setFileRealPath(this.manifestXml);
|
||||||
|
this.manifests.put(this.rootManifest, parsedElements);
|
||||||
|
for (final String includeElem : parsedElements.getIncludes()) {
|
||||||
|
final Path maniPath = rootDirectory.resolve(includeElem);
|
||||||
|
LOGGER.debug("PArse <<SUB>> XML config " + maniPath);
|
||||||
|
ManifestFile tmpManifest = null;
|
||||||
|
try {
|
||||||
|
tmpManifest = mapper.parse(maniPath, ManifestFile.class);
|
||||||
|
} catch (final ExmlException | AknotException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
tmpManifest.setFileRealPath(maniPath);
|
||||||
|
this.manifests.put(includeElem, tmpManifest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String removeEndSlash(String value) {
|
||||||
|
while (value.length() > 1 && (value.charAt(value.length() - 1) == '\\' || value.charAt(value.length() - 1) == '/')) {
|
||||||
|
value = value.substring(0, value.length() - 1);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
143
src/org/atriasoft/island/Tools.java
Normal file
143
src/org/atriasoft/island/Tools.java
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
package org.atriasoft.island;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.island.internal.Log;
|
||||||
|
import org.atriasoft.island.model.manifest.Dependency;
|
||||||
|
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||||
|
|
||||||
|
public class Tools {
|
||||||
|
|
||||||
|
public static void createDirectory(final Path basePath) {
|
||||||
|
Path absPath = basePath.toAbsolutePath();
|
||||||
|
if (!Files.exists(absPath)) {
|
||||||
|
try {
|
||||||
|
Files.createDirectory(absPath);
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOGGER.error("Errro while creating path ... " + e.getMessage());
|
||||||
|
LOGGER.error("Path ... " + absPath);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void createSymbolicLink(Path link, Path target) throws IOException {
|
||||||
|
LOGGER.warn("create Link {} -> {}", link, target);
|
||||||
|
createDirectory(link.getParent());
|
||||||
|
if (Files.exists(link)) {
|
||||||
|
Files.delete(link);
|
||||||
|
}
|
||||||
|
Files.createSymbolicLink(link, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void fileWriteData(final Path path, final String data) {
|
||||||
|
|
||||||
|
Path tmpFile = path.getParent().resolve(path.getFileName() + "__tmp");
|
||||||
|
if (!Files.exists(path.getParent())) {
|
||||||
|
File file = path.getParent().toFile();
|
||||||
|
if (!file.mkdirs()) {
|
||||||
|
LOGGER.critical("Can not create the path:" + path.getParent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Files.writeString(tmpFile, data);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// this is the way to have atomic replacement of file and not partial downloaded file ==> move is 99.999999% atomic.
|
||||||
|
try {
|
||||||
|
Files.move(tmpFile, path, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
|
||||||
|
} catch (IOException e) {
|
||||||
|
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getListBaseDisplay(final int id, final int count, final Dependency elem) {
|
||||||
|
if (!Env.getDisplayFolderInsteadOfGitName()) {
|
||||||
|
return id + "/" + count + " : " + elem.name();
|
||||||
|
}
|
||||||
|
return id + "/" + count + " : " + elem.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getListBaseDisplay(final int id, final int count, final ProjectConfig elem) {
|
||||||
|
if (!Env.getDisplayFolderInsteadOfGitName()) {
|
||||||
|
return id + "/" + count + " : " + elem.getName();
|
||||||
|
}
|
||||||
|
return id + "/" + count + " : " + elem.getPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getPlural(final List<?> artefactories) {
|
||||||
|
return artefactories.size() > 1 ? "ies" : "y";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String readFile(final Path path, final Charset encoding) throws IOException {
|
||||||
|
byte[] encoded = Files.readAllBytes(path);
|
||||||
|
return new String(encoded, encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the split of the generic version :
|
||||||
|
* - 1.5.2-dev
|
||||||
|
* @param version
|
||||||
|
* @return list of element : {"1", "5", "2", "dev"}
|
||||||
|
*/
|
||||||
|
public static String[] versionStringToList(final String version) {
|
||||||
|
LOGGER.trace("parse version string '" + version + "'");
|
||||||
|
List<String> out = new ArrayList<>();
|
||||||
|
if (version == null || version.isEmpty()) {
|
||||||
|
return new String[] { "0", "0", "0" };
|
||||||
|
}
|
||||||
|
String[] elems = version.split("-");
|
||||||
|
if (elems[0].split(".").length <= 1) {
|
||||||
|
LOGGER.critical("Can not parde a version with wrong version model '" + version + "'");
|
||||||
|
}
|
||||||
|
List<String> values = Arrays.asList(elems[0].split("."));
|
||||||
|
for (String elem : values) {
|
||||||
|
out.add(elem);
|
||||||
|
}
|
||||||
|
if (elems.length >= 2) {
|
||||||
|
out.add(elems[1]);
|
||||||
|
}
|
||||||
|
return out.toArray(new String[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String versionToString(final int[] version, final boolean develop) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (int iii = 0; iii < version.length; iii++) {
|
||||||
|
if (sb.length() != 0) {
|
||||||
|
sb.append(".");
|
||||||
|
}
|
||||||
|
sb.append(Integer.toString(version[iii]));
|
||||||
|
}
|
||||||
|
if (develop) {
|
||||||
|
sb.append("-dev");
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void waitForServerIfNeeded() {
|
||||||
|
int waitTime = Env.getWaitBetweenSeverCommand();
|
||||||
|
if (waitTime > 0) {
|
||||||
|
LOGGER.info("Waiting between commands: " + waitTime + "s");
|
||||||
|
try {
|
||||||
|
Thread.sleep(waitTime * 1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
71
src/org/atriasoft/island/actions/BaseCheckout.java
Normal file
71
src/org/atriasoft/island/actions/BaseCheckout.java
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package org.atriasoft.island.actions;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.death.annotation.ArgAlias;
|
||||||
|
import org.atriasoft.death.annotation.ArgCommand;
|
||||||
|
import org.atriasoft.death.annotation.ArgDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgExecute;
|
||||||
|
import org.atriasoft.death.annotation.ArgName;
|
||||||
|
import org.atriasoft.death.annotation.ArgParams;
|
||||||
|
import org.atriasoft.death.annotation.ArgParamsDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgSample;
|
||||||
|
import org.atriasoft.island.Config;
|
||||||
|
import org.atriasoft.island.Env;
|
||||||
|
import org.atriasoft.island.Manifest;
|
||||||
|
import org.atriasoft.island.Tools;
|
||||||
|
import org.atriasoft.island.internal.Log;
|
||||||
|
import org.atriasoft.island.model.ActionException;
|
||||||
|
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||||
|
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||||
|
|
||||||
|
@ArgCommand("checkout")
|
||||||
|
@ArgDescription("Ckeckout a specific branch in all repository")
|
||||||
|
@ArgSample({
|
||||||
|
"checkout dev",
|
||||||
|
"checkout -r github master",
|
||||||
|
"checkout -r=gitlab master",
|
||||||
|
})
|
||||||
|
public class BaseCheckout {
|
||||||
|
@ArgName("remote")
|
||||||
|
@ArgAlias('r')
|
||||||
|
@ArgDescription("Name of the remote server")
|
||||||
|
public String remote = null;
|
||||||
|
|
||||||
|
@ArgExecute
|
||||||
|
@ArgParams("branch")
|
||||||
|
@ArgParamsDescription("Branch to checkout (if '__TAG__' ==> checkout specific repository tags)")
|
||||||
|
public void execute(final String branch) throws ActionException, Exception {
|
||||||
|
// check system is OK
|
||||||
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
|
// update the local configuration file{
|
||||||
|
configuration.setBranch(branch);
|
||||||
|
configuration.store();
|
||||||
|
|
||||||
|
Path file_source_manifest = Env.getIslandPathManifest().resolve(configuration.getManifestName());
|
||||||
|
if (!Files.exists(file_source_manifest)) {
|
||||||
|
LOGGER.critical("Missing manifest file { '" + file_source_manifest.toAbsolutePath() + "'");
|
||||||
|
}
|
||||||
|
Manifest mani = new Manifest(file_source_manifest);
|
||||||
|
|
||||||
|
List<ProjectConfig> all_project = mani.get_all_configs();
|
||||||
|
LOGGER.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.getListBaseDisplay(id_element, all_project.size(), elem);
|
||||||
|
if (!StatusActions.checkoutElem(elem, this.remote, branch, base_display)) {
|
||||||
|
have_error = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (have_error == true) {
|
||||||
|
LOGGER.error("Checkout have fail !!! ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
85
src/org/atriasoft/island/actions/BaseCommit.java
Normal file
85
src/org/atriasoft/island/actions/BaseCommit.java
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
package org.atriasoft.island.actions;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.death.annotation.ArgAlias;
|
||||||
|
import org.atriasoft.death.annotation.ArgCommand;
|
||||||
|
import org.atriasoft.death.annotation.ArgDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgExecute;
|
||||||
|
import org.atriasoft.death.annotation.ArgName;
|
||||||
|
import org.atriasoft.death.annotation.ArgSample;
|
||||||
|
import org.atriasoft.island.Commands;
|
||||||
|
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.manifest.ConfigManifest;
|
||||||
|
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.api.Git;
|
||||||
|
|
||||||
|
@ArgCommand("commit")
|
||||||
|
@ArgDescription("commit in all repository")
|
||||||
|
@ArgSample("commit -a --amend -m \"[DEV] your comment\"")
|
||||||
|
public class BaseCommit {
|
||||||
|
|
||||||
|
@ArgName("message")
|
||||||
|
@ArgAlias('m')
|
||||||
|
@ArgDescription("commit message to set on all modify repository")
|
||||||
|
public String message = "---No commit message---";
|
||||||
|
|
||||||
|
@ArgName("amend")
|
||||||
|
@ArgDescription("Ammend data to the previous commit")
|
||||||
|
public boolean amend = false;
|
||||||
|
|
||||||
|
@ArgName("all")
|
||||||
|
@ArgAlias('a')
|
||||||
|
@ArgDescription("All file are added")
|
||||||
|
public boolean all = false;
|
||||||
|
|
||||||
|
@ArgExecute
|
||||||
|
public void execute() throws ActionException, Exception {
|
||||||
|
|
||||||
|
// check system is OK
|
||||||
|
Manifest.checkIsInit();
|
||||||
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
// load the manifest after pulling it (if possible)
|
||||||
|
Path file_source_manifest = Env.getIslandPathManifest().resolve(configuration.getManifestName());
|
||||||
|
if (!Files.exists(file_source_manifest)) {
|
||||||
|
LOGGER.critical("Missing manifest file : '" + file_source_manifest + "'");
|
||||||
|
}
|
||||||
|
Manifest mani = new Manifest(file_source_manifest);
|
||||||
|
|
||||||
|
List<ProjectConfig> all_project = mani.get_all_configs();
|
||||||
|
LOGGER.print("Commit of: " + all_project.size() + " projects");
|
||||||
|
int id_element = 0;
|
||||||
|
|
||||||
|
for (ProjectConfig elem : all_project) {
|
||||||
|
id_element++;
|
||||||
|
String base_display = Tools.getListBaseDisplay(id_element, all_project.size(), elem);
|
||||||
|
LOGGER.info("commit : " + base_display);
|
||||||
|
Path git_repo_path = Env.getIslandRootPath().resolve(elem.getPath());
|
||||||
|
if ( !Commands.isGitRepository(git_repo_path.toString())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Git git = Git.open(git_repo_path.toFile());
|
||||||
|
boolean is_modify = git.status().call().hasUncommittedChanges();
|
||||||
|
if (!is_modify) {
|
||||||
|
LOGGER.info("Not modify skip !! ");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// simply update the repository ...
|
||||||
|
git.commit()
|
||||||
|
.setAll(this.all)
|
||||||
|
.setAmend(this.amend)
|
||||||
|
.setMessage(this.message)
|
||||||
|
.call();
|
||||||
|
LOGGER.print("[" + elem.getName() + "] commit done");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
89
src/org/atriasoft/island/actions/BaseFetch.java
Normal file
89
src/org/atriasoft/island/actions/BaseFetch.java
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
package org.atriasoft.island.actions;
|
||||||
|
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.death.annotation.ArgAlias;
|
||||||
|
import org.atriasoft.death.annotation.ArgCommand;
|
||||||
|
import org.atriasoft.death.annotation.ArgDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgExecute;
|
||||||
|
import org.atriasoft.death.annotation.ArgName;
|
||||||
|
import org.atriasoft.death.annotation.ArgSample;
|
||||||
|
import org.atriasoft.island.Commands;
|
||||||
|
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.manifest.ConfigManifest;
|
||||||
|
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.api.Git;
|
||||||
|
import org.eclipse.jgit.lib.TextProgressMonitor;
|
||||||
|
|
||||||
|
@ArgCommand("push")
|
||||||
|
@ArgDescription("Update all the repository remote branch")
|
||||||
|
@ArgSample("fetch --remote=github")
|
||||||
|
public class BaseFetch {
|
||||||
|
|
||||||
|
@ArgName("remote")
|
||||||
|
@ArgAlias('r')
|
||||||
|
@ArgDescription("Name of the remote server")
|
||||||
|
public String remote = "origin";
|
||||||
|
|
||||||
|
@ArgExecute
|
||||||
|
public void execute() throws ActionException, Exception {
|
||||||
|
|
||||||
|
// check system is OK
|
||||||
|
Manifest.checkIsInit();
|
||||||
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
|
// fetch or pull the manifest in case...
|
||||||
|
{
|
||||||
|
Git git = Git.open(Env.getIslandPathManifest().toFile());
|
||||||
|
git.fetch().setRemote(this.remote).call();
|
||||||
|
}
|
||||||
|
// load the manifest after pulling it (if possible)
|
||||||
|
Path file_source_manifest = Env.getIslandPathManifest().resolve(configuration.getManifestName());
|
||||||
|
if (!Files.exists(file_source_manifest)) {
|
||||||
|
LOGGER.critical("Missing manifest file : '" + file_source_manifest + "'");
|
||||||
|
}
|
||||||
|
Manifest mani = new Manifest(file_source_manifest);
|
||||||
|
|
||||||
|
List<ProjectConfig> all_project = mani.get_all_configs();
|
||||||
|
LOGGER.info("Synchronize of: " + all_project.size() + " projects");
|
||||||
|
int id_element = 0;
|
||||||
|
|
||||||
|
for (ProjectConfig elem : all_project) {
|
||||||
|
id_element++;
|
||||||
|
String base_display = Tools.getListBaseDisplay(id_element, all_project.size(), elem);
|
||||||
|
LOGGER.print("fetch : " + base_display);
|
||||||
|
Tools.waitForServerIfNeeded();
|
||||||
|
LOGGER.debug("elem : " + elem);
|
||||||
|
Path git_repo_path = Env.getIslandRootPath().resolve(elem.getPath());
|
||||||
|
if (elem.getTag() != null) {
|
||||||
|
LOGGER.info("[TODO] Need to select a specific tag version ... " + elem.getTag());
|
||||||
|
}
|
||||||
|
if (!Commands.isGitRepository(elem.getPath())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// simply update the repository ...
|
||||||
|
LOGGER.trace("Fetching project: ");
|
||||||
|
{
|
||||||
|
Git git = Git.open(git_repo_path.toFile());
|
||||||
|
git.fetch()
|
||||||
|
.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
|
||||||
|
.setRemote(elem.getSelectRemotes().getName())
|
||||||
|
.call();
|
||||||
|
LOGGER.info("[" + elem.getName() + "] fetch done");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Update the links:
|
||||||
|
//TODO: have_error = update_links.update(configuration, mani, "sync-local")
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
73
src/org/atriasoft/island/actions/BaseInit.java
Normal file
73
src/org/atriasoft/island/actions/BaseInit.java
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package org.atriasoft.island.actions;
|
||||||
|
|
||||||
|
import org.atriasoft.death.annotation.ArgAlias;
|
||||||
|
import org.atriasoft.death.annotation.ArgCommand;
|
||||||
|
import org.atriasoft.death.annotation.ArgDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgExecute;
|
||||||
|
import org.atriasoft.death.annotation.ArgName;
|
||||||
|
import org.atriasoft.death.annotation.ArgParams;
|
||||||
|
import org.atriasoft.death.annotation.ArgSample;
|
||||||
|
import org.atriasoft.island.Config;
|
||||||
|
import org.atriasoft.island.Env;
|
||||||
|
import org.atriasoft.island.Manifest;
|
||||||
|
import org.atriasoft.island.Tools;
|
||||||
|
import org.atriasoft.island.internal.Log;
|
||||||
|
import org.atriasoft.island.model.ActionException;
|
||||||
|
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.api.Git;
|
||||||
|
import org.eclipse.jgit.transport.SshSessionFactory;
|
||||||
|
import org.eclipse.jgit.transport.sshd.DefaultProxyDataFactory;
|
||||||
|
import org.eclipse.jgit.transport.sshd.JGitKeyCache;
|
||||||
|
import org.eclipse.jgit.transport.sshd.SshdSessionFactory;
|
||||||
|
|
||||||
|
|
||||||
|
@ArgCommand("init")
|
||||||
|
@ArgDescription("Initialize an island workspace (need 'fetch' after)")
|
||||||
|
@ArgSample("init http://github.com/atria-soft/manifest.git")
|
||||||
|
public class BaseInit {
|
||||||
|
@ArgName("branch")
|
||||||
|
@ArgAlias('b')
|
||||||
|
@ArgDescription("Select the branch to checkout")
|
||||||
|
public String branch = "master";
|
||||||
|
|
||||||
|
@ArgName("manifest")
|
||||||
|
@ArgAlias('m')
|
||||||
|
@ArgDescription("name of the root manifest file")
|
||||||
|
public String manifestFile = "default.xml";
|
||||||
|
|
||||||
|
@ArgExecute
|
||||||
|
@ArgParams("Manifest Address")
|
||||||
|
public void execute(final String addressManifest) throws ActionException, Exception {
|
||||||
|
if (addressManifest.isEmpty()) {
|
||||||
|
LOGGER.critical("Init: Missing manifest name");
|
||||||
|
}
|
||||||
|
LOGGER.info("Init with: '" + addressManifest + "' branch='" + this.branch + "' name of manifest='" + this.manifestFile + "'");
|
||||||
|
if (Manifest.isInit()) {
|
||||||
|
LOGGER.critical("System already init: path already exist: '" + Env.getIslandPath() + "'");
|
||||||
|
}
|
||||||
|
Tools.createDirectory(Env.getIslandPath());
|
||||||
|
|
||||||
|
// create the file configuration:
|
||||||
|
ConfigManifest configuration = Config.createUniqueConfig();
|
||||||
|
configuration.setRepo(addressManifest);
|
||||||
|
configuration.setBranch(this.branch);
|
||||||
|
configuration.setManifestName(this.manifestFile);
|
||||||
|
configuration.store();
|
||||||
|
|
||||||
|
Tools.createDirectory(Env.getIslandPathManifest());
|
||||||
|
LOGGER.info("Clone the manifest");
|
||||||
|
// init session on apache ssh:
|
||||||
|
SshdSessionFactory factory = new SshdSessionFactory(new JGitKeyCache(), new DefaultProxyDataFactory());
|
||||||
|
//LOGGER.error("iiii " + factory.getSshDirectory());
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread(factory::close));
|
||||||
|
SshSessionFactory.setInstance(factory);
|
||||||
|
|
||||||
|
Git git = Git.cloneRepository()
|
||||||
|
.setURI( addressManifest )
|
||||||
|
.setDirectory( Env.getIslandPathManifest().toFile() )
|
||||||
|
.setBranch(this.branch)
|
||||||
|
.call();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
89
src/org/atriasoft/island/actions/BasePush.java
Normal file
89
src/org/atriasoft/island/actions/BasePush.java
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
package org.atriasoft.island.actions;
|
||||||
|
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.death.annotation.ArgAlias;
|
||||||
|
import org.atriasoft.death.annotation.ArgCommand;
|
||||||
|
import org.atriasoft.death.annotation.ArgDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgExecute;
|
||||||
|
import org.atriasoft.death.annotation.ArgName;
|
||||||
|
import org.atriasoft.death.annotation.ArgSample;
|
||||||
|
import org.atriasoft.island.Commands;
|
||||||
|
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.manifest.ConfigManifest;
|
||||||
|
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||||
|
import org.eclipse.jgit.api.Git;
|
||||||
|
import org.eclipse.jgit.lib.TextProgressMonitor;
|
||||||
|
import org.eclipse.jgit.transport.PushResult;
|
||||||
|
|
||||||
|
@ArgCommand("push")
|
||||||
|
@ArgDescription("Push all repository to the upper server")
|
||||||
|
@ArgSample("push --remote=github")
|
||||||
|
public class BasePush {
|
||||||
|
@ArgName("remote")
|
||||||
|
@ArgAlias('r')
|
||||||
|
@ArgDescription("Name of the remote server")
|
||||||
|
public String remote = "origin";
|
||||||
|
|
||||||
|
@ArgName("force")
|
||||||
|
@ArgAlias('f')
|
||||||
|
@ArgDescription("Force the push on the remote")
|
||||||
|
public boolean force = false;
|
||||||
|
|
||||||
|
@ArgName("dry-run")
|
||||||
|
@ArgDescription("simulate all actions")
|
||||||
|
public boolean dryRun = false;
|
||||||
|
|
||||||
|
@ArgExecute
|
||||||
|
public void execute() throws ActionException, Exception {
|
||||||
|
String dryRunComment = this.dryRun ? " (DRY-RUN)" : "";
|
||||||
|
// check system is OK
|
||||||
|
Manifest.checkIsInit();
|
||||||
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
// load the manifest after pulling it (if possible)
|
||||||
|
Path file_source_manifest = Env.getIslandPathManifest().resolve(configuration.getManifestName());
|
||||||
|
Manifest mani = new Manifest(file_source_manifest);
|
||||||
|
|
||||||
|
List<ProjectConfig> all_project = mani.get_all_configs();
|
||||||
|
LOGGER.info("Synchronize of: " + all_project.size() + " projects");
|
||||||
|
int id_element = 0;
|
||||||
|
|
||||||
|
for (ProjectConfig elem : all_project) {
|
||||||
|
id_element++;
|
||||||
|
String base_display = Tools.getListBaseDisplay(id_element, all_project.size(), elem);
|
||||||
|
LOGGER.print("push : " + base_display + dryRunComment);
|
||||||
|
Tools.waitForServerIfNeeded();
|
||||||
|
LOGGER.debug("elem : " + elem);
|
||||||
|
Path git_repo_path = Env.getIslandRootPath().resolve(elem.getPath());
|
||||||
|
if (!Commands.isGitRepository(elem.getPath())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// simply update the repository ...
|
||||||
|
LOGGER.trace("push project: ");
|
||||||
|
{
|
||||||
|
Git git = Git.open(git_repo_path.toFile());
|
||||||
|
String select_branch = git.getRepository().getBranch();
|
||||||
|
|
||||||
|
Iterable<PushResult> plo = git.push() //
|
||||||
|
.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out))) //
|
||||||
|
.setRemote(elem.getSelectRemotes().getName()) //
|
||||||
|
.setForce(this.force) //
|
||||||
|
.add(select_branch) //
|
||||||
|
.setDryRun(this.dryRun) //
|
||||||
|
.call();
|
||||||
|
LOGGER.trace("plop " + plo.hashCode());
|
||||||
|
LOGGER.info("[" + elem.getName() + "] fetch done " + dryRunComment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Update the links:
|
||||||
|
//TODO: have_error = update_links.update(configuration, mani, "sync-local")
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
79
src/org/atriasoft/island/actions/BaseStatus.java
Normal file
79
src/org/atriasoft/island/actions/BaseStatus.java
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
package org.atriasoft.island.actions;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.death.annotation.ArgAlias;
|
||||||
|
import org.atriasoft.death.annotation.ArgCommand;
|
||||||
|
import org.atriasoft.death.annotation.ArgDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgExecute;
|
||||||
|
import org.atriasoft.death.annotation.ArgName;
|
||||||
|
import org.atriasoft.death.annotation.ArgSample;
|
||||||
|
import org.atriasoft.island.Config;
|
||||||
|
import org.atriasoft.island.Env;
|
||||||
|
import org.atriasoft.island.Manifest;
|
||||||
|
import org.atriasoft.island.Tools;
|
||||||
|
import org.atriasoft.island.internal.Log;
|
||||||
|
import org.atriasoft.island.model.ActionException;
|
||||||
|
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||||
|
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.api.Git;
|
||||||
|
|
||||||
|
@ArgCommand("status")
|
||||||
|
@ArgDescription("Get the status of all the repositories")
|
||||||
|
@ArgSample("status --tags")
|
||||||
|
public class BaseStatus {
|
||||||
|
|
||||||
|
@ArgName("remote")
|
||||||
|
@ArgAlias('r')
|
||||||
|
@ArgDescription("Name of the remote server")
|
||||||
|
public String remote = "origin";
|
||||||
|
|
||||||
|
@ArgName("tags")
|
||||||
|
@ArgAlias('t')
|
||||||
|
@ArgDescription("Display if the commit is on a tag (and display it)")
|
||||||
|
public boolean display_tag = false;
|
||||||
|
|
||||||
|
@ArgExecute
|
||||||
|
public void execute() throws ActionException, Exception {
|
||||||
|
// check system is OK
|
||||||
|
Manifest.checkIsInit();
|
||||||
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
|
Path file_source_manifest = Env.getIslandPathManifest().resolve(configuration.getManifestName());
|
||||||
|
if (!Files.exists(file_source_manifest)) {
|
||||||
|
LOGGER.critical("Missing manifest file : '" + file_source_manifest + "'");
|
||||||
|
}
|
||||||
|
Manifest mani = new Manifest(file_source_manifest);
|
||||||
|
Git git = Git.open(Env.getIslandPathManifest().toFile());
|
||||||
|
boolean is_modify_manifest = git.status().call().hasUncommittedChanges();
|
||||||
|
if (is_modify_manifest) {
|
||||||
|
LOGGER.info("!!!!!!!!!!!! MANIFEST is modify !!!!!!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ProjectConfig> all_project = mani.get_all_configs();
|
||||||
|
LOGGER.info("status of: " + all_project.size() + " projects");
|
||||||
|
int id_element = 0;
|
||||||
|
|
||||||
|
/* Display status of manifest ==> todo later ...
|
||||||
|
elem = configuration.get_manifest_config()
|
||||||
|
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||||
|
status.display_status(elem, remote, display_tag, id_element, base_display)
|
||||||
|
*/
|
||||||
|
boolean is_behind = false;
|
||||||
|
for (ProjectConfig elem : all_project) {
|
||||||
|
id_element++;
|
||||||
|
String base_display = Tools.getListBaseDisplay(id_element, all_project.size(), elem);
|
||||||
|
int ret = StatusActions.displayStatus(elem, this.remote, this.display_tag, id_element, base_display);
|
||||||
|
if (ret != 0) {
|
||||||
|
is_behind = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is_behind == true) {
|
||||||
|
//return Env.ret_action_need_updtate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
164
src/org/atriasoft/island/actions/BaseSync.java
Normal file
164
src/org/atriasoft/island/actions/BaseSync.java
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
package org.atriasoft.island.actions;
|
||||||
|
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.death.annotation.ArgAlias;
|
||||||
|
import org.atriasoft.death.annotation.ArgCommand;
|
||||||
|
import org.atriasoft.death.annotation.ArgDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgExecute;
|
||||||
|
import org.atriasoft.death.annotation.ArgName;
|
||||||
|
import org.atriasoft.death.annotation.ArgSample;
|
||||||
|
import org.atriasoft.island.Config;
|
||||||
|
import org.atriasoft.island.Env;
|
||||||
|
import org.atriasoft.island.Manifest;
|
||||||
|
import org.atriasoft.island.Tools;
|
||||||
|
import org.atriasoft.island.internal.Log;
|
||||||
|
import org.atriasoft.island.model.ActionException;
|
||||||
|
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||||
|
import org.atriasoft.island.model.manifest.MirrorConfig;
|
||||||
|
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.api.Git;
|
||||||
|
import org.eclipse.jgit.lib.BranchConfig;
|
||||||
|
import org.eclipse.jgit.lib.Repository;
|
||||||
|
import org.eclipse.jgit.lib.StoredConfig;
|
||||||
|
import org.eclipse.jgit.lib.TextProgressMonitor;
|
||||||
|
|
||||||
|
@ArgCommand("sync")
|
||||||
|
@ArgDescription("Syncronize all the repository referenced")
|
||||||
|
@ArgSample("sync -d")
|
||||||
|
public class BaseSync {
|
||||||
|
|
||||||
|
@ArgName("download")
|
||||||
|
@ArgAlias('d')
|
||||||
|
@ArgDescription("Just download the 'not download' repository")
|
||||||
|
public boolean downloadOnly = false;
|
||||||
|
|
||||||
|
@ArgName("remote")
|
||||||
|
@ArgAlias('r')
|
||||||
|
@ArgDescription("Name of the remote server")
|
||||||
|
public String remote = "origin";
|
||||||
|
|
||||||
|
@ArgExecute
|
||||||
|
public void execute() throws ActionException, Exception {
|
||||||
|
|
||||||
|
// check system is OK
|
||||||
|
Manifest.checkIsInit();
|
||||||
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
|
// fetch or pull the manifest in case...
|
||||||
|
{
|
||||||
|
Git git = Git.open(Env.getIslandPathManifest().toFile());
|
||||||
|
boolean is_modify_manifest = git.status().call().hasUncommittedChanges();
|
||||||
|
if (is_modify_manifest) {
|
||||||
|
git.fetch().setRemote(this.remote).call();
|
||||||
|
} else {
|
||||||
|
git.pull().setRemote(this.remote).call();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// load the manifest after pulling it (if possible)
|
||||||
|
Path file_source_manifest = Env.getIslandPathManifest().resolve(configuration.getManifestName());
|
||||||
|
if (!Files.exists(file_source_manifest)) {
|
||||||
|
LOGGER.critical("Missing manifest file : '" + file_source_manifest + "'");
|
||||||
|
}
|
||||||
|
Manifest mani = new Manifest(file_source_manifest);
|
||||||
|
|
||||||
|
List<ProjectConfig> all_project = mani.get_all_configs();
|
||||||
|
LOGGER.info("Synchronize of: " + all_project.size() + " projects");
|
||||||
|
int id_element = 0;
|
||||||
|
|
||||||
|
for (ProjectConfig elem : all_project) {
|
||||||
|
id_element++;
|
||||||
|
String base_display = Tools.getListBaseDisplay(id_element, all_project.size(), elem);
|
||||||
|
LOGGER.info("sync : " + base_display);
|
||||||
|
Tools.waitForServerIfNeeded();
|
||||||
|
LOGGER.debug("elem : " + elem);
|
||||||
|
Path git_repo_path = Env.getIslandRootPath().resolve(elem.getPath());
|
||||||
|
if (elem.getTag() != null) {
|
||||||
|
LOGGER.info("[TODO] Need to select a specific tag version ... " + elem.getTag());
|
||||||
|
}
|
||||||
|
if (!Files.exists(git_repo_path)) {
|
||||||
|
// this is a new clone ==> this is easy ...
|
||||||
|
LOGGER.warn("Path Does not Exist ... " + git_repo_path);
|
||||||
|
String addressManifest = configuration.createAdressGitRepo(elem.getSelectRemotes().getFetch(), elem.getName());
|
||||||
|
|
||||||
|
LOGGER.info("clone the repo : " + addressManifest);
|
||||||
|
|
||||||
|
Git git = Git.cloneRepository()
|
||||||
|
.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
|
||||||
|
.setURI( addressManifest )
|
||||||
|
.setDirectory( git_repo_path.toFile() )
|
||||||
|
.setBranch(elem.getBranch())
|
||||||
|
.call();
|
||||||
|
// add global mirror list
|
||||||
|
for (MirrorConfig mirror : elem.getSelectRemotes().getMirror()) {
|
||||||
|
LOGGER.trace("Add global mirror: " + mirror);
|
||||||
|
String addressManifestMiror = configuration.createAdressGitRepo(mirror.getFetch(), elem.getName());
|
||||||
|
StoredConfig config = git.getRepository().getConfig();
|
||||||
|
config.setString("remote", mirror.getName(), "url", addressManifestMiror);
|
||||||
|
config.save();
|
||||||
|
}
|
||||||
|
// check submodule if requested:
|
||||||
|
if (elem.getSelectRemotes().isSync()
|
||||||
|
&& Files.exists(git_repo_path.resolve(".gitmodules"))) {
|
||||||
|
LOGGER.info(" ==> update submodule (init)");
|
||||||
|
git.submoduleInit().call();
|
||||||
|
LOGGER.info(" ==> update submodule (update)");
|
||||||
|
git.submoduleUpdate()
|
||||||
|
.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
|
||||||
|
.call();
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!Files.exists(git_repo_path.resolve(".git"))) {
|
||||||
|
// path already exist but it is not used to as a git repo ==> this is an error
|
||||||
|
LOGGER.error("path '" + git_repo_path + "' is already existing but not used for a git repository. Clean it and restart");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.downloadOnly == true) {
|
||||||
|
LOGGER.info("SYNC: Already downloaded");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// simply update the repository ...
|
||||||
|
LOGGER.trace("Fetching project: ");
|
||||||
|
{
|
||||||
|
Git git = Git.open(git_repo_path.toFile());
|
||||||
|
Repository repo = git.getRepository();
|
||||||
|
// get tracking branch
|
||||||
|
String ret_track = new BranchConfig(repo.getConfig(), repo.getBranch()).getTrackingBranch();
|
||||||
|
boolean is_modify = git.status().call().hasUncommittedChanges();
|
||||||
|
String select_branch = repo.getFullBranch();
|
||||||
|
|
||||||
|
if (is_modify) {
|
||||||
|
// fetch the repository
|
||||||
|
git.fetch()
|
||||||
|
.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
|
||||||
|
.setRemote(elem.getSelectRemotes().getName())
|
||||||
|
.call();
|
||||||
|
LOGGER.warn("[" + elem.getName() + "] Not update ==> the repository is modified (just fetch)");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
git.pull()
|
||||||
|
.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
|
||||||
|
.setRemote(elem.getSelectRemotes().getName())
|
||||||
|
.call();
|
||||||
|
LOGGER.trace("select branch = '" + select_branch + "' track: '" + ret_track + "'");
|
||||||
|
// check submodule if requested:
|
||||||
|
if (elem.getSelectRemotes().isSync()
|
||||||
|
&& Files.exists(git_repo_path.resolve(".gitmodules"))) {
|
||||||
|
LOGGER.info(" ==> sync submodule");
|
||||||
|
git.submoduleUpdate()
|
||||||
|
.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
|
||||||
|
.call();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Update the links:
|
||||||
|
//TODO: have_error = update_links.update(configuration, mani, "sync-local")
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
141
src/org/atriasoft/island/actions/Deliver.java
Normal file
141
src/org/atriasoft/island/actions/Deliver.java
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
package org.atriasoft.island.actions;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.death.annotation.ArgAlias;
|
||||||
|
import org.atriasoft.death.annotation.ArgCommand;
|
||||||
|
import org.atriasoft.death.annotation.ArgDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgExecute;
|
||||||
|
import org.atriasoft.death.annotation.ArgName;
|
||||||
|
import org.atriasoft.death.annotation.ArgSample;
|
||||||
|
import org.atriasoft.island.Commands;
|
||||||
|
import org.atriasoft.island.Commands.CreateVersion;
|
||||||
|
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.manifest.ConfigManifest;
|
||||||
|
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.api.Git;
|
||||||
|
import org.eclipse.jgit.api.ResetCommand.ResetType;
|
||||||
|
|
||||||
|
@ArgCommand("deliver")
|
||||||
|
@ArgDescription("Deliver the current repository (develop & master MUST be up to date and you MUST be on master)")
|
||||||
|
@ArgSample("deliver --from=develop --to=master")
|
||||||
|
public class Deliver {
|
||||||
|
|
||||||
|
@ArgName("from")
|
||||||
|
@ArgAlias('f')
|
||||||
|
@ArgDescription("Source branch to deliver")
|
||||||
|
public String from = null;
|
||||||
|
|
||||||
|
@ArgName("to")
|
||||||
|
@ArgAlias('t')
|
||||||
|
@ArgDescription("Desticantion branche of the deliver")
|
||||||
|
public String to = null;
|
||||||
|
|
||||||
|
@ArgExecute
|
||||||
|
public void execute() throws ActionException, Exception {
|
||||||
|
|
||||||
|
// check system is OK
|
||||||
|
Manifest.checkIsInit();
|
||||||
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
// load the manifest after pulling it (if possible)
|
||||||
|
Path file_source_manifest = Env.getIslandPathManifest().resolve(configuration.getManifestName());
|
||||||
|
if (!Files.exists(file_source_manifest)) {
|
||||||
|
LOGGER.critical("Missing manifest file : '" + file_source_manifest + "'");
|
||||||
|
}
|
||||||
|
Manifest mani = new Manifest(file_source_manifest);
|
||||||
|
if (this.from == null || this.from.isEmpty()) {
|
||||||
|
this.from = mani.getDeliverDevelop();
|
||||||
|
}
|
||||||
|
if (this.to == null || this.to.isEmpty()) {
|
||||||
|
this.to = mani.getBranchRelease();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ProjectConfig> all_project = mani.get_all_configs();
|
||||||
|
LOGGER.info("Check if all project are on master: " + all_project.size() + " projects");
|
||||||
|
boolean deliver_availlable = true;
|
||||||
|
int id_element = 0;
|
||||||
|
for (ProjectConfig elem : all_project) {
|
||||||
|
id_element++;
|
||||||
|
String base_display = Tools.getListBaseDisplay(id_element, all_project.size(), elem);
|
||||||
|
LOGGER.trace("delivercheck : " + base_display);
|
||||||
|
if (!StatusActions.deliverCheck(elem, null, id_element, base_display, this.from, this.to)) {
|
||||||
|
deliver_availlable = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!deliver_availlable) {
|
||||||
|
LOGGER.error("deliver-ckeck: Correct the warning to validate the Merge");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LOGGER.info("deliver-ckeck: ==> All is OK");
|
||||||
|
id_element = 0;
|
||||||
|
for (ProjectConfig elem : all_project) {
|
||||||
|
id_element += 1;
|
||||||
|
String base_display = Tools.getListBaseDisplay(id_element, all_project.size(), elem);
|
||||||
|
LOGGER.info("deliver: ========================================================================");
|
||||||
|
LOGGER.info("deliver:.equals(" + base_display);
|
||||||
|
LOGGER.info("deliver: ========================================================================");
|
||||||
|
|
||||||
|
Path git_repo_path = Env.getIslandRootPath().resolve(elem.getPath());
|
||||||
|
// Check the validity of the version,
|
||||||
|
CreateVersion curentVersionElem = Commands.get_current_version_repo(git_repo_path);
|
||||||
|
if (curentVersionElem == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
LOGGER.info("deliver: ==> version: " + curentVersionElem.version());
|
||||||
|
|
||||||
|
Git git = Git.open(git_repo_path.toFile());
|
||||||
|
// Checkout destination branch:
|
||||||
|
Commands.checkout(git, this.to);
|
||||||
|
// create new repo tag
|
||||||
|
int[] new_version_description = Commands.create_new_version_repo(git, curentVersionElem.version(), curentVersionElem.addInManagement(), this.from, this.to);
|
||||||
|
LOGGER.info("new version: " + Arrays.toString(new_version_description));
|
||||||
|
if (new_version_description == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Commands.merge_branch_on_master(git, this.from, mani.getDeliverModeMerge(), this.to);
|
||||||
|
|
||||||
|
Path version_path_file = git_repo_path.resolve("version.txt");
|
||||||
|
// update version file:
|
||||||
|
String releaseVersion = Tools.versionToString(new_version_description, false);
|
||||||
|
Tools.fileWriteData(version_path_file, releaseVersion);
|
||||||
|
git.add()
|
||||||
|
.addFilepattern("version.txt")
|
||||||
|
.call();
|
||||||
|
git.commit()
|
||||||
|
.setAll(true)
|
||||||
|
.setMessage("[RELEASE] Release v" + releaseVersion)
|
||||||
|
.call();
|
||||||
|
git.tag()
|
||||||
|
.setName("v" + releaseVersion)
|
||||||
|
.call();
|
||||||
|
// now we update the development branch:
|
||||||
|
git.checkout()
|
||||||
|
.setCreateBranch(false)
|
||||||
|
.setName("refs/heads/" + this.from)
|
||||||
|
.call();
|
||||||
|
git.reset()
|
||||||
|
.setMode(ResetType.HARD)
|
||||||
|
.setRef("refs/heads/"+ this.to)
|
||||||
|
.call();
|
||||||
|
Tools.fileWriteData(version_path_file, Tools.versionToString(new_version_description, true));
|
||||||
|
git.add()
|
||||||
|
.addFilepattern("version.txt")
|
||||||
|
.call();
|
||||||
|
git.commit()
|
||||||
|
.setAll(true)
|
||||||
|
.setMessage(StatusActions.defaultUpdateMessage)
|
||||||
|
.call();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
391
src/org/atriasoft/island/actions/DependencySync.java
Normal file
391
src/org/atriasoft/island/actions/DependencySync.java
Normal file
@ -0,0 +1,391 @@
|
|||||||
|
package org.atriasoft.island.actions;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
|
import org.atriasoft.death.annotation.ArgCommand;
|
||||||
|
import org.atriasoft.death.annotation.ArgDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgExecute;
|
||||||
|
import org.atriasoft.death.annotation.ArgName;
|
||||||
|
import org.atriasoft.death.annotation.ArgSample;
|
||||||
|
import org.atriasoft.ejson.Ejson;
|
||||||
|
import org.atriasoft.ejson.model.JsonArray;
|
||||||
|
import org.atriasoft.ejson.model.JsonObject;
|
||||||
|
import org.atriasoft.ejson.model.JsonString;
|
||||||
|
import org.atriasoft.exml.XmlMapper;
|
||||||
|
import org.atriasoft.exml.exception.ExmlException;
|
||||||
|
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.GLDDependModel;
|
||||||
|
import org.atriasoft.island.model.manifest.Artifactory;
|
||||||
|
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||||
|
import org.atriasoft.island.model.manifest.Dependency;
|
||||||
|
import org.atriasoft.island.model.maven.MavenMetadata;
|
||||||
|
import org.atriasoft.island.model.maven.PomDependency;
|
||||||
|
import org.atriasoft.island.model.maven.PomMaven;
|
||||||
|
|
||||||
|
@ArgCommand("depend-sync")
|
||||||
|
@ArgDescription("Syncronize all the dependencies referenced")
|
||||||
|
@ArgSample("depend-sync")
|
||||||
|
public class DependencySync {
|
||||||
|
|
||||||
|
private class UpdateDependency {
|
||||||
|
public Dependency dependency;
|
||||||
|
public List<String> download = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String MAVEN_METADATA = "maven-metadata.xml";
|
||||||
|
|
||||||
|
@ArgName("doc")
|
||||||
|
@ArgDescription("enable download of the documentation")
|
||||||
|
public boolean documentation = false;
|
||||||
|
|
||||||
|
@ArgName("sources")
|
||||||
|
@ArgDescription("enable download of the sources")
|
||||||
|
public boolean sources = false;
|
||||||
|
|
||||||
|
public Path createArtefactLinkFileName(final String fileName) {
|
||||||
|
final Path outPath = Env.getIslandPathArtifactoryLink().resolve(fileName);
|
||||||
|
return outPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Path createArtefactLinkGLDFile(final String fileName) {
|
||||||
|
final Path outPath = Env.getIslandPathArtifactoryLink().resolve("GLD_" + fileName + ".json");
|
||||||
|
return outPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Path createBasePkgLocalFileName(final List<Artifactory> artefactories, final Dependency dependency, final String version) {
|
||||||
|
final Artifactory artifactory = findArtifactory(artefactories, dependency.remote());
|
||||||
|
final String out = artifactory.getName() + "/" + dependency.org().replace(".", "/") + "/" + dependency.name() + "/" + version;
|
||||||
|
final Path outPath = Env.getIslandPathArtifactory().resolve(out);
|
||||||
|
return outPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String createBasePkgRemoteFileName(final List<Artifactory> artefactories, final Dependency dependency, final String version) {
|
||||||
|
final Artifactory artifactory = findArtifactory(artefactories, dependency.remote());
|
||||||
|
String out = artifactory.getFetch();
|
||||||
|
while (out.endsWith("/")) {
|
||||||
|
out = out.substring(0, out.length() - 1);
|
||||||
|
}
|
||||||
|
out += "/" + dependency.org().replace(".", "/") + "/" + dependency.name() + "/" + version;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createGLDFile(final PomMaven mavenPom, final Path createArtefactLinkGLDFile, final Path artefactLink) {
|
||||||
|
final GLDDependModel model = new GLDDependModel();
|
||||||
|
model.path.java.add(artefactLink.getFileName().toString());
|
||||||
|
model.groupId = mavenPom.groupId();
|
||||||
|
model.version = mavenPom.version();
|
||||||
|
if (mavenPom.dependencies() != null) {
|
||||||
|
for (final PomDependency elem : mavenPom.dependencies()) {
|
||||||
|
model.dependency.add(elem.artifactId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO: for later : create a generic serializer ...
|
||||||
|
final StringBuilder data = new StringBuilder();
|
||||||
|
final JsonObject root = new JsonObject();
|
||||||
|
root.put("type", new JsonString(model.type));
|
||||||
|
root.put("group-id", new JsonString(model.groupId));
|
||||||
|
root.put("version", new JsonString(model.version));
|
||||||
|
final JsonObject path = new JsonObject();
|
||||||
|
root.put("path", path);
|
||||||
|
final JsonArray java = new JsonArray();
|
||||||
|
for (final String elem : model.path.java) {
|
||||||
|
java.add(new JsonString(elem));
|
||||||
|
}
|
||||||
|
path.put("java", java);
|
||||||
|
final JsonArray dep = new JsonArray();
|
||||||
|
for (final String elem : model.dependency) {
|
||||||
|
dep.add(new JsonString(elem));
|
||||||
|
}
|
||||||
|
root.put("dependency", dep);
|
||||||
|
Ejson.generate(root, data);
|
||||||
|
//LOGGER.error("generated GLD dependency : {}", data.toString());
|
||||||
|
//LOGGER.error(" ==> {}", createArtefactLinkGLDFile.toString());
|
||||||
|
//LOGGER.error(" --> {}", artefactLink.toString());
|
||||||
|
Tools.fileWriteData(createArtefactLinkGLDFile, data.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void createLinkOnArtefact(final Path path, final String baseName) throws Exception {
|
||||||
|
// remove previous file in the link area:
|
||||||
|
Tools.createSymbolicLink(createArtefactLinkFileName(baseName), path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String createMavenMetadataRemoteFileName(final List<Artifactory> artefactories, final Dependency dependency) {
|
||||||
|
return createBasePkgRemoteFileName(artefactories, dependency, DependencySync.MAVEN_METADATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Path createMetadataLocalFileName(final List<Artifactory> artefactories, final Dependency dependency) {
|
||||||
|
return createBasePkgLocalFileName(artefactories, dependency, DependencySync.MAVEN_METADATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void downloadPackage(final List<Artifactory> artefactories, final Dependency dependency, final List<UpdateDependency> alreadyDone) throws Exception {
|
||||||
|
LOGGER.debug("download : " + dependency);
|
||||||
|
for (final UpdateDependency elem : alreadyDone) {
|
||||||
|
if (elem.dependency.org().equals(dependency.org()) && elem.dependency.name().equals(dependency.name()) && elem.dependency.remote().equals(dependency.remote())) {
|
||||||
|
// find element ==> check version
|
||||||
|
for (final String version : elem.download) {
|
||||||
|
if (version.equals(dependency.revision())) {
|
||||||
|
// already download ==> skip ...
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final String metadataFile = createMavenMetadataRemoteFileName(artefactories, dependency);
|
||||||
|
LOGGER.trace("Metadata position: " + metadataFile);
|
||||||
|
final Path localPath = createMetadataLocalFileName(artefactories, dependency);
|
||||||
|
final String dataAsString = readAllMatadataAndStore(metadataFile, localPath);
|
||||||
|
LOGGER.trace("dataAsString: " + dataAsString);
|
||||||
|
MavenMetadata metaData = null;
|
||||||
|
final XmlMapper mapper = new XmlMapper();
|
||||||
|
try {
|
||||||
|
metaData = mapper.parse(dataAsString, MavenMetadata.class);
|
||||||
|
} catch (final ExmlException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
LOGGER.print("metaData=" + metaData);
|
||||||
|
|
||||||
|
// TODO : check if the current file is newer....
|
||||||
|
|
||||||
|
// TODO : Check if the version is download
|
||||||
|
|
||||||
|
final String lastReleaseTag = metaData.versioning().release();
|
||||||
|
|
||||||
|
final String remotePakageFileName = createBasePkgRemoteFileName(artefactories, dependency, lastReleaseTag);
|
||||||
|
final Path localPackageFileName = createBasePkgLocalFileName(artefactories, dependency, lastReleaseTag);
|
||||||
|
// pom sources
|
||||||
|
String base = getPomFileName(dependency, lastReleaseTag);
|
||||||
|
readRemoteFileAndStore(remotePakageFileName + "/" + base, localPackageFileName.resolve(base), base);
|
||||||
|
PomMaven mavenPom = null;
|
||||||
|
try {
|
||||||
|
mavenPom = mapper.parse(localPackageFileName.resolve(base), PomMaven.class);
|
||||||
|
} catch (final ExmlException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// retrieve binary
|
||||||
|
base = getJavaPackageFileName(dependency, lastReleaseTag);
|
||||||
|
readRemoteFileAndStore(remotePakageFileName + "/" + base, localPackageFileName.resolve(base), base);
|
||||||
|
// TODO: If Zip artefact this mean we need to uncompress it.
|
||||||
|
createLinkOnArtefact(localPackageFileName.resolve(base), base);
|
||||||
|
// create the GLD file with maven dependency
|
||||||
|
|
||||||
|
createGLDFile(mavenPom, createArtefactLinkGLDFile(mavenPom.artifactId()), createArtefactLinkFileName(base));
|
||||||
|
|
||||||
|
// listFiles(localPackageFileName.resolve(base));
|
||||||
|
// retrieve javadoc
|
||||||
|
if (this.documentation) {
|
||||||
|
base = getJavaDocFileName(dependency, lastReleaseTag);
|
||||||
|
readRemoteFileAndStore(remotePakageFileName + "/" + base, localPackageFileName.resolve(base), base);
|
||||||
|
}
|
||||||
|
// retrieve sources
|
||||||
|
if (this.sources) {
|
||||||
|
base = getJavaSourceFileName(dependency, lastReleaseTag);
|
||||||
|
readRemoteFileAndStore(remotePakageFileName + "/" + base, localPackageFileName.resolve(base), base);
|
||||||
|
}
|
||||||
|
// module sources ==> for gradle ==> no need...
|
||||||
|
/*
|
||||||
|
base = getModuleFileName(dependency, lastReleaseTag);
|
||||||
|
readRemoteFileAndStore(remotePakageFileName + "/" + base, localPackageFileName.resolve(base), base);
|
||||||
|
*/
|
||||||
|
boolean find = false;
|
||||||
|
for (final UpdateDependency elem : alreadyDone) {
|
||||||
|
if (elem.dependency.org().equals(dependency.org()) && elem.dependency.name().equals(dependency.name()) && elem.dependency.remote().equals(dependency.remote())) {
|
||||||
|
// find element ==> check version
|
||||||
|
elem.download.add(dependency.revision());
|
||||||
|
find = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!find) {
|
||||||
|
final UpdateDependency tmpp = new UpdateDependency();
|
||||||
|
tmpp.dependency = dependency;
|
||||||
|
tmpp.download.add(dependency.revision());
|
||||||
|
alreadyDone.add(tmpp);
|
||||||
|
}
|
||||||
|
if (mavenPom != null && mavenPom.dependencies() != null) {
|
||||||
|
for (final PomDependency value : mavenPom.dependencies()) {
|
||||||
|
final Dependency dependencyTmp = new Dependency(value.groupId(), value.artifactId(), value.version(), dependency.remote());
|
||||||
|
downloadPackage(artefactories, dependencyTmp, alreadyDone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ArgExecute
|
||||||
|
public void execute() throws ActionException, Exception {
|
||||||
|
final List<UpdateDependency> alreadyDone = new ArrayList<>();
|
||||||
|
// check system is OK
|
||||||
|
Manifest.checkIsInit();
|
||||||
|
final ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
|
// load the manifest after pulling it (if possible)
|
||||||
|
final Path file_source_manifest = Env.getIslandPathManifest().resolve(configuration.getManifestName());
|
||||||
|
if (!Files.exists(file_source_manifest)) {
|
||||||
|
LOGGER.critical("Missing manifest file : '" + file_source_manifest + "'");
|
||||||
|
}
|
||||||
|
final Manifest mani = new Manifest(file_source_manifest);
|
||||||
|
|
||||||
|
final List<Artifactory> artefactories = mani.getAllArtefactories();
|
||||||
|
final List<Dependency> dependencies = mani.getAllDependencies();
|
||||||
|
|
||||||
|
LOGGER.info("Synchronize of: " + dependencies.size() + " dependenc" + Tools.getPlural(dependencies));
|
||||||
|
LOGGER.info("base on: " + artefactories.size() + " artefactor" + Tools.getPlural(artefactories));
|
||||||
|
int id_element = 0;
|
||||||
|
|
||||||
|
for (final Dependency elem : dependencies) {
|
||||||
|
id_element++;
|
||||||
|
final String base_display = Tools.getListBaseDisplay(id_element, dependencies.size(), elem);
|
||||||
|
LOGGER.info("dep-sync : " + base_display);
|
||||||
|
LOGGER.debug("elem : " + elem);
|
||||||
|
downloadPackage(artefactories, elem, alreadyDone);
|
||||||
|
}
|
||||||
|
LOGGER.print("Dependency sync END");
|
||||||
|
}
|
||||||
|
|
||||||
|
Artifactory findArtifactory(final List<Artifactory> artefactories, final String name) {
|
||||||
|
Artifactory out = null;
|
||||||
|
for (final Artifactory elem : artefactories) {
|
||||||
|
if ("default".equals(elem.getName())) {
|
||||||
|
out = elem;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// By default we are capable to use maven artefactory (can be replace with using "default" name).
|
||||||
|
if (out == null) {
|
||||||
|
out = new Artifactory("default", "https://repo1.maven.org/maven2", "maven");
|
||||||
|
}
|
||||||
|
for (final Artifactory elem : artefactories) {
|
||||||
|
if (name.equals(elem.getName())) {
|
||||||
|
return elem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOGGER.error("Can not find the remote '" + name + "'artefactory in the list ==> fallback to 'default'");
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJavaDocFileName(final Dependency dependency, final String version) {
|
||||||
|
return dependency.name() + "-" + version + "-javadoc.jar";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJavaPackageFileName(final Dependency dependency, final String version) {
|
||||||
|
return dependency.name() + "-" + version + ".jar";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJavaSourceFileName(final Dependency dependency, final String version) {
|
||||||
|
return dependency.name() + "-" + version + "-sources.jar";
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is the gradle module interface
|
||||||
|
public String getModuleFileName(final Dependency dependency, final String version) {
|
||||||
|
return dependency.name() + "-" + version + ".module";
|
||||||
|
}
|
||||||
|
|
||||||
|
// this is the maven module interface
|
||||||
|
public String getPomFileName(final Dependency dependency, final String version) {
|
||||||
|
return dependency.name() + "-" + version + ".pom";
|
||||||
|
}
|
||||||
|
|
||||||
|
void listFiles(final Path path) {
|
||||||
|
LOGGER.info("List of file in " + path);
|
||||||
|
try {
|
||||||
|
final ZipFile zipFile = new ZipFile(path.toFile());
|
||||||
|
|
||||||
|
final Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
||||||
|
while (entries.hasMoreElements()) {
|
||||||
|
final ZipEntry entry = entries.nextElement();
|
||||||
|
LOGGER.info(" - " + entry.getName() + " (" + entry.getSize() + ")");
|
||||||
|
//InputStream stream = zipFile.getInputStream(entry);
|
||||||
|
}
|
||||||
|
} catch (final IOException ex) {
|
||||||
|
LOGGER.error("Catch Exception : " + ex.getLocalizedMessage());
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String readAllMatadataAndStore(final String urlPath, final Path path) throws Exception {
|
||||||
|
final URL url = new URL(urlPath);
|
||||||
|
final HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||||
|
con.setRequestMethod("GET");
|
||||||
|
con.setConnectTimeout(5000);
|
||||||
|
con.setReadTimeout(5000);
|
||||||
|
con.setInstanceFollowRedirects(false);
|
||||||
|
final StringBuilder result = new StringBuilder();
|
||||||
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
|
||||||
|
for (String line; (line = reader.readLine()) != null;) {
|
||||||
|
result.append(line);
|
||||||
|
result.append("\n");
|
||||||
|
}
|
||||||
|
} catch (final Exception ex) {
|
||||||
|
LOGGER.error("Can not retrive data from artefactory ..." + ex.getLocalizedMessage());
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
final String dataAsString = result.toString();
|
||||||
|
LOGGER.trace("return=" + dataAsString);
|
||||||
|
Tools.fileWriteData(path, dataAsString);
|
||||||
|
return dataAsString;
|
||||||
|
}
|
||||||
|
|
||||||
|
void readRemoteFileAndStore(final String urlPath, final Path path, final String baseName) throws Exception {
|
||||||
|
if (Files.exists(path)) {
|
||||||
|
LOGGER.debug("File already download : " + baseName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (!Files.exists(path.getParent())) {
|
||||||
|
final File file = path.getParent().toFile();
|
||||||
|
if (!file.mkdirs()) {
|
||||||
|
LOGGER.critical("Can not create the path:" + path.getParent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final URL url = new URL(urlPath);
|
||||||
|
final HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||||
|
con.setRequestMethod("GET");
|
||||||
|
con.setConnectTimeout(5000);
|
||||||
|
con.setReadTimeout(5000);
|
||||||
|
con.setInstanceFollowRedirects(false);
|
||||||
|
final int BUFFER_SIZE = 1024 * 1024;
|
||||||
|
final InputStream inputStream = con.getInputStream();
|
||||||
|
final Path tmpFile = path.getParent().resolve(path.getFileName() + "__tmp");
|
||||||
|
final FileOutputStream outputStream = new FileOutputStream(tmpFile.toFile());
|
||||||
|
int bytesRead = -1;
|
||||||
|
int totalRead = 0;
|
||||||
|
final byte[] buffer = new byte[BUFFER_SIZE];
|
||||||
|
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||||
|
outputStream.write(buffer, 0, bytesRead);
|
||||||
|
totalRead += bytesRead;
|
||||||
|
//System.out.print("Download: " + baseName + " =" + totalRead + " B\r");
|
||||||
|
}
|
||||||
|
System.out.print("Download: " + baseName + " =" + totalRead + " B\n");
|
||||||
|
outputStream.close();
|
||||||
|
inputStream.close();
|
||||||
|
// this is the way to have atomic replacement of file and not partial downloaded file ==> move is 99.999999% atomic.
|
||||||
|
Files.move(tmpFile, path);
|
||||||
|
} catch (final FileNotFoundException ex) {
|
||||||
|
LOGGER.warn("File not found: " + urlPath);
|
||||||
|
} finally {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
46
src/org/atriasoft/island/actions/ManifestCheckout.java
Normal file
46
src/org/atriasoft/island/actions/ManifestCheckout.java
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
package org.atriasoft.island.actions;
|
||||||
|
import org.atriasoft.death.annotation.ArgAlias;
|
||||||
|
import org.atriasoft.death.annotation.ArgCommand;
|
||||||
|
import org.atriasoft.death.annotation.ArgDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgExecute;
|
||||||
|
import org.atriasoft.death.annotation.ArgName;
|
||||||
|
import org.atriasoft.death.annotation.ArgParams;
|
||||||
|
import org.atriasoft.death.annotation.ArgParamsDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgSample;
|
||||||
|
import org.atriasoft.island.Config;
|
||||||
|
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.manifest.ConfigManifest;
|
||||||
|
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||||
|
|
||||||
|
@ArgCommand("manifest-checkout")
|
||||||
|
@ArgDescription("Ckeckout a specific branch of the manifest")
|
||||||
|
@ArgSample({
|
||||||
|
"manifest-checkout dev",
|
||||||
|
"manifest-checkout -r github master",
|
||||||
|
"manifest-checkout -r=gitlab master",
|
||||||
|
})
|
||||||
|
public class ManifestCheckout {
|
||||||
|
@ArgName("remote")
|
||||||
|
@ArgAlias('r')
|
||||||
|
@ArgDescription("Name of the remote server")
|
||||||
|
public String remote = null;
|
||||||
|
|
||||||
|
@ArgExecute
|
||||||
|
@ArgParams("branch")
|
||||||
|
@ArgParamsDescription("Branch to checkout (if '__TAG__' ==> checkout specific repository tags)")
|
||||||
|
public void execute(final String branch) throws ActionException, Exception {
|
||||||
|
// check system is OK
|
||||||
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
ProjectConfig elem = configuration.getManifestConfig();
|
||||||
|
String base_display = Tools.getListBaseDisplay(0, 0, elem);
|
||||||
|
if (!StatusActions.checkoutElem(elem, this.remote, branch, base_display)) {
|
||||||
|
LOGGER.error("Checkout have fail !!! ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
41
src/org/atriasoft/island/actions/ManifestStatus.java
Normal file
41
src/org/atriasoft/island/actions/ManifestStatus.java
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package org.atriasoft.island.actions;
|
||||||
|
|
||||||
|
import org.atriasoft.death.annotation.ArgAlias;
|
||||||
|
import org.atriasoft.death.annotation.ArgCommand;
|
||||||
|
import org.atriasoft.death.annotation.ArgDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgExecute;
|
||||||
|
import org.atriasoft.death.annotation.ArgName;
|
||||||
|
import org.atriasoft.death.annotation.ArgSample;
|
||||||
|
import org.atriasoft.island.Config;
|
||||||
|
import org.atriasoft.island.Manifest;
|
||||||
|
import org.atriasoft.island.Tools;
|
||||||
|
import org.atriasoft.island.model.ActionException;
|
||||||
|
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||||
|
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||||
|
|
||||||
|
@ArgCommand("manifest-status")
|
||||||
|
@ArgDescription("Get the status of manifest repositories")
|
||||||
|
@ArgSample("manifest-status --tags")
|
||||||
|
public class ManifestStatus {
|
||||||
|
|
||||||
|
@ArgName("remote")
|
||||||
|
@ArgAlias('r')
|
||||||
|
@ArgDescription("Name of the remote server")
|
||||||
|
public String remote = "origin";
|
||||||
|
|
||||||
|
@ArgName("tags")
|
||||||
|
@ArgAlias('t')
|
||||||
|
@ArgDescription("Display if the commit is on a tag (and display it)")
|
||||||
|
public boolean displayTag = false;
|
||||||
|
|
||||||
|
@ArgExecute
|
||||||
|
public void execute() throws ActionException, Exception {
|
||||||
|
// check system is OK
|
||||||
|
Manifest.checkIsInit();
|
||||||
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
ProjectConfig elem = configuration.getManifestConfig();
|
||||||
|
String base_display = Tools.getListBaseDisplay(0, 0, elem);
|
||||||
|
StatusActions.displayStatus(elem, this.remote, this.displayTag, 0, base_display);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
255
src/org/atriasoft/island/actions/StatusActions.java
Normal file
255
src/org/atriasoft/island/actions/StatusActions.java
Normal file
@ -0,0 +1,255 @@
|
|||||||
|
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.DeltaBranch;
|
||||||
|
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode;
|
||||||
|
import org.eclipse.jgit.api.Git;
|
||||||
|
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||||
|
|
||||||
|
public class StatusActions {
|
||||||
|
|
||||||
|
public static String defaultBehindMessage = "[DEV] update dev tag version";
|
||||||
|
public static String defaultUpdateMessage = "[VERSION] update dev tag version";
|
||||||
|
public static String baseNameOfATaggedBranch = "branch_on_tag_";
|
||||||
|
|
||||||
|
public static boolean checkoutElem(final ProjectConfig elem, final String argumentRemoteName, String branchToCheckout, final String baseDisplay) throws Exception {
|
||||||
|
LOGGER.trace("checkout : " + baseDisplay);
|
||||||
|
Path git_repo_path = Env.getIslandRootPath().resolve(elem.getPath());
|
||||||
|
if (!Files.exists(git_repo_path)){
|
||||||
|
LOGGER.warn("checkout " + baseDisplay + " ==> 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){
|
||||||
|
LOGGER.warn("checkout " + baseDisplay + " ==> modify data can not checkout new branch");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
List<String> list_branch_local = Commands.getListBranchLocal(git);
|
||||||
|
String select_branch = git.getRepository().getBranch();
|
||||||
|
|
||||||
|
boolean is_tag = false;
|
||||||
|
if (branchToCheckout.equals("__TAG__")) {
|
||||||
|
branchToCheckout = StatusActions.baseNameOfATaggedBranch + elem.getTag();
|
||||||
|
is_tag = true;
|
||||||
|
if (elem.isVolatile()) {
|
||||||
|
LOGGER.info("checkout " + baseDisplay + " ==> Can not checkout for 'volatile' repository");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (elem.getTag() == null) {
|
||||||
|
LOGGER.info("checkout " + baseDisplay + " ==> Can not checkout for 'null' Tag");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check if we are on the good branch{
|
||||||
|
if (branchToCheckout.equals(select_branch)) {
|
||||||
|
LOGGER.info("checkout " + baseDisplay + " ==> No change already on good branch");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// check if we have already checkout the branch before
|
||||||
|
LOGGER.trace(" check : " + branchToCheckout + " in " + list_branch_local);
|
||||||
|
if (list_branch_local.contains("refs/heads/" + branchToCheckout)) {
|
||||||
|
git.checkout().setCreateBranch(false).setName("refs/heads/" + branchToCheckout).call();
|
||||||
|
LOGGER.info("checkout " + baseDisplay + " ==> switch branch");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> list_tags = Commands.getTags(git);
|
||||||
|
if (list_tags.contains("refs/tags/" + branchToCheckout)) {
|
||||||
|
is_tag = true;
|
||||||
|
if (elem.getTag() == null) {
|
||||||
|
elem.setTag(branchToCheckout);
|
||||||
|
branchToCheckout = StatusActions.baseNameOfATaggedBranch + elem.getTag();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Check if the remote branch exist ...
|
||||||
|
if (is_tag) {
|
||||||
|
LOGGER.info("checkout " + baseDisplay + " ==> NO remote branch");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
List<String> list_branch_remote = Commands.getListBranchRemote(git);
|
||||||
|
String tryRemoteBranch = elem.getSelectRemotes().getName() + "/" + branchToCheckout;
|
||||||
|
if (list_branch_remote.contains("refs/remotes/" + tryRemoteBranch)) {
|
||||||
|
LOGGER.info(" ==> find ...");
|
||||||
|
try {
|
||||||
|
git.checkout()
|
||||||
|
.setCreateBranch(true)
|
||||||
|
.setName(branchToCheckout)
|
||||||
|
.setUpstreamMode(SetupUpstreamMode.TRACK)
|
||||||
|
.setStartPoint(tryRemoteBranch)
|
||||||
|
.call();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
LOGGER.error("checkout " + baseDisplay + " ==> Can not checkout to the correct branch");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
LOGGER.info("checkout " + baseDisplay + " ==> create new branch");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Checkout a specific tags{
|
||||||
|
if (!list_tags.contains(elem.getTag())) {
|
||||||
|
LOGGER.info("checkout " + baseDisplay + " ==> NO remote tags");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
LOGGER.info(" ==> find ...");
|
||||||
|
LOGGER.info("[TODO] checkout " + baseDisplay + " ==> 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;
|
||||||
|
LOGGER.trace("execute : " + cmd);
|
||||||
|
ret = multiprocess.run_command(cmd, cwd=git_repo_path);
|
||||||
|
if ret[1] != "" \
|
||||||
|
and ret != false{
|
||||||
|
LOGGER.info("'" + str(ret) + "'");
|
||||||
|
LOGGER.error("checkout " + base_display + " ==> Can not checkout to the correct tags");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
LOGGER.info("checkout " + base_display + " ==> create new branch: " + branch_to_checkout);
|
||||||
|
return true;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
public static int displayStatus(final ProjectConfig elem, final String argumentRemoteName, final boolean argumentDisplayTag, final int idElement, final String baseDisplay) throws IOException, GitAPIException {
|
||||||
|
String volatileString = "";
|
||||||
|
if (elem.isVolatile()) {
|
||||||
|
volatileString = " (volatile)";
|
||||||
|
}
|
||||||
|
LOGGER.trace("status : " + baseDisplay);
|
||||||
|
//LOGGER.debug("elem : " + str(elem))
|
||||||
|
Path git_repo_path = Env.getIslandRootPath().resolve(elem.getPath());
|
||||||
|
if (!Files.exists(git_repo_path)) {
|
||||||
|
LOGGER.print(baseDisplay + 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.getListBranchAll(git);
|
||||||
|
String select_branch = git.getRepository().getBranch();
|
||||||
|
LOGGER.trace("List all branch: " + list_branch);
|
||||||
|
String tracking_remote_branch = null;
|
||||||
|
if (!select_branch.startsWith(StatusActions.baseNameOfATaggedBranch)) {
|
||||||
|
// get tracking branch
|
||||||
|
tracking_remote_branch = Commands.getTrackingBranch(git, argumentRemoteName, select_branch);
|
||||||
|
if (tracking_remote_branch == null) {
|
||||||
|
if (select_branch == null) {
|
||||||
|
LOGGER.print(baseDisplay + volatileString + "\r\t\t\t\t\t\t\t (NO BRANCH)");
|
||||||
|
} else {
|
||||||
|
LOGGER.print(baseDisplay + volatileString + "\r\t\t\t\t\t\t\t " + select_branch);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tracking_remote_branch = select_branch.substring(StatusActions.baseNameOfATaggedBranch.length());
|
||||||
|
}
|
||||||
|
String modify_status = " ";
|
||||||
|
if (is_modify == true) {
|
||||||
|
modify_status = " *** ";
|
||||||
|
}
|
||||||
|
LOGGER.trace("select branch = '" + select_branch + "' is modify : " + is_modify + " track: '" + tracking_remote_branch + "'");
|
||||||
|
DeltaBranch deltas = Commands.getDeltaBranch(git, select_branch, tracking_remote_branch);
|
||||||
|
String behind_forward_comment = "";
|
||||||
|
if (deltas.forward() != 0) {
|
||||||
|
behind_forward_comment += "forward=" + deltas.forward();
|
||||||
|
}
|
||||||
|
if (deltas.behind() != 0) {
|
||||||
|
if (deltas.forward() != 0) {
|
||||||
|
behind_forward_comment += " ";
|
||||||
|
}
|
||||||
|
behind_forward_comment += "behind=" + deltas.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 (argumentDisplayTag) {
|
||||||
|
List<String> ret_current_tags = Commands.getTagsCurrent(git);
|
||||||
|
LOGGER.trace("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- - - - -";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOGGER.print(baseDisplay + volatileString + "\r\t\t\t\t\t\t\t" + modify_status + "(" + select_branch + " -> " + tracking_remote_branch + ")" + behind_forward_comment + tags_comment);
|
||||||
|
Commands.getDiff(git);
|
||||||
|
return deltas.behind();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean deliverCheck(final ProjectConfig elem, final String argumentRemoteName, final int idElement, final String baseDisplay, final String sourceBranch, final String destinationBranch) throws GitAPIException, IOException {
|
||||||
|
boolean deliver_availlable = true;
|
||||||
|
LOGGER.debug("deliver-ckeck: " + baseDisplay);
|
||||||
|
LOGGER.debug(" ==> check repo exist");
|
||||||
|
// Check the repo exist
|
||||||
|
Path git_repo_path = Env.getIslandRootPath().resolve(elem.getPath());
|
||||||
|
if (!Files.exists(git_repo_path)) {
|
||||||
|
LOGGER.warn("deliver-ckeck: " + baseDisplay + " ==> MUST be download");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
LOGGER.debug(" ==> check is modify");
|
||||||
|
// check if the curent repo is modify
|
||||||
|
Git git = Git.open(git_repo_path.toFile());
|
||||||
|
boolean is_modify = git.status().call().hasUncommittedChanges();
|
||||||
|
if (is_modify) {
|
||||||
|
LOGGER.warn("deliver-ckeck: " + baseDisplay + " ==> MUST not be modify");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGGER.debug(" ==> check current branch is '" + sourceBranch + "'");
|
||||||
|
// check if we are on source_branch
|
||||||
|
String select_branch = git.getRepository().getBranch();
|
||||||
|
if (!select_branch.equals(sourceBranch)) {
|
||||||
|
LOGGER.warn("deliver-ckeck: " + baseDisplay + " ==> MUST be on source branch: '" + sourceBranch + "' and is: '" + select_branch + "'");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
LOGGER.debug(" ==> check have tracking branch");
|
||||||
|
// check if we have a remote traking branch
|
||||||
|
String tracking_remote_branch = Commands.getTrackingBranch(git, argumentRemoteName, select_branch);
|
||||||
|
if (tracking_remote_branch == null) {
|
||||||
|
LOGGER.warn("deliver-ckeck: " + baseDisplay + " ==> MUST have a remote tracking branch");
|
||||||
|
deliver_availlable = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// go on destination branch
|
||||||
|
Commands.checkout(git, destinationBranch);
|
||||||
|
LOGGER.debug(" ==> check current branch is '" + sourceBranch + "'");
|
||||||
|
// check if we are on "master"
|
||||||
|
select_branch = git.getRepository().getBranch();
|
||||||
|
if (select_branch != destinationBranch) {
|
||||||
|
LOGGER.warn("deliver-ckeck: " + baseDisplay + " ==> Can not checkout branch: '" + destinationBranch + "' and is: '" + select_branch + "'");
|
||||||
|
deliver_availlable = false;
|
||||||
|
}
|
||||||
|
LOGGER.debug(" ==> check have tracking branch");
|
||||||
|
// check if we have a remote traking branch
|
||||||
|
tracking_remote_branch = Commands.getTrackingBranch(git, argumentRemoteName, select_branch);
|
||||||
|
if (tracking_remote_branch == null) {
|
||||||
|
LOGGER.warn("deliver-ckeck: " + baseDisplay + " ==> MUST have a remote tracking branch");
|
||||||
|
deliver_availlable = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check out back the source branch
|
||||||
|
Commands.checkout(git, sourceBranch);
|
||||||
|
return deliver_availlable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
45
src/org/atriasoft/island/actions/VolatileAdd.java
Normal file
45
src/org/atriasoft/island/actions/VolatileAdd.java
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package org.atriasoft.island.actions;
|
||||||
|
|
||||||
|
import org.atriasoft.death.annotation.ArgCommand;
|
||||||
|
import org.atriasoft.death.annotation.ArgDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgExecute;
|
||||||
|
import org.atriasoft.death.annotation.ArgParams;
|
||||||
|
import org.atriasoft.death.annotation.ArgParamsDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgSample;
|
||||||
|
import org.atriasoft.island.Config;
|
||||||
|
import org.atriasoft.island.Manifest;
|
||||||
|
import org.atriasoft.island.internal.Log;
|
||||||
|
import org.atriasoft.island.model.ActionException;
|
||||||
|
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||||
|
|
||||||
|
@ArgCommand("volatile-add")
|
||||||
|
@ArgDescription("Add a 'volatile' repository with a local path (this element is update as an element in the manifest but is not managed by the manifest)")
|
||||||
|
@ArgSample("volatile-add https://git.heeroyui.org/atria-tools/island.git git")
|
||||||
|
public class VolatileAdd {
|
||||||
|
|
||||||
|
@ArgExecute
|
||||||
|
@ArgParams({"git repository", "path"})
|
||||||
|
@ArgParamsDescription({"Git repositoty to download", "Path to install the new git repository"})
|
||||||
|
public void execute(final String remoteUrl, final String localPath) throws ActionException, Exception {
|
||||||
|
|
||||||
|
if (remoteUrl.isEmpty()) {
|
||||||
|
LOGGER.error("volatile-add: Missing git repository address ...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LOGGER.info("Add 'volatile' repository: '" + remoteUrl + "' path='" + localPath + "'");
|
||||||
|
|
||||||
|
// check system is OK
|
||||||
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
|
// Update the current configuration:
|
||||||
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
if (configuration.existVolatile(localPath)) {
|
||||||
|
LOGGER.error("Volatile Already exist !!!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// TODO: Check if the local path does not exist in the manifest
|
||||||
|
configuration.addVolatile(remoteUrl, localPath);
|
||||||
|
configuration.store();
|
||||||
|
LOGGER.print("Volatile added: " + localPath);
|
||||||
|
}
|
||||||
|
}
|
41
src/org/atriasoft/island/actions/VolatileList.java
Normal file
41
src/org/atriasoft/island/actions/VolatileList.java
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package org.atriasoft.island.actions;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.death.annotation.ArgCommand;
|
||||||
|
import org.atriasoft.death.annotation.ArgDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgExecute;
|
||||||
|
import org.atriasoft.death.annotation.ArgSample;
|
||||||
|
import org.atriasoft.island.Config;
|
||||||
|
import org.atriasoft.island.Manifest;
|
||||||
|
import org.atriasoft.island.internal.Log;
|
||||||
|
import org.atriasoft.island.model.ActionException;
|
||||||
|
import org.atriasoft.island.model.Volatile;
|
||||||
|
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||||
|
|
||||||
|
@ArgCommand("volatile-list")
|
||||||
|
@ArgDescription("List all volatiles elements")
|
||||||
|
@ArgSample("volatile-list")
|
||||||
|
public class VolatileList {
|
||||||
|
|
||||||
|
@ArgExecute
|
||||||
|
public void execute() throws ActionException, Exception {
|
||||||
|
LOGGER.info("List all 'volatile'");
|
||||||
|
|
||||||
|
// check system is OK
|
||||||
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
|
// Update the current configuration:
|
||||||
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
List<Volatile> volatiles = configuration.getVolatiles();
|
||||||
|
|
||||||
|
LOGGER.print("List of volatiles:");
|
||||||
|
if (volatiles.size() == 0) {
|
||||||
|
LOGGER.print("\t==> No repository");
|
||||||
|
} else {
|
||||||
|
for (Volatile elem : volatiles) {
|
||||||
|
LOGGER.print("\t" + elem.getPath() + "\r\t\t\t\t" + elem.getAddress());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
40
src/org/atriasoft/island/actions/VolatileRemove.java
Normal file
40
src/org/atriasoft/island/actions/VolatileRemove.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package org.atriasoft.island.actions;
|
||||||
|
|
||||||
|
import org.atriasoft.death.annotation.ArgCommand;
|
||||||
|
import org.atriasoft.death.annotation.ArgDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgExecute;
|
||||||
|
import org.atriasoft.death.annotation.ArgParams;
|
||||||
|
import org.atriasoft.death.annotation.ArgParamsDescription;
|
||||||
|
import org.atriasoft.death.annotation.ArgSample;
|
||||||
|
import org.atriasoft.island.Config;
|
||||||
|
import org.atriasoft.island.Manifest;
|
||||||
|
import org.atriasoft.island.internal.Log;
|
||||||
|
import org.atriasoft.island.model.ActionException;
|
||||||
|
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||||
|
|
||||||
|
@ArgCommand("volatile-rm")
|
||||||
|
@ArgDescription("Remove a 'volatile' repository with a local path")
|
||||||
|
@ArgSample("volatile-rm git")
|
||||||
|
public class VolatileRemove {
|
||||||
|
|
||||||
|
@ArgExecute
|
||||||
|
@ArgParams("path")
|
||||||
|
@ArgParamsDescription("Path to install the new git repository")
|
||||||
|
public void execute(final String localPath) throws ActionException, Exception {
|
||||||
|
LOGGER.info("Remove 'volatile' repository: path='" + localPath + "'");
|
||||||
|
|
||||||
|
// check system is OK
|
||||||
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
|
// Update the current configuration:
|
||||||
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
if (!configuration.existVolatile(localPath)) {
|
||||||
|
LOGGER.error("Volatile Does not exist !!!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// TODO: Check if the local path does not exist in the manifest
|
||||||
|
configuration.rmVolatile(localPath);
|
||||||
|
configuration.store();
|
||||||
|
LOGGER.print("Volatile Removed: " + localPath);
|
||||||
|
}
|
||||||
|
}
|
@ -1,72 +1,73 @@
|
|||||||
package org.atriasoft.island.internal;
|
package org.atriasoft.island.internal;
|
||||||
|
|
||||||
import io.scenarium.logger.LogLevel;
|
import org.atriasoft.reggol.LogLevel;
|
||||||
import io.scenarium.logger.Logger;
|
import org.atriasoft.reggol.Logger;
|
||||||
|
|
||||||
public class Log {
|
public class Log {
|
||||||
|
private static final boolean FORCE = false;
|
||||||
private static final String LIB_NAME = "island";
|
private static final String LIB_NAME = "island";
|
||||||
private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME);
|
private static final String LIB_NAME_DRAW = Logger.getDrawableName(LOGGER.LIB_NAME);
|
||||||
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL);
|
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.CRITICAL);
|
||||||
private static final boolean PRINT_ERROR = Logger.getNeedPrint(LIB_NAME, LogLevel.ERROR);
|
private static final boolean PRINT_ERROR = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.ERROR);
|
||||||
private static final boolean PRINT_WARNING = Logger.getNeedPrint(LIB_NAME, LogLevel.WARNING);
|
private static final boolean PRINT_WARNING = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.WARNING);
|
||||||
private static final boolean PRINT_INFO = Logger.getNeedPrint(LIB_NAME, LogLevel.INFO);
|
private static final boolean PRINT_INFO = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.INFO);
|
||||||
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG);
|
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.DEBUG);
|
||||||
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LIB_NAME, LogLevel.VERBOSE);
|
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.VERBOSE);
|
||||||
private static final boolean PRINT_TODO = Logger.getNeedPrint(LIB_NAME, LogLevel.TODO);
|
private static final boolean PRINT_TODO = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.TODO);
|
||||||
private static final boolean PRINT_PRINT = Logger.getNeedPrint(LIB_NAME, LogLevel.PRINT);
|
private static final boolean PRINT_PRINT = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.PRINT);
|
||||||
|
|
||||||
public static void critical(final String data) {
|
|
||||||
if (PRINT_CRITICAL) {
|
|
||||||
Logger.critical(LIB_NAME_DRAW, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void critical(final String data, final Exception e) {
|
public static void critical(final String data, final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
if (PRINT_CRITICAL) {
|
if (LOGGER.PRINT_CRITICAL || LOGGER.FORCE) {
|
||||||
Logger.critical(LIB_NAME_DRAW, data + " : " + e.getMessage());
|
Logger.critical(LOGGER.LIB_NAME_DRAW, data + " : " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debug(final String data) {
|
public static void critical(final String data, Object... objects) {
|
||||||
if (PRINT_DEBUG) {
|
if (LOGGER.PRINT_CRITICAL || LOGGER.FORCE) {
|
||||||
Logger.debug(LIB_NAME_DRAW, data);
|
Logger.critical(LOGGER.LIB_NAME_DRAW, data, objects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void error(final String data) {
|
public static void debug(final String data, Object... objects) {
|
||||||
if (PRINT_ERROR) {
|
if (LOGGER.PRINT_DEBUG || LOGGER.FORCE) {
|
||||||
Logger.error(LIB_NAME_DRAW, data);
|
Logger.debug(LOGGER.LIB_NAME_DRAW, data, objects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void info(final String data) {
|
public static void error(final String data, Object... objects) {
|
||||||
if (PRINT_INFO) {
|
if (LOGGER.PRINT_ERROR || LOGGER.FORCE) {
|
||||||
Logger.info(LIB_NAME_DRAW, data);
|
Logger.error(LOGGER.LIB_NAME_DRAW, data, objects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void print(final String data) {
|
public static void info(final String data, Object... objects) {
|
||||||
if (PRINT_PRINT) {
|
if (LOGGER.PRINT_INFO || LOGGER.FORCE) {
|
||||||
Logger.print(LIB_NAME_DRAW, data);
|
Logger.info(LOGGER.LIB_NAME_DRAW, data, objects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void todo(final String data) {
|
public static void print(final String data, Object... objects) {
|
||||||
if (PRINT_TODO) {
|
if (LOGGER.PRINT_PRINT || LOGGER.FORCE) {
|
||||||
Logger.todo(LIB_NAME_DRAW, data);
|
Logger.print(LOGGER.LIB_NAME_DRAW, data, objects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void verbose(final String data) {
|
public static void todo(final String data, Object... objects) {
|
||||||
if (PRINT_VERBOSE) {
|
if (LOGGER.PRINT_TODO || LOGGER.FORCE) {
|
||||||
Logger.verbose(LIB_NAME_DRAW, data);
|
Logger.todo(LOGGER.LIB_NAME_DRAW, data, objects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void warning(final String data) {
|
public static void verbose(final String data, Object... objects) {
|
||||||
if (PRINT_WARNING) {
|
if (LOGGER.PRINT_VERBOSE || LOGGER.FORCE) {
|
||||||
Logger.warning(LIB_NAME_DRAW, data);
|
Logger.verbose(LOGGER.LIB_NAME_DRAW, data, objects);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void warning(final String data, Object... objects) {
|
||||||
|
if (LOGGER.PRINT_WARNING || LOGGER.FORCE) {
|
||||||
|
Logger.warning(LOGGER.LIB_NAME_DRAW, data, objects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
src/org/atriasoft/island/model/ActionException.java
Normal file
10
src/org/atriasoft/island/model/ActionException.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package org.atriasoft.island.model;
|
||||||
|
|
||||||
|
public class ActionException extends Exception {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public ActionException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
5
src/org/atriasoft/island/model/DeltaBranch.java
Normal file
5
src/org/atriasoft/island/model/DeltaBranch.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package org.atriasoft.island.model;
|
||||||
|
|
||||||
|
public record DeltaBranch(int forward, int behind) {
|
||||||
|
|
||||||
|
}
|
17
src/org/atriasoft/island/model/GLDDependModel.java
Normal file
17
src/org/atriasoft/island/model/GLDDependModel.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package org.atriasoft.island.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.aknot.annotation.AknotName;
|
||||||
|
|
||||||
|
public class GLDDependModel {
|
||||||
|
public String type = "LIBRARY";
|
||||||
|
@AknotName("group-id")
|
||||||
|
public String groupId;
|
||||||
|
public String version;
|
||||||
|
public GLDDependPathModel path = new GLDDependPathModel();
|
||||||
|
public List<String> dependency = new ArrayList<>();
|
||||||
|
@AknotName("dependency-build")
|
||||||
|
public List<String> dependencyBuild = new ArrayList<>();
|
||||||
|
}
|
8
src/org/atriasoft/island/model/GLDDependPathModel.java
Normal file
8
src/org/atriasoft/island/model/GLDDependPathModel.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package org.atriasoft.island.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GLDDependPathModel {
|
||||||
|
public List<String> java = new ArrayList<>();
|
||||||
|
}
|
41
src/org/atriasoft/island/model/RepositoryConfig.java
Normal file
41
src/org/atriasoft/island/model/RepositoryConfig.java
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package org.atriasoft.island.model;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
32
src/org/atriasoft/island/model/Volatile.java
Normal file
32
src/org/atriasoft/island/model/Volatile.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package org.atriasoft.island.model;
|
||||||
|
|
||||||
|
import org.atriasoft.aknot.annotation.AknotName;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotDefaultAttribute;
|
||||||
|
|
||||||
|
@AknotDefaultAttribute
|
||||||
|
public class Volatile {
|
||||||
|
private String address;
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
@AknotName({ "address", "path" })
|
||||||
|
public Volatile(final String gitAddress, final String path) {
|
||||||
|
this.address = gitAddress;
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddress() {
|
||||||
|
return this.address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return this.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(final String gitAddress) {
|
||||||
|
this.address = gitAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPath(final String path) {
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
}
|
62
src/org/atriasoft/island/model/manifest/Artifactory.java
Normal file
62
src/org/atriasoft/island/model/manifest/Artifactory.java
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
package org.atriasoft.island.model.manifest;
|
||||||
|
|
||||||
|
import org.atriasoft.aknot.annotation.AknotName;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotDefaultAttribute;
|
||||||
|
|
||||||
|
@AknotDefaultAttribute
|
||||||
|
public class Artifactory {
|
||||||
|
private String name; // Local name of the remote.
|
||||||
|
private String fetch; // Address to fetch.
|
||||||
|
private String type; // type of artifactory (default maven to update later ...)
|
||||||
|
|
||||||
|
public Artifactory() {
|
||||||
|
this.name = "";
|
||||||
|
this.fetch = "";
|
||||||
|
this.type = "maven";
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName({ "name", "fetch" })
|
||||||
|
public Artifactory(final String name, final String fetch) {
|
||||||
|
this.name = name;
|
||||||
|
this.fetch = fetch;
|
||||||
|
this.type = "maven";
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName({ "name", "fetch", "type" })
|
||||||
|
public Artifactory(final String name, final String fetch, final String type) {
|
||||||
|
this.name = name;
|
||||||
|
this.fetch = fetch;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Artifactory clone() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return new Artifactory(this.name, this.fetch, this.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFetch() {
|
||||||
|
return this.fetch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return this.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFetch(final String fetch) {
|
||||||
|
this.fetch = fetch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(final String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(final String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
191
src/org/atriasoft/island/model/manifest/ConfigManifest.java
Normal file
191
src/org/atriasoft/island/model/manifest/ConfigManifest.java
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
package org.atriasoft.island.model.manifest;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ListIterator;
|
||||||
|
|
||||||
|
import org.atriasoft.aknot.annotation.AknotList;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotName;
|
||||||
|
import org.atriasoft.aknot.exception.AknotException;
|
||||||
|
import org.atriasoft.exml.XmlMapper;
|
||||||
|
import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||||
|
import org.atriasoft.exml.exception.ExmlException;
|
||||||
|
import org.atriasoft.island.Env;
|
||||||
|
import org.atriasoft.island.internal.Log;
|
||||||
|
import org.atriasoft.island.model.Volatile;
|
||||||
|
|
||||||
|
@AknotName("config-island")
|
||||||
|
public class ConfigManifest {
|
||||||
|
|
||||||
|
public static ConfigManifest load() {
|
||||||
|
return ConfigManifest.load(Env.getIslandPathConfig());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ConfigManifest load(final Path path) {
|
||||||
|
ConfigManifest root = null;
|
||||||
|
final XmlMapper mapper = new XmlMapper();
|
||||||
|
try {
|
||||||
|
root = mapper.parse(path, ConfigManifest.class);
|
||||||
|
} catch (final ExmlException e) {
|
||||||
|
LOGGER.error("Can not parse the file.1. " + path);
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (final AknotException e) {
|
||||||
|
LOGGER.error("Can not parse the file.2. " + path);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String repo = "";
|
||||||
|
private String branch = "master";
|
||||||
|
private String manifestName = "default.xml";
|
||||||
|
|
||||||
|
private List<Volatile> volatiles = new ArrayList<>();
|
||||||
|
|
||||||
|
private List<Link> links = new ArrayList<>();
|
||||||
|
|
||||||
|
public ConfigManifest() {}
|
||||||
|
|
||||||
|
public void addLink(final String source, final String destination) {
|
||||||
|
rmLink(destination);
|
||||||
|
this.links.add(new Link(source, destination));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addVolatile(final String gitAddress, final String path) {
|
||||||
|
rmVolatile(path);
|
||||||
|
this.volatiles.add(new Volatile(gitAddress, path));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String createAdressGitRepo(final String fetch, final String name) {
|
||||||
|
|
||||||
|
// check if it is a directAdress:
|
||||||
|
if (fetch.startsWith("git@") || fetch.startsWith("http://") || fetch.startsWith("https://")) {
|
||||||
|
if (fetch.startsWith("git@") && fetch.substring(4).split(":").length <= 1) {
|
||||||
|
return fetch + ":" + name;
|
||||||
|
}
|
||||||
|
return fetch + "/" + name;
|
||||||
|
}
|
||||||
|
// this is a relative repository (../xxxx) >> need to remove enought path in the root...
|
||||||
|
String addressManifest = this.repo.replace('\\', '/');
|
||||||
|
String offsetFetch = fetch.replace('\\', '/');
|
||||||
|
while (offsetFetch.startsWith("..")) {
|
||||||
|
if (offsetFetch.startsWith("../")) {
|
||||||
|
offsetFetch = offsetFetch.substring(3);
|
||||||
|
} else if (offsetFetch.equals("..")) {
|
||||||
|
offsetFetch = offsetFetch.substring(2);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
int index = addressManifest.lastIndexOf('/');
|
||||||
|
if (index == -1) {
|
||||||
|
index = addressManifest.lastIndexOf(':');
|
||||||
|
if (index == -1) {
|
||||||
|
LOGGER.critical("Can not retrieve the path of the repository : " + this.repo + " AND " + fetch);
|
||||||
|
}
|
||||||
|
index += 1;
|
||||||
|
}
|
||||||
|
addressManifest = addressManifest.substring(0, index);
|
||||||
|
}
|
||||||
|
return addressManifest + offsetFetch + name;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean existVolatile(final String path) {
|
||||||
|
final ListIterator<Volatile> it = this.volatiles.listIterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
final Volatile elem = it.next();
|
||||||
|
if (elem.getPath().equals(path)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBranch() {
|
||||||
|
return this.branch;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotList(value = "link")
|
||||||
|
public List<Link> getLinks() {
|
||||||
|
return this.links;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProjectConfig getManifestConfig() {
|
||||||
|
return new ProjectConfig("manifest", Env.getIslandPathManifest().resolve(getManifestName()).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName(value = "manifest-name")
|
||||||
|
public String getManifestName() {
|
||||||
|
return this.manifestName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRepo() {
|
||||||
|
return this.repo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotList(value = "volatile")
|
||||||
|
public List<Volatile> getVolatiles() {
|
||||||
|
return this.volatiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rmLink(final String destination) {
|
||||||
|
final ListIterator<Link> it = this.links.listIterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
final Link elem = it.next();
|
||||||
|
if (elem.getDestination().equals(destination)) {
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rmVolatile(final String path) {
|
||||||
|
final ListIterator<Volatile> it = this.volatiles.listIterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
final Volatile elem = it.next();
|
||||||
|
if (elem.getPath().equals(path)) {
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBranch(final String branch) {
|
||||||
|
this.branch = branch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLinks(final List<Link> curentLink) {
|
||||||
|
this.links = curentLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setManifestName(final String manifestName) {
|
||||||
|
this.manifestName = manifestName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRepo(final String repo) {
|
||||||
|
this.repo = repo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVolatiles(final List<Volatile> volatiles) {
|
||||||
|
this.volatiles = volatiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void store() {
|
||||||
|
try {
|
||||||
|
store(Env.getIslandPathConfig());
|
||||||
|
} catch (final ExmlBuilderException e) {
|
||||||
|
LOGGER.error("Can not store the configuration ... ");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void store(final Path path) throws ExmlBuilderException {
|
||||||
|
final XmlMapper mapper = new XmlMapper();
|
||||||
|
try {
|
||||||
|
mapper.store(this, path);
|
||||||
|
} catch (final ExmlException | IOException | AknotException ex) {
|
||||||
|
LOGGER.warn("detect throw: " + ex.getMessage());
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
6
src/org/atriasoft/island/model/manifest/DeliverMode.java
Normal file
6
src/org/atriasoft/island/model/manifest/DeliverMode.java
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package org.atriasoft.island.model.manifest;
|
||||||
|
|
||||||
|
public enum DeliverMode {
|
||||||
|
MERGE,
|
||||||
|
FAST_FORWARD;
|
||||||
|
}
|
31
src/org/atriasoft/island/model/manifest/Dependency.java
Normal file
31
src/org/atriasoft/island/model/manifest/Dependency.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package org.atriasoft.island.model.manifest;
|
||||||
|
|
||||||
|
import org.atriasoft.aknot.annotation.AknotName;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotOptional;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotDefaultAttribute;
|
||||||
|
|
||||||
|
@AknotDefaultAttribute
|
||||||
|
public record Dependency(
|
||||||
|
String org,
|
||||||
|
String name,
|
||||||
|
@AknotOptional String revision,
|
||||||
|
@AknotOptional String remote) { // TODO this is a big mistake for xml , can not parse multiple type... use @XmlOptionnal(nullDefaultValue=true)
|
||||||
|
|
||||||
|
@AknotName({ "org", "name", "rev", "remote" })
|
||||||
|
public Dependency(final String org, final String name, final String revision, final String remote) {
|
||||||
|
this.org = org;
|
||||||
|
this.name = name;
|
||||||
|
this.revision = revision;
|
||||||
|
this.remote = remote == null ? "default" : remote;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName({ "org", "name", "rev" })
|
||||||
|
public Dependency(final String org, final String name, final String revision) {
|
||||||
|
this(org, name, revision, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName({ "org", "name" })
|
||||||
|
public Dependency(final String org, final String name) {
|
||||||
|
this(org, name, null, null);
|
||||||
|
}
|
||||||
|
}
|
30
src/org/atriasoft/island/model/manifest/Link.java
Normal file
30
src/org/atriasoft/island/model/manifest/Link.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package org.atriasoft.island.model.manifest;
|
||||||
|
|
||||||
|
import org.atriasoft.aknot.annotation.AknotDefaultAttribute;
|
||||||
|
|
||||||
|
@AknotDefaultAttribute
|
||||||
|
public class Link {
|
||||||
|
private String source;
|
||||||
|
private String destination;
|
||||||
|
public Link(final String source, final String destination) {
|
||||||
|
this.source = source;
|
||||||
|
this.destination = destination;
|
||||||
|
}
|
||||||
|
public 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
96
src/org/atriasoft/island/model/manifest/ManifestFile.java
Normal file
96
src/org/atriasoft/island/model/manifest/ManifestFile.java
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
package org.atriasoft.island.model.manifest;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.aknot.annotation.AknotIgnoreUnknown;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotList;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotManaged;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotName;
|
||||||
|
|
||||||
|
@AknotIgnoreUnknown
|
||||||
|
@AknotName("manifest")
|
||||||
|
public class ManifestFile {
|
||||||
|
private Path fileRealPath = null;
|
||||||
|
private List<ProjectConfig> projects = new ArrayList<>();
|
||||||
|
private List<RemoteConfig> remotes = new ArrayList<>();
|
||||||
|
private List<Artifactory> artefactories = new ArrayList<>();
|
||||||
|
private List<String> includes = new ArrayList<>();
|
||||||
|
private List<Dependency> dependencies = new ArrayList<>();
|
||||||
|
private OptionRepository options = null;
|
||||||
|
private List<Link> links = new ArrayList<>();
|
||||||
|
|
||||||
|
@AknotName("artefactory")
|
||||||
|
public List<Artifactory> getArtefactories() {
|
||||||
|
return this.artefactories;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName(value = "dependencies")
|
||||||
|
@AknotList(value = "dependency")
|
||||||
|
public List<Dependency> getDependencies() {
|
||||||
|
return this.dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotManaged(false)
|
||||||
|
public Path getFileRealPath() {
|
||||||
|
return this.fileRealPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName(value = "include")
|
||||||
|
public List<String> getIncludes() {
|
||||||
|
return this.includes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName(value = "link")
|
||||||
|
public List<Link> getLinks() {
|
||||||
|
return this.links;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OptionRepository getOptions() {
|
||||||
|
return this.options;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName(value = "project")
|
||||||
|
public List<ProjectConfig> getProjects() {
|
||||||
|
return this.projects;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName(value = "remote")
|
||||||
|
public List<RemoteConfig> getRemotes() {
|
||||||
|
return this.remotes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArtefactories(final List<Artifactory> artefacts) {
|
||||||
|
this.artefactories = artefacts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDependencies(final List<Dependency> dependency) {
|
||||||
|
this.dependencies = dependency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileRealPath(final Path fileRealPath) {
|
||||||
|
this.fileRealPath = fileRealPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIncludes(final List<String> includes) {
|
||||||
|
this.includes = includes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLinks(final List<Link> links) {
|
||||||
|
this.links = links;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOptions(final OptionRepository options) {
|
||||||
|
this.options = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProjects(final List<ProjectConfig> projects) {
|
||||||
|
this.projects = projects;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemotes(final List<RemoteConfig> remotes) {
|
||||||
|
this.remotes = remotes;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
33
src/org/atriasoft/island/model/manifest/MirrorConfig.java
Normal file
33
src/org/atriasoft/island/model/manifest/MirrorConfig.java
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package org.atriasoft.island.model.manifest;
|
||||||
|
|
||||||
|
import org.atriasoft.aknot.annotation.AknotName;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotDefaultAttribute;
|
||||||
|
|
||||||
|
@AknotDefaultAttribute
|
||||||
|
public class MirrorConfig {
|
||||||
|
private String name;
|
||||||
|
private String fetch;
|
||||||
|
|
||||||
|
@AknotName({ "name", "fetch" })
|
||||||
|
public MirrorConfig(final String name, final String fetch) {
|
||||||
|
this.name = name;
|
||||||
|
this.fetch = fetch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFetch() {
|
||||||
|
return this.fetch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFetch(final String fetch) {
|
||||||
|
this.fetch = fetch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(final String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
package org.atriasoft.island.model.manifest;
|
||||||
|
|
||||||
|
import org.atriasoft.aknot.annotation.AknotName;
|
||||||
|
|
||||||
|
public class OptionRepository {
|
||||||
|
private String branchRelease;
|
||||||
|
private String branchDevelop;
|
||||||
|
private DeliverMode deliverMode;
|
||||||
|
private String defaultBranch;
|
||||||
|
private String defaultRemote;
|
||||||
|
private boolean synchronizeSubmodule;
|
||||||
|
|
||||||
|
public OptionRepository() {
|
||||||
|
this.branchRelease = "master";
|
||||||
|
this.branchDevelop = "dev";
|
||||||
|
this.deliverMode = DeliverMode.MERGE;
|
||||||
|
this.defaultBranch = "master";
|
||||||
|
this.defaultRemote = "origin";
|
||||||
|
this.synchronizeSubmodule = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OptionRepository(final String branchRelease, final String branchDevelop, final DeliverMode deliverMode, final String defaultBranch, final String defaultRemote,
|
||||||
|
final boolean synchronizeSubmodule) {
|
||||||
|
this.branchRelease = branchRelease;
|
||||||
|
this.branchDevelop = branchDevelop;
|
||||||
|
this.deliverMode = deliverMode;
|
||||||
|
this.defaultBranch = defaultBranch;
|
||||||
|
this.defaultRemote = defaultRemote;
|
||||||
|
this.synchronizeSubmodule = synchronizeSubmodule;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OptionRepository clone() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return new OptionRepository(this.branchRelease, this.branchDevelop, this.deliverMode, this.defaultBranch, this.defaultRemote, this.synchronizeSubmodule);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName(value = "branch-develop")
|
||||||
|
public String getBranchDevelop() {
|
||||||
|
return this.branchDevelop;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName(value = "branch-release")
|
||||||
|
public String getBranchRelease() {
|
||||||
|
return this.branchRelease;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName(value = "default-branch")
|
||||||
|
public String getDefaultBranch() {
|
||||||
|
return this.defaultBranch;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName(value = "default-remote")
|
||||||
|
public String getDefaultRemote() {
|
||||||
|
return this.defaultRemote;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName(value = "deliver-mode")
|
||||||
|
public DeliverMode getDeliverMode() {
|
||||||
|
return this.deliverMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName(value = "synchronize-submodule")
|
||||||
|
public boolean isSynchronizeSubmodule() {
|
||||||
|
return this.synchronizeSubmodule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBranchDevelop(final String branchDevelop) {
|
||||||
|
this.branchDevelop = branchDevelop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBranchRelease(final String branchRelease) {
|
||||||
|
this.branchRelease = branchRelease;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultBranch(final String defaultBranch) {
|
||||||
|
this.defaultBranch = defaultBranch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultRemote(final String defaultRemote) {
|
||||||
|
this.defaultRemote = defaultRemote;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeliverMode(final DeliverMode deliverMode) {
|
||||||
|
this.deliverMode = deliverMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSynchronizeSubmodule(final boolean downloadSubmodule) {
|
||||||
|
this.synchronizeSubmodule = downloadSubmodule;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "OptionRepository [branchRelease=" + this.branchRelease + ", branchDevelop=" + this.branchDevelop + ", deliverMode=" + this.deliverMode + ", defaultBranch=" + this.defaultBranch
|
||||||
|
+ ", defaultRemote=" + this.defaultRemote + ", synchronizeSubmodule=" + this.synchronizeSubmodule + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
111
src/org/atriasoft/island/model/manifest/ProjectConfig.java
Normal file
111
src/org/atriasoft/island/model/manifest/ProjectConfig.java
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
package org.atriasoft.island.model.manifest;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.aknot.annotation.AknotManaged;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotName;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotOptional;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotDefaultAttribute;
|
||||||
|
|
||||||
|
@AknotDefaultAttribute
|
||||||
|
public class ProjectConfig {
|
||||||
|
private String name;
|
||||||
|
private String path;
|
||||||
|
private String tag;
|
||||||
|
private String branch;
|
||||||
|
private boolean volatileElement = false;
|
||||||
|
private List<RemoteConfig> remotes = new ArrayList<>();
|
||||||
|
RemoteConfig selectRemotes = null;
|
||||||
|
|
||||||
|
// TODO remove this when Xml parser is ready ...
|
||||||
|
public ProjectConfig() {
|
||||||
|
this.name = null;
|
||||||
|
this.path = null;
|
||||||
|
this.tag = null;
|
||||||
|
this.branch = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName({ "name", "path" })
|
||||||
|
public ProjectConfig(final String name, final String path) {
|
||||||
|
this.name = name;
|
||||||
|
this.path = path;
|
||||||
|
this.tag = null;
|
||||||
|
this.branch = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName({ "name", "path", "branch" })
|
||||||
|
public ProjectConfig(final String name, final String path, final String branch) {
|
||||||
|
this.name = name;
|
||||||
|
this.path = path;
|
||||||
|
this.tag = null;
|
||||||
|
this.tag = branch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBranch() {
|
||||||
|
return this.branch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return this.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotManaged(false)
|
||||||
|
public List<RemoteConfig> getRemotes() {
|
||||||
|
return this.remotes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotManaged(false)
|
||||||
|
public RemoteConfig getSelectRemotes() {
|
||||||
|
return this.selectRemotes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotOptional
|
||||||
|
public String getTag() {
|
||||||
|
return this.tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotManaged(false)
|
||||||
|
public boolean isVolatile() {
|
||||||
|
return this.volatileElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotOptional
|
||||||
|
public void setBranch(final String branch) {
|
||||||
|
this.branch = branch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(final String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPath(final String path) {
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemotes(final List<RemoteConfig> remotes) {
|
||||||
|
this.remotes = remotes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectRemotes(final RemoteConfig selectRemotes) {
|
||||||
|
this.selectRemotes = selectRemotes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTag(final String tag) {
|
||||||
|
this.tag = tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVolatile(final boolean volatileElement) {
|
||||||
|
this.volatileElement = volatileElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ProjectConfig [name=" + this.name + ", path=" + this.path + ", tag=" + this.tag + ", branch=" + this.branch + ", volatileElement=" + this.volatileElement + ", remotes=" + this.remotes
|
||||||
|
+ ", selectRemotes=" + this.selectRemotes + "]";
|
||||||
|
}
|
||||||
|
}
|
71
src/org/atriasoft/island/model/manifest/RemoteConfig.java
Normal file
71
src/org/atriasoft/island/model/manifest/RemoteConfig.java
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package org.atriasoft.island.model.manifest;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.aknot.annotation.AknotName;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotOptional;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotAttribute;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotDefaultAttribute;
|
||||||
|
|
||||||
|
@AknotDefaultAttribute
|
||||||
|
public class RemoteConfig {
|
||||||
|
private String name; // Local name of the remote.
|
||||||
|
private String fetch; // Address to fetch.
|
||||||
|
private boolean sync = true; // Need to sync the submodule.
|
||||||
|
List<MirrorConfig> mirror; // List of all mirror available.
|
||||||
|
|
||||||
|
public RemoteConfig() {
|
||||||
|
this.name = "";
|
||||||
|
this.fetch = "";
|
||||||
|
this.mirror = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotName({ "name", "fetch", "mirror" })
|
||||||
|
public RemoteConfig(final String name, final String fetch, final List<MirrorConfig> mirror) {
|
||||||
|
this.name = name;
|
||||||
|
this.fetch = fetch;
|
||||||
|
this.mirror = mirror;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RemoteConfig clone() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return new RemoteConfig(this.name, this.fetch, new ArrayList<>(this.mirror));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFetch() {
|
||||||
|
return this.fetch;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotAttribute(false)
|
||||||
|
public List<MirrorConfig> getMirror() {
|
||||||
|
return this.mirror;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AknotOptional
|
||||||
|
public boolean isSync() {
|
||||||
|
return this.sync;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFetch(final String fetch) {
|
||||||
|
this.fetch = fetch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMirror(final List<MirrorConfig> mirror) {
|
||||||
|
this.mirror = mirror;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(final String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSync(final boolean sync) {
|
||||||
|
this.sync = sync;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
15
src/org/atriasoft/island/model/maven/MavenMetadata.java
Normal file
15
src/org/atriasoft/island/model/maven/MavenMetadata.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package org.atriasoft.island.model.maven;
|
||||||
|
|
||||||
|
import org.atriasoft.aknot.annotation.AknotDefaultAttribute;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotIgnoreUnknown;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotName;
|
||||||
|
|
||||||
|
@AknotDefaultAttribute(false)
|
||||||
|
@AknotIgnoreUnknown
|
||||||
|
@AknotName("metadata")
|
||||||
|
public record MavenMetadata(
|
||||||
|
@AknotName("groupId") String groupId,
|
||||||
|
@AknotName("artifactId") String artifactId,
|
||||||
|
@AknotName("versioning") Versioning versioning) {
|
||||||
|
|
||||||
|
}
|
16
src/org/atriasoft/island/model/maven/PomDependency.java
Normal file
16
src/org/atriasoft/island/model/maven/PomDependency.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package org.atriasoft.island.model.maven;
|
||||||
|
|
||||||
|
import org.atriasoft.aknot.annotation.AknotDefaultNullValue;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotIgnoreUnknown;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotName;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotOptional;
|
||||||
|
|
||||||
|
@AknotDefaultNullValue
|
||||||
|
@AknotIgnoreUnknown
|
||||||
|
public record PomDependency(
|
||||||
|
@AknotName("groupId") String groupId,
|
||||||
|
@AknotName("artifactId") String artifactId,
|
||||||
|
@AknotOptional @AknotName("version") String version,
|
||||||
|
@AknotOptional @AknotName("scope") String scope) {
|
||||||
|
|
||||||
|
}
|
22
src/org/atriasoft/island/model/maven/PomMaven.java
Normal file
22
src/org/atriasoft/island/model/maven/PomMaven.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package org.atriasoft.island.model.maven;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.aknot.annotation.AknotDefaultNullValue;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotIgnoreUnknown;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotList;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotName;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotOptional;
|
||||||
|
|
||||||
|
@AknotDefaultNullValue
|
||||||
|
@AknotIgnoreUnknown
|
||||||
|
@AknotName("project")
|
||||||
|
public record PomMaven(
|
||||||
|
@AknotName("modelVersion") String modelVersion,
|
||||||
|
@AknotName("groupId") String groupId,
|
||||||
|
@AknotName("artifactId") String artifactId,
|
||||||
|
@AknotName("version") String version,
|
||||||
|
@AknotOptional @AknotName("name") String name,
|
||||||
|
@AknotOptional @AknotName("description") String description,
|
||||||
|
@AknotOptional @AknotName("url") String url,
|
||||||
|
@AknotOptional @AknotName("dependencies") @AknotList(value = "dependency") List<PomDependency> dependencies) {}
|
14
src/org/atriasoft/island/model/maven/Versioning.java
Normal file
14
src/org/atriasoft/island/model/maven/Versioning.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package org.atriasoft.island.model.maven;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.aknot.annotation.AknotList;
|
||||||
|
import org.atriasoft.aknot.annotation.AknotName;
|
||||||
|
|
||||||
|
public record Versioning(
|
||||||
|
@AknotName("latest") String latest,
|
||||||
|
@AknotName("release") String release,
|
||||||
|
@AknotName("lastUpdated") String lastUpdated,
|
||||||
|
@AknotName("versions") @AknotList(value = "version") List<String> versions) {
|
||||||
|
|
||||||
|
}
|
@ -1,140 +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)
|
|
||||||
//#
|
|
||||||
|
|
||||||
// Local import
|
|
||||||
from realog import debug
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
from . import env
|
|
||||||
import death.Arguments as arguments
|
|
||||||
|
|
||||||
list_actions = []
|
|
||||||
|
|
||||||
__base_action_name = env.get_system_base_name() + "Action_"
|
|
||||||
|
|
||||||
public void init(files):
|
|
||||||
global list_actions;
|
|
||||||
debug.verbose("List of action for island: " + str(len(files)))
|
|
||||||
for elem_path in files :
|
|
||||||
debug.verbose("parse file : " + elem_path)
|
|
||||||
base_name = os.path.basename(elem_path)
|
|
||||||
if len(base_name) <= 3 + len(__base_action_name):
|
|
||||||
// reject it, too small
|
|
||||||
continue
|
|
||||||
base_name = base_name[:-3]
|
|
||||||
if base_name[:len(__base_action_name)] != __base_action_name:
|
|
||||||
// reject it, wrong start file
|
|
||||||
continue
|
|
||||||
name_action = base_name[len(__base_action_name):]
|
|
||||||
debug.debug(" '" + os.path.basename(elem_path)[:-3] + "' file=" + elem_path)
|
|
||||||
list_actions.append({
|
|
||||||
"name":name_action,
|
|
||||||
"path":elem_path,
|
|
||||||
})
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @brief Get the wall list of action availlable
|
|
||||||
//# @return ([string]) the list of action name
|
|
||||||
//#
|
|
||||||
public void get_list_of_action():
|
|
||||||
global list_actions;
|
|
||||||
out = []
|
|
||||||
for elem in list_actions:
|
|
||||||
out.append(elem["name"])
|
|
||||||
return out
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @brief Get a description of an action
|
|
||||||
//# @param[in] action_name (string) Name of the action
|
|
||||||
//# @param[in] function_name (string) Name of the fucntion to call
|
|
||||||
//# @param[in] default_value (*) Renurned value of the call if function does not exist
|
|
||||||
//# @return (*) the getted value or the default_value
|
|
||||||
//#
|
|
||||||
public void get_function_value(action_name, function_name, default_value = None):
|
|
||||||
global list_actions;
|
|
||||||
for elem in list_actions:
|
|
||||||
if elem["name"] == action_name:
|
|
||||||
// finish the parsing
|
|
||||||
sys.path.append(os.path.dirname(elem["path"]))
|
|
||||||
the_action = __import__(__base_action_name + action_name)
|
|
||||||
if function_name not in dir(the_action):
|
|
||||||
return default_value
|
|
||||||
method_to_call = getattr(the_action, function_name)
|
|
||||||
return method_to_call()
|
|
||||||
return default_value
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @brief Get the global help value of a module
|
|
||||||
//# @param[in] action_name (string) Name of the action
|
|
||||||
//# @return The first line of description
|
|
||||||
//#
|
|
||||||
public void get_action_help(action_name):
|
|
||||||
value = get_function_value(action_name, "help", "---")
|
|
||||||
return value.split("\n")[0]
|
|
||||||
|
|
||||||
|
|
||||||
public void usage(arguments, action_name):
|
|
||||||
color = debug.get_color_set()
|
|
||||||
// generic argument displayed for specific action:
|
|
||||||
//print("Specific argument for the command: '" + action_name + "'" )
|
|
||||||
//print(" " + get_desc(action_name))
|
|
||||||
value = get_function_value(action_name, "help")
|
|
||||||
debug.info("Description:")
|
|
||||||
debug.info("\t" + str(value))
|
|
||||||
arguments.display(action_name)
|
|
||||||
value = get_function_value(action_name, "help_example")
|
|
||||||
if value != None:
|
|
||||||
debug.info("Example:")
|
|
||||||
for elem in value.split("\n"):
|
|
||||||
debug.info("\t" + value)
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
public void execute(action_name, argument_start_id):
|
|
||||||
global list_actions;
|
|
||||||
// TODO: Move here the check if action is availlable
|
|
||||||
|
|
||||||
for elem in list_actions:
|
|
||||||
if elem["name"] != action_name:
|
|
||||||
continue
|
|
||||||
debug.info("action: " + str(elem));
|
|
||||||
// finish the parsing
|
|
||||||
sys.path.append(os.path.dirname(elem["path"]))
|
|
||||||
the_action = __import__(__base_action_name + action_name)
|
|
||||||
my_under_args_parser = arguments.Arguments()
|
|
||||||
my_under_args_parser.add("h", "help", desc="Help of this action")
|
|
||||||
|
|
||||||
if "add_specific_arguments" in dir(the_action):
|
|
||||||
the_action.add_specific_arguments(my_under_args_parser, elem["name"])
|
|
||||||
have_unknow_argument = false
|
|
||||||
if "have_unknow_argument" in dir(the_action):
|
|
||||||
have_unknow_argument = the_action.have_unknow_argument()
|
|
||||||
my_under_args = my_under_args_parser.parse(argument_start_id, have_unknow_argument)
|
|
||||||
// search help if needed ==> permit to not duplicating code
|
|
||||||
for elem in my_under_args:
|
|
||||||
if elem.get_option_name() == "help":
|
|
||||||
usage(my_under_args_parser, action_name)
|
|
||||||
return 0
|
|
||||||
// now we can execute:
|
|
||||||
if "execute" not in dir(the_action):
|
|
||||||
debug.error("execute is not implmented for this action ... '" + str(action_name) + "'")
|
|
||||||
return -11
|
|
||||||
debug.info("execute: " + action_name)
|
|
||||||
for elem in my_under_args:
|
|
||||||
debug.debug(" " + str(elem.get_option_name()) + "='" + str(elem.get_arg()) + "'")
|
|
||||||
ret = the_action.execute(my_under_args)
|
|
||||||
if ret == None:
|
|
||||||
return 0
|
|
||||||
if ret < 0:
|
|
||||||
debug.info(" ==========================")
|
|
||||||
debug.info(" == Some error occured ==")
|
|
||||||
debug.info(" ==========================")
|
|
||||||
return ret
|
|
||||||
debug.error("Can not do the action...")
|
|
||||||
return -10
|
|
@ -1,88 +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 debug
|
|
||||||
from island import tools
|
|
||||||
from island import env
|
|
||||||
from island import config
|
|
||||||
from island import multiprocess
|
|
||||||
from island import manifest
|
|
||||||
from island import commands
|
|
||||||
import 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 "Ckeckout a specific branch in all repository"
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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_arg("branch", optionnal=false, desc="Branch to checkout (if '__TAG__' ==> checkout specific repository tags)")
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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 = ""
|
|
||||||
branch_to_checkout = ""
|
|
||||||
for elem in _arguments:
|
|
||||||
if elem.get_option_name() == "remote":
|
|
||||||
debug.info("find remote name: '" + elem.get_arg() + "'")
|
|
||||||
argument_remote_name = elem.get_arg()
|
|
||||||
elif elem.get_option_name() == "branch":
|
|
||||||
branch_to_checkout = elem.get_arg()
|
|
||||||
else:
|
|
||||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
|
||||||
|
|
||||||
// check system is OK
|
|
||||||
manifest.check_lutin_is_init()
|
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
|
||||||
|
|
||||||
// update the local configuration file:
|
|
||||||
configuration.set_branch(branch_to_checkout)
|
|
||||||
configuration.store()
|
|
||||||
|
|
||||||
file_source_manifest = new Path(env.get_island_path_manifest(), configuration.get_manifest_name())
|
|
||||||
if os.path.exists(file_source_manifest) == false:
|
|
||||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
|
||||||
|
|
||||||
mani = manifest.Manifest(file_source_manifest)
|
|
||||||
|
|
||||||
all_project = mani.get_all_configs()
|
|
||||||
debug.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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
|||||||
//# @license MPL v2.0 (see license file)
|
//# @license MPL v2.0 (see license file)
|
||||||
//#
|
//#
|
||||||
|
|
||||||
from realog import debug
|
from realog import Log
|
||||||
from island import tools
|
from island import tools
|
||||||
from island import env
|
from island import env
|
||||||
from island import multiprocess
|
from island import multiprocess
|
||||||
@ -44,40 +44,40 @@ public void have_unknow_argument():
|
|||||||
public void execute(_arguments):
|
public void execute(_arguments):
|
||||||
cmd = ""
|
cmd = ""
|
||||||
for elem in _arguments:
|
for elem in _arguments:
|
||||||
debug.info("Get data element: " + str(elem.get_arg()))
|
LOGGER.info("Get data element: " + str(elem.getArg()))
|
||||||
cmd += elem.get_arg() + " "
|
cmd += elem.getArg() + " "
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
file_source_manifest = new Path(env.get_island_path_manifest(), configuration.get_manifest_name())
|
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||||
if os.path.exists(file_source_manifest) == false:
|
if os.path.exists(file_source_manifest) == false:
|
||||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
LOGGER.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||||
|
|
||||||
mani = manifest.Manifest(file_source_manifest)
|
mani = manifest.Manifest(file_source_manifest)
|
||||||
|
|
||||||
all_project = mani.get_all_configs()
|
all_project = mani.get_all_configs()
|
||||||
debug.info("status of: " + str(len(all_project)) + " projects")
|
LOGGER.info("status of: " + str(len(all_project)) + " projects")
|
||||||
id_element = 0
|
id_element = 0
|
||||||
for elem in all_project:
|
for elem in all_project:
|
||||||
debug.info("------------------------------------------")
|
LOGGER.info("------------------------------------------")
|
||||||
id_element += 1
|
id_element += 1
|
||||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||||
debug.info("execute command : " + base_display)
|
LOGGER.info("execute command : " + base_display)
|
||||||
tools.wait_for_server_if_needed()
|
tools.wait_for_server_if_needed()
|
||||||
//debug.debug("elem : " + str(elem))
|
//LOGGER.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:
|
if os.path.exists(git_repo_path) == false:
|
||||||
debug.info("" + base_display + "\r\t\t\t\t\t\t\t\t\t" + " (not download)")
|
LOGGER.info("" + base_display + "\r\t\t\t\t\t\t\t\t\t" + " (not download)")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
debug.verbose("execute : " + cmd)
|
LOGGER.trace("execute : " + cmd)
|
||||||
ret = multiprocess.run_command(cmd, cwd=git_repo_path)
|
ret = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||||
if ret[0] == 0:
|
if ret[0] == 0:
|
||||||
debug.info("ret=" + ret[1])
|
LOGGER.info("ret=" + ret[1])
|
||||||
debug.info("err=" + ret[2])
|
LOGGER.info("err=" + ret[2])
|
||||||
else:
|
else:
|
||||||
debug.info("Execution ERROR")
|
LOGGER.info("Execution ERROR")
|
||||||
|
|
@ -1,95 +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 debug
|
|
||||||
from island import tools
|
|
||||||
from island import env
|
|
||||||
from island import config
|
|
||||||
from island import multiprocess
|
|
||||||
from island import manifest
|
|
||||||
from island import commands
|
|
||||||
import 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 "Commit in all repository"
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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("m", "message", haveParam=true, desc="Message to commit data")
|
|
||||||
my_args.add("a", "all", desc="Commit all elements")
|
|
||||||
my_args.add("", "amend", desc="Ammend data at the previous commit")
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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_message = ""
|
|
||||||
argument_amend = ""
|
|
||||||
argument_all = ""
|
|
||||||
for elem in _arguments:
|
|
||||||
if elem.get_option_name() == "message":
|
|
||||||
debug.info("find message: '" + elem.get_arg() + "'")
|
|
||||||
argument_message = " --message \"" + elem.get_arg() + "\" ";
|
|
||||||
elif elem.get_option_name() == "all":
|
|
||||||
argument_all = " --all "
|
|
||||||
elif elem.get_option_name() == "amend":
|
|
||||||
argument_amend = " --amend "
|
|
||||||
else:
|
|
||||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
|
||||||
|
|
||||||
// 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:
|
|
||||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
|
||||||
mani = manifest.Manifest(file_source_manifest)
|
|
||||||
|
|
||||||
all_project = mani.get_all_configs()
|
|
||||||
debug.info("commit : " + str(len(all_project)) + " projects")
|
|
||||||
id_element = 0
|
|
||||||
for elem in all_project:
|
|
||||||
id_element += 1
|
|
||||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
|
||||||
debug.info("commit: " + base_display)
|
|
||||||
git_repo_path = new Path(env.get_island_root_path(), elem.path)
|
|
||||||
if os.path.exists(git_repo_path) == false:
|
|
||||||
debug.error("can not commit project that not exist")
|
|
||||||
continue
|
|
||||||
|
|
||||||
if os.path.exists(new Path(git_repo_path,".git")) == false:
|
|
||||||
// path already exist but it is not used to as a git repo ==> this is an error
|
|
||||||
debug.warning("path '" + git_repo_path + "' is already existing but not used for a git repository. Clean it and restart")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// simply update the repository ...
|
|
||||||
debug.verbose("commit in project:")
|
|
||||||
// fetch the repository
|
|
||||||
cmd = "git commit " + argument_amend + argument_all + argument_message
|
|
||||||
debug.debug("execute : " + cmd)
|
|
||||||
multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
|||||||
//# @license MPL v2.0 (see license file)
|
//# @license MPL v2.0 (see license file)
|
||||||
//#
|
//#
|
||||||
|
|
||||||
from realog import debug
|
from realog import Log
|
||||||
from island import tools
|
from island import tools
|
||||||
from island import env
|
from island import env
|
||||||
from island import config
|
from island import config
|
||||||
@ -45,35 +45,35 @@ public void add_specific_arguments(my_args, section):
|
|||||||
public void execute(_arguments):
|
public void execute(_arguments):
|
||||||
argument_remote_name = ""
|
argument_remote_name = ""
|
||||||
for elem in _arguments:
|
for elem in _arguments:
|
||||||
if elem.get_option_name() == "remote":
|
if elem.getOptionName().equals("remote":
|
||||||
debug.info("find remote name: '" + elem.get_arg() + "'")
|
LOGGER.info("find remote name: '" + elem.getArg() + "'")
|
||||||
argument_remote_name = elem.get_arg()
|
argument_remote_name = elem.getArg()
|
||||||
else:
|
else:
|
||||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
LOGGER.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
file_source_manifest = new Path(env.get_island_path_manifest(), configuration.get_manifest_name())
|
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||||
if os.path.exists(file_source_manifest) == false:
|
if os.path.exists(file_source_manifest) == false:
|
||||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
LOGGER.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||||
mani = manifest.Manifest(file_source_manifest)
|
mani = manifest.Manifest(file_source_manifest)
|
||||||
|
|
||||||
destination_branch = mani.deliver_master
|
destination_branch = mani.deliver_master
|
||||||
source_branch = mani.deliver_develop
|
source_branch = mani.deliver_develop
|
||||||
|
|
||||||
all_project = mani.get_all_configs()
|
all_project = mani.get_all_configs()
|
||||||
debug.info("fetch : " + str(len(all_project)) + " projects")
|
LOGGER.info("fetch : " + str(len(all_project)) + " projects")
|
||||||
id_element = 0
|
id_element = 0
|
||||||
for elem in all_project:
|
for elem in all_project:
|
||||||
id_element += 1
|
id_element += 1
|
||||||
// configure remote name:
|
// configure remote name:
|
||||||
if argument_remote_name == "":
|
if argument_remote_name.equals("":
|
||||||
argument_remote_name = elem.select_remote["name"]
|
argument_remote_name = elem.select_remote["name"]
|
||||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||||
debug.info("deliver-push: " + base_display)
|
LOGGER.info("deliver-push: " + base_display)
|
||||||
tools.wait_for_server_if_needed()
|
tools.wait_for_server_if_needed()
|
||||||
status.deliver_push(elem, argument_remote_name, destination_branch, source_branch, base_display)
|
status.deliver_push(elem, argument_remote_name, destination_branch, source_branch, base_display)
|
||||||
|
|
||||||
|
@ -1,138 +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 debug
|
|
||||||
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 "Deliver the current repository (develop & master MUST be up to date and you MUST be on master)"
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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("f", "from", haveParam=true, desc="source branche to deliver")
|
|
||||||
_my_args.add("t", "to", haveParam=true, desc="desticantion branche of the deliver")
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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_from = None
|
|
||||||
argument_to = None
|
|
||||||
for elem in _arguments:
|
|
||||||
if elem.get_option_name() == "from":
|
|
||||||
debug.info("find source branch name: '" + elem.get_arg() + "'")
|
|
||||||
argument_from = elem.get_arg()
|
|
||||||
elif elem.get_option_name() == "to":
|
|
||||||
debug.info("find destination branch name: '" + elem.get_arg() + "'")
|
|
||||||
argument_to = elem.get_arg()
|
|
||||||
else:
|
|
||||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
|
||||||
|
|
||||||
// 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:
|
|
||||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
|
||||||
|
|
||||||
mani = manifest.Manifest(file_source_manifest)
|
|
||||||
|
|
||||||
destination_branch = mani.deliver_master
|
|
||||||
source_branch = mani.deliver_develop
|
|
||||||
if argument_from != None:
|
|
||||||
source_branch = argument_from
|
|
||||||
if argument_to != None:
|
|
||||||
destination_branch = argument_to
|
|
||||||
|
|
||||||
all_project = mani.get_all_configs()
|
|
||||||
debug.info("Check if all project are on master: " + str(len(all_project)) + " projects")
|
|
||||||
id_element = 0
|
|
||||||
deliver_availlable = true
|
|
||||||
for elem in all_project:
|
|
||||||
id_element += 1
|
|
||||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
|
||||||
debug.verbose("deliver-ckeck: " + base_display)
|
|
||||||
if status.deliver_check(elem, argument_remote_name, id_element, base_display, source_branch, destination_branch) == false:
|
|
||||||
deliver_availlable = false
|
|
||||||
if deliver_availlable == false:
|
|
||||||
debug.error("deliver-ckeck: Correct the warning to validate the Merge")
|
|
||||||
return
|
|
||||||
debug.info("deliver-ckeck: ==> All is OK")
|
|
||||||
id_element = 0
|
|
||||||
for elem in all_project:
|
|
||||||
id_element += 1
|
|
||||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
|
||||||
debug.info("deliver: ========================================================================")
|
|
||||||
debug.info("deliver: == " + base_display)
|
|
||||||
debug.info("deliver: ========================================================================")
|
|
||||||
|
|
||||||
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:
|
|
||||||
continue
|
|
||||||
debug.info("deliver: ==> version: " + str(version_description))
|
|
||||||
|
|
||||||
// go to the dev branch
|
|
||||||
select_branch = commands.get_current_branch(git_repo_path)
|
|
||||||
|
|
||||||
// Checkout destination branch:
|
|
||||||
commands.checkout(git_repo_path, destination_branch)
|
|
||||||
|
|
||||||
// create new repo tag
|
|
||||||
new_version_description = status.create_new_version_repo(git_repo_path, version_description, add_in_version_management, source_branch, destination_branch)
|
|
||||||
debug.info("new version: " + str(new_version_description))
|
|
||||||
if new_version_description == None:
|
|
||||||
continue
|
|
||||||
// merge branch
|
|
||||||
if mani.deliver_mode == "merge":
|
|
||||||
merge_force = true
|
|
||||||
else:
|
|
||||||
merge_force = false
|
|
||||||
commands.merge_branch_on_master(git_repo_path, source_branch, merge_force, branch_destination=destination_branch)
|
|
||||||
|
|
||||||
version_path_file = new Path(git_repo_path, "version.txt")
|
|
||||||
// update version file:
|
|
||||||
tools.file_write_data(version_path_file, tools.version_to_string(new_version_description))
|
|
||||||
commands.add_file(git_repo_path, version_path_file)
|
|
||||||
commands.commit_all(git_repo_path, "[RELEASE] Release v" + tools.version_to_string(new_version_description))
|
|
||||||
commands.tag(git_repo_path, "v" + tools.version_to_string(new_version_description))
|
|
||||||
commands.checkout(git_repo_path, source_branch)
|
|
||||||
commands.reset_hard(git_repo_path, destination_branch)
|
|
||||||
new_version_description.append("dev")
|
|
||||||
tools.file_write_data(version_path_file, tools.version_to_string(new_version_description))
|
|
||||||
commands.add_file(git_repo_path, version_path_file)
|
|
||||||
commands.commit_all(git_repo_path, status.default_update_message)
|
|
||||||
commands.checkout(git_repo_path, destination_branch)
|
|
||||||
|
|
@ -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 debug
|
|
||||||
from island import tools
|
|
||||||
from island import env
|
|
||||||
from island import config
|
|
||||||
from island import multiprocess
|
|
||||||
from island import manifest
|
|
||||||
from island import commands
|
|
||||||
import 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 "Fecth all the repository (get all modification on the server)"
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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")
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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 = ""
|
|
||||||
for elem in _arguments:
|
|
||||||
if elem.get_option_name() == "remote":
|
|
||||||
debug.info("find remote name: '" + elem.get_arg() + "'")
|
|
||||||
argument_remote_name = elem.get_arg()
|
|
||||||
else:
|
|
||||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
|
||||||
|
|
||||||
// check system is OK
|
|
||||||
manifest.check_lutin_is_init()
|
|
||||||
|
|
||||||
debug.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())
|
|
||||||
if os.path.exists(file_source_manifest) == false:
|
|
||||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
|
||||||
mani = manifest.Manifest(file_source_manifest)
|
|
||||||
|
|
||||||
all_project = mani.get_all_configs()
|
|
||||||
debug.info("fetch : " + str(len(all_project)) + " projects")
|
|
||||||
id_element = 0
|
|
||||||
for elem in all_project:
|
|
||||||
id_element += 1
|
|
||||||
// configure remote name:
|
|
||||||
if argument_remote_name == "":
|
|
||||||
argument_remote_name = elem.select_remote["name"]
|
|
||||||
|
|
||||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
|
||||||
debug.info("fetch: " + base_display)
|
|
||||||
tools.wait_for_server_if_needed()
|
|
||||||
//debug.debug("elem : " + str(elem))
|
|
||||||
git_repo_path = new Path(env.get_island_root_path(), elem.path)
|
|
||||||
if os.path.exists(git_repo_path) == false:
|
|
||||||
debug.error("can not fetch project that not exist")
|
|
||||||
continue
|
|
||||||
|
|
||||||
if os.path.exists(new Path(git_repo_path,".git")) == false:
|
|
||||||
// path already exist but it is not used to as a git repo ==> this is an error
|
|
||||||
debug.error("path '" + git_repo_path + "' is already existing but not used for a git repository. Clean it and restart")
|
|
||||||
|
|
||||||
// simply update the repository ...
|
|
||||||
debug.verbose("Fetching project: ")
|
|
||||||
|
|
||||||
commands.fetch(git_repo_path, argument_remote_name)
|
|
||||||
|
|
@ -1,100 +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 debug
|
|
||||||
from island import tools
|
|
||||||
from island import env
|
|
||||||
from island import config
|
|
||||||
from island import commands
|
|
||||||
from island import multiprocess
|
|
||||||
from island import manifest
|
|
||||||
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 "Init a island repository (need 'fetch' after)"
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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("b", "branch", haveParam=true, desc="Select branch to display")
|
|
||||||
my_args.add("m", "manifest", haveParam=true, desc="Name of the manifest")
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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):
|
|
||||||
if len(_arguments) == 0:
|
|
||||||
debug.error("Missing argument to execute the current action ...")
|
|
||||||
|
|
||||||
// the configuration availlable:
|
|
||||||
branch = "master"
|
|
||||||
manifest_name = "default.xml"
|
|
||||||
address_manifest = ""
|
|
||||||
for elem in _arguments:
|
|
||||||
if elem.get_option_name() == "branch":
|
|
||||||
debug.info("find branch name: '" + elem.get_arg() + "'")
|
|
||||||
branch = elem.get_arg()
|
|
||||||
elif elem.get_option_name() == "manifest":
|
|
||||||
debug.info("find mmanifest name: '" + elem.get_arg() + "'")
|
|
||||||
manifest_name = elem.get_arg()
|
|
||||||
elif elem.get_option_name() == "":
|
|
||||||
if address_manifest != "":
|
|
||||||
debug.error("Manifest adress already set : '" + address_manifest + "' !!! '" + elem.get_arg() + "'")
|
|
||||||
address_manifest = elem.get_arg()
|
|
||||||
else:
|
|
||||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
|
||||||
|
|
||||||
if address_manifest == "":
|
|
||||||
debug.error("Init: Missing manifest name")
|
|
||||||
|
|
||||||
debug.info("Init with: '" + address_manifest + "' branch='" + branch + "' name of manifest='" + manifest_name + "'")
|
|
||||||
|
|
||||||
|
|
||||||
// check if .XXX exist (create it if needed)
|
|
||||||
if manifest.is_lutin_init() == true:
|
|
||||||
debug.error("System already init: path already exist: '" + str(env.get_island_path()) + "'")
|
|
||||||
|
|
||||||
tools.create_directory(env.get_island_path())
|
|
||||||
// check if the git of the manifest if availlable
|
|
||||||
|
|
||||||
// create the file configuration:
|
|
||||||
conf = config.get_unique_config()
|
|
||||||
conf.set_manifest(address_manifest)
|
|
||||||
conf.set_branch(branch)
|
|
||||||
conf.set_manifest_name(manifest_name)
|
|
||||||
conf.store()
|
|
||||||
|
|
||||||
debug.info("Clone the manifest")
|
|
||||||
ret_values = commands.clone(env.get_island_path_manifest(), address_manifest, branch_name=branch)
|
|
||||||
|
|
||||||
if ret_values == false:
|
|
||||||
debug.info("'" + str(ret_values) + "'")
|
|
||||||
debug.error("Init does not work")
|
|
||||||
return false
|
|
||||||
|
|
||||||
debug.info("Init done correctly ...")
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,72 +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 debug
|
|
||||||
from island import tools
|
|
||||||
from island import env
|
|
||||||
from island import config
|
|
||||||
from island import multiprocess
|
|
||||||
from island import manifest
|
|
||||||
from island import commands
|
|
||||||
import 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 "Manifest Ckeckout a specific branch of repository"
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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_arg("branch", optionnal=false, desc="Branch to checkout (if '__TAG__' ==> checkout specific repository tags)")
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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 = ""
|
|
||||||
branch_to_checkout = ""
|
|
||||||
for elem in _arguments:
|
|
||||||
if elem.get_option_name() == "remote":
|
|
||||||
debug.info("find remote name: '" + elem.get_arg() + "'")
|
|
||||||
argument_remote_name = elem.get_arg()
|
|
||||||
elif elem.get_option_name() == "branch":
|
|
||||||
branch_to_checkout = elem.get_arg()
|
|
||||||
else:
|
|
||||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
|
||||||
|
|
||||||
// check system is OK
|
|
||||||
manifest.check_lutin_is_init()
|
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
|||||||
//# @license MPL v2.0 (see license file)
|
//# @license MPL v2.0 (see license file)
|
||||||
//#
|
//#
|
||||||
|
|
||||||
from realog import debug
|
from realog import Log
|
||||||
from island import tools
|
from island import tools
|
||||||
from island import env
|
from island import env
|
||||||
from island import config
|
from island import config
|
||||||
@ -45,16 +45,16 @@ public void add_specific_arguments(my_args, section):
|
|||||||
//#
|
//#
|
||||||
public void execute(_arguments):
|
public void execute(_arguments):
|
||||||
for elem in _arguments:
|
for elem in _arguments:
|
||||||
debug.error("pull Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
LOGGER.error("pull Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
file_source_manifest = new Path(env.get_island_path_manifest(), configuration.get_manifest_name())
|
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||||
if os.path.exists(file_source_manifest) == false:
|
if os.path.exists(file_source_manifest) == false:
|
||||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
LOGGER.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||||
|
|
||||||
|
|
||||||
elem = configuration.get_manifest_config()
|
elem = configuration.get_manifest_config()
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
//# @license MPL v2.0 (see license file)
|
//# @license MPL v2.0 (see license file)
|
||||||
//#
|
//#
|
||||||
|
|
||||||
from realog import debug
|
from realog import Log
|
||||||
from island import tools
|
from island import tools
|
||||||
from island import env
|
from island import env
|
||||||
from island import config
|
from island import config
|
||||||
@ -49,16 +49,16 @@ public void add_specific_arguments(my_args, section):
|
|||||||
public void execute(_arguments):
|
public void execute(_arguments):
|
||||||
argument_remote_name = ""
|
argument_remote_name = ""
|
||||||
for elem in _arguments:
|
for elem in _arguments:
|
||||||
debug.error("pull Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
LOGGER.error("pull Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
file_source_manifest = new Path(env.get_island_path_manifest(), configuration.get_manifest_name())
|
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||||
if os.path.exists(file_source_manifest) == false:
|
if os.path.exists(file_source_manifest) == false:
|
||||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
LOGGER.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||||
|
|
||||||
elem = configuration.get_manifest_config()
|
elem = configuration.get_manifest_config()
|
||||||
|
|
||||||
@ -69,31 +69,31 @@ public void execute(_arguments):
|
|||||||
|
|
||||||
// Check the manifest is up to date ...
|
// Check the manifest is up to date ...
|
||||||
base_display = tools.get_list_base_display(0, 0, elem)
|
base_display = tools.get_list_base_display(0, 0, elem)
|
||||||
debug.verbose("deliver-ckeck: " + base_display)
|
LOGGER.trace("deliver-ckeck: " + base_display)
|
||||||
if status.deliver_check(elem, argument_remote_name, 0, base_display, source_branch, destination_branch) == false:
|
if status.deliver_check(elem, argument_remote_name, 0, base_display, source_branch, destination_branch) == false:
|
||||||
debug.error("Can not deliver a MANIFEST that is not ready to merge", crash=false)
|
LOGGER.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)
|
all_tags = check_all_tags(mani)
|
||||||
if all_tags == None:
|
if all_tags == None:
|
||||||
debug.error("Need the Tags are set in sub-repository", crash=false)
|
LOGGER.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 ...)
|
// deliver the manifest (if Needed ...)
|
||||||
base_display = tools.get_list_base_display(0, 0, elem)
|
base_display = tools.get_list_base_display(0, 0, elem)
|
||||||
|
|
||||||
debug.info("manifest-deliver: ========================================================================")
|
LOGGER.info("manifest-deliver: ========================================================================")
|
||||||
debug.info("manifest-deliver: == " + base_display)
|
LOGGER.info("manifest-deliver:.equals(" + base_display)
|
||||||
debug.info("manifest-deliver: ========================================================================")
|
LOGGER.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,
|
// Check the validity of the version,
|
||||||
version_description, add_in_version_management = status.get_current_version_repo(git_repo_path)
|
version_description, add_in_version_management = status.get_current_version_repo(git_repo_path)
|
||||||
if version_description == None:
|
if version_description == None:
|
||||||
return env.ret_action_fail
|
return Env.ret_action_fail
|
||||||
debug.info("manifest-deliver: ==> version: " + str(version_description))
|
LOGGER.info("manifest-deliver: ==> version: " + str(version_description))
|
||||||
|
|
||||||
// go to the dev branch
|
// go to the dev branch
|
||||||
select_branch = commands.get_current_branch(git_repo_path)
|
select_branch = commands.get_current_branch(git_repo_path)
|
||||||
@ -101,12 +101,12 @@ public void execute(_arguments):
|
|||||||
|
|
||||||
// create new repo tag
|
// create new repo tag
|
||||||
new_version_description = status.create_new_version_repo(git_repo_path, version_description, add_in_version_management, source_branch, destination_branch)
|
new_version_description = status.create_new_version_repo(git_repo_path, version_description, add_in_version_management, source_branch, destination_branch)
|
||||||
debug.info("new version: " + str(new_version_description))
|
LOGGER.info("new version: " + str(new_version_description))
|
||||||
if new_version_description == None:
|
if new_version_description == None:
|
||||||
return
|
return
|
||||||
// merge branch
|
// merge branch
|
||||||
commands.checkout(git_repo_path, destination_branch)
|
commands.checkout(git_repo_path, destination_branch)
|
||||||
if mani.deliver_mode == "merge":
|
if mani.deliver_mode.equals("merge":
|
||||||
merge_force = true
|
merge_force = true
|
||||||
else:
|
else:
|
||||||
merge_force = false
|
merge_force = false
|
||||||
@ -130,13 +130,13 @@ public void execute(_arguments):
|
|||||||
commands.checkout(git_repo_path, destination_branch)
|
commands.checkout(git_repo_path, destination_branch)
|
||||||
|
|
||||||
|
|
||||||
debug.info("manifest-deliver: ==> DONE")
|
LOGGER.info("manifest-deliver: ==> DONE")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void check_all_tags(mani):
|
public void check_all_tags(mani):
|
||||||
all_project = mani.get_all_configs()
|
all_project = mani.get_all_configs()
|
||||||
debug.info("Check all: " + str(len(all_project)) + " projects have a current tag ...")
|
LOGGER.info("Check all: " + str(len(all_project)) + " projects have a current tag ...")
|
||||||
id_element = 0
|
id_element = 0
|
||||||
check_have_error = false
|
check_have_error = false
|
||||||
list_tags = []
|
list_tags = []
|
||||||
@ -144,16 +144,16 @@ public void check_all_tags(mani):
|
|||||||
id_element += 1
|
id_element += 1
|
||||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||||
if elem.volatile == true:
|
if elem.volatile == true:
|
||||||
debug.info(base_display + "\r\t\t\t\t\t\t\t\t\t" + " (Not Managed)")
|
LOGGER.info(base_display + "\r\t\t\t\t\t\t\t\t\t" + " (Not Managed)")
|
||||||
continue
|
continue
|
||||||
tags_comment = ""
|
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:
|
if os.path.exists(git_repo_path) == false:
|
||||||
debug.error(base_display + volatile + "\r\t\t\t\t\t\t\t\t\t" + " (not download)", crash=false)
|
LOGGER.error(base_display + volatile + "\r\t\t\t\t\t\t\t\t\t" + " (not download)", crash=false)
|
||||||
check_have_error = true
|
check_have_error = true
|
||||||
continue
|
continue
|
||||||
ret_current_tags = commands.get_tags_current(git_repo_path)
|
ret_current_tags = commands.get_tags_current(git_repo_path)
|
||||||
debug.verbose("tags found: " + str(ret_current_tags))
|
LOGGER.trace("tags found: " + str(ret_current_tags))
|
||||||
if len(ret_current_tags) == 0:
|
if len(ret_current_tags) == 0:
|
||||||
list_tags.append({
|
list_tags.append({
|
||||||
"name":elem.name,
|
"name":elem.name,
|
||||||
@ -169,11 +169,11 @@ public void check_all_tags(mani):
|
|||||||
tags_comment += ","
|
tags_comment += ","
|
||||||
tags_comment += elem_tag
|
tags_comment += elem_tag
|
||||||
if len(ret_current_tags) == 0:
|
if len(ret_current_tags) == 0:
|
||||||
debug.error(base_display + "\r\t\t\t\t\t\t\t\t\t" + " (NO TAG DETECTED)", crash=false)
|
LOGGER.error(base_display + "\r\t\t\t\t\t\t\t\t\t" + " (NO TAG DETECTED)", crash=false)
|
||||||
check_have_error = true
|
check_have_error = true
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
debug.info(base_display + "\r\t\t\t\t\t\t\t\t\t" + " " + tags_comment)
|
LOGGER.info(base_display + "\r\t\t\t\t\t\t\t\t\t" + " " + tags_comment)
|
||||||
if check_have_error == true:
|
if check_have_error == true:
|
||||||
return None
|
return None
|
||||||
return list_tags
|
return list_tags
|
||||||
|
@ -1,63 +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 debug
|
|
||||||
from island import tools
|
|
||||||
from island import env
|
|
||||||
from island import config
|
|
||||||
from island import multiprocess
|
|
||||||
from island import manifest
|
|
||||||
from island import commands
|
|
||||||
import 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 "Display status spécifically of the manifest"
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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("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.get_option_name() == "tags":
|
|
||||||
argument_display_tag = true
|
|
||||||
else:
|
|
||||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
|
||||||
|
|
||||||
// check system is OK
|
|
||||||
manifest.check_lutin_is_init()
|
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
|
||||||
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
|
|
@ -8,7 +8,7 @@
|
|||||||
//# @license MPL v2.0 (see license file)
|
//# @license MPL v2.0 (see license file)
|
||||||
//#
|
//#
|
||||||
|
|
||||||
from realog import debug
|
from realog import Log
|
||||||
from island import tools
|
from island import tools
|
||||||
from island import env
|
from island import env
|
||||||
from island import config
|
from island import config
|
||||||
@ -44,17 +44,17 @@ public void add_specific_arguments(my_args, section):
|
|||||||
//#
|
//#
|
||||||
public void execute(_arguments):
|
public void execute(_arguments):
|
||||||
for elem in _arguments:
|
for elem in _arguments:
|
||||||
debug.error("pull Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
LOGGER.error("pull Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
debug.info("update manifest : '" + str(env.get_island_path_manifest()) + "'")
|
LOGGER.info("update manifest : '" + str(Env.get_island_path_manifest()) + "'")
|
||||||
is_modify_manifest = commands.check_repository_is_modify(env.get_island_path_manifest())
|
is_modify_manifest = commands.check_repository_is_modify(Env.get_island_path_manifest())
|
||||||
if is_modify_manifest == true:
|
if is_modify_manifest == true:
|
||||||
commands.fetch(env.get_island_path_manifest(), "origin")
|
commands.fetch(Env.get_island_path_manifest(), "origin")
|
||||||
else:
|
else:
|
||||||
commands.pull(env.get_island_path_manifest(), "origin")
|
commands.pull(Env.get_island_path_manifest(), "origin")
|
||||||
|
|
@ -1,114 +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 debug
|
|
||||||
from island import tools
|
|
||||||
from island import env
|
|
||||||
from island import config
|
|
||||||
from island import multiprocess
|
|
||||||
from island import manifest
|
|
||||||
from island import commands
|
|
||||||
import 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 "Push all repository to the upper server"
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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")
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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 = ""
|
|
||||||
for elem in _arguments:
|
|
||||||
if elem.get_option_name() == "remote":
|
|
||||||
debug.info("find remote name: '" + elem.get_arg() + "'")
|
|
||||||
argument_remote_name = elem.get_arg()
|
|
||||||
else:
|
|
||||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
|
||||||
|
|
||||||
// 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:
|
|
||||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
|
||||||
mani = manifest.Manifest(file_source_manifest)
|
|
||||||
|
|
||||||
all_project = mani.get_all_configs()
|
|
||||||
debug.info("fetch : " + str(len(all_project)) + " projects")
|
|
||||||
id_element = 0
|
|
||||||
for elem in all_project:
|
|
||||||
id_element += 1
|
|
||||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
|
||||||
debug.info("push: " + base_display)
|
|
||||||
tools.wait_for_server_if_needed()
|
|
||||||
//debug.debug("elem : " + str(elem))
|
|
||||||
git_repo_path = new Path(env.get_island_root_path(), elem.path)
|
|
||||||
if os.path.exists(git_repo_path) == false:
|
|
||||||
debug.error("can not push project that not exist")
|
|
||||||
continue
|
|
||||||
|
|
||||||
if os.path.exists(new Path(git_repo_path,".git")) == false:
|
|
||||||
// path already exist but it is not used to as a git repo ==> this is an error
|
|
||||||
debug.error("path '" + git_repo_path + "' exist but not used for a git repository. Clean it and restart")
|
|
||||||
|
|
||||||
// get the current branch:
|
|
||||||
// get local branch
|
|
||||||
cmd = "git branch -a"
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
ret_branch = multiprocess.run_command(cmd, cwd=git_repo_path)
|
|
||||||
list_branch = ret_branch[1].split('\n')
|
|
||||||
list_branch2 = []
|
|
||||||
list_branch3 = []
|
|
||||||
select_branch = ""
|
|
||||||
for elem_branch in list_branch:
|
|
||||||
if len(elem_branch.split(" -> ")) != 1:
|
|
||||||
continue
|
|
||||||
if elem_branch[2:10] == "remotes/":
|
|
||||||
elem_branch = elem_branch[:2] + elem_branch[10:]
|
|
||||||
if elem_branch[:2] == "* ":
|
|
||||||
list_branch2.append([elem_branch[2:], true])
|
|
||||||
select_branch = elem_branch[2:]
|
|
||||||
else:
|
|
||||||
list_branch2.append([elem_branch[2:], false])
|
|
||||||
list_branch3.append(elem_branch[2:])
|
|
||||||
|
|
||||||
// simply update the repository ...
|
|
||||||
debug.verbose("Push project: ")
|
|
||||||
// fetch the repository
|
|
||||||
cmd = "git push"
|
|
||||||
if argument_remote_name != "":
|
|
||||||
cmd += " " + argument_remote_name
|
|
||||||
else:
|
|
||||||
cmd += " " + elem.select_remote["name"]
|
|
||||||
cmd += " " + select_branch + ":" + select_branch
|
|
||||||
debug.info("execute : " + cmd)
|
|
||||||
multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
|
||||||
|
|
@ -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 debug
|
|
||||||
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.get_option_name() == "remote":
|
|
||||||
debug.info("find remote name: '" + elem.get_arg() + "'")
|
|
||||||
argument_remote_name = elem.get_arg()
|
|
||||||
elif elem.get_option_name() == "tags":
|
|
||||||
argument_display_tag = true
|
|
||||||
else:
|
|
||||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
|
||||||
|
|
||||||
// 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:
|
|
||||||
debug.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:
|
|
||||||
debug.info("!!!!!!!!!!!! MANIFEST is modify !!!!!!!!")
|
|
||||||
|
|
||||||
|
|
||||||
all_project = mani.get_all_configs()
|
|
||||||
debug.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
|
|
||||||
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
|||||||
//# @license MPL v2.0 (see license file)
|
//# @license MPL v2.0 (see license file)
|
||||||
//#
|
//#
|
||||||
|
|
||||||
from realog import debug
|
from realog import Log
|
||||||
from island import tools
|
from island import tools
|
||||||
from island import env
|
from island import env
|
||||||
from island import config
|
from island import config
|
||||||
@ -39,116 +39,116 @@ public void add_specific_arguments(my_args, section):
|
|||||||
//#
|
//#
|
||||||
//# @return error value [0 .. 50] the <0 value is reserved system ==> else, what you want.
|
//# @return error value [0 .. 50] the <0 value is reserved system ==> else, what you want.
|
||||||
//# None : No error (return program out 0)
|
//# None : No error (return program out 0)
|
||||||
//# -5 : env.ret_manifest_is_not_existing : Manifest does not exit
|
//# -5 : Env.ret_manifest_is_not_existing : Manifest does not exit
|
||||||
//# -10 : env.ret_action_is_not_existing : ACTION is not existing
|
//# -10 : Env.ret_action_is_not_existing : ACTION is not existing
|
||||||
//# -11 : env.ret_action_executing_system_error : ACTION execution system error
|
//# -11 : Env.ret_action_executing_system_error : ACTION execution system error
|
||||||
//# -12 : env.ret_action_wrong_parameters : ACTION Wrong parameters
|
//# -12 : Env.ret_action_wrong_parameters : ACTION Wrong parameters
|
||||||
//# -13 : env.ret_action_partial_done : ACTION partially done
|
//# -13 : Env.ret_action_partial_done : ACTION partially done
|
||||||
//#
|
//#
|
||||||
public void execute(_arguments):
|
public void execute(_arguments):
|
||||||
reset_instead_of_rebase = false
|
reset_instead_of_rebase = false
|
||||||
for elem in _arguments:
|
for elem in _arguments:
|
||||||
if elem.get_option_name() == "rebase":
|
if elem.getOptionName().equals("rebase":
|
||||||
reset_instead_of_rebase = true
|
reset_instead_of_rebase = true
|
||||||
debug.info("==> Request reset instead of rebase")
|
LOGGER.info("==> Request reset instead of rebase")
|
||||||
else:
|
else:
|
||||||
debug.error("SYNC Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'", ret_value=env.ret_action_wrong_parameters)
|
LOGGER.error("SYNC Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'", ret_value=Env.ret_action_wrong_parameters)
|
||||||
|
|
||||||
// check system is OK
|
// check system is OK
|
||||||
manifest.check_lutin_is_init()
|
Manifest.checkIsInit();
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
debug.info("update manifest : '" + str(env.get_island_path_manifest()) + "'")
|
LOGGER.info("update manifest : '" + str(Env.get_island_path_manifest()) + "'")
|
||||||
is_modify_manifest = commands.check_repository_is_modify(env.get_island_path_manifest())
|
is_modify_manifest = commands.check_repository_is_modify(Env.get_island_path_manifest())
|
||||||
if is_modify_manifest == true:
|
if is_modify_manifest == true:
|
||||||
debug.warning("Manifest is modify")
|
LOGGER.warn("Manifest is modify")
|
||||||
else:
|
else:
|
||||||
ret_track = commands.get_current_tracking_branch(env.get_island_path_manifest())
|
ret_track = commands.get_current_tracking_branch(Env.get_island_path_manifest())
|
||||||
is_forward = commands.is_forward(env.get_island_path_manifest(), ret_track)
|
is_forward = commands.is_forward(Env.get_island_path_manifest(), ret_track)
|
||||||
if is_forward == true:
|
if is_forward == true:
|
||||||
// fetch the repository
|
// fetch the repository
|
||||||
debug.warning("sync-local: Not update ==> the MANIFEST is forward the remote branch " + str(commands.get_forward(env.get_island_path_manifest(), ret_track)))
|
LOGGER.warn("sync-local: Not update ==> the MANIFEST is forward the remote branch " + str(commands.get_forward(Env.get_island_path_manifest(), ret_track)))
|
||||||
else:
|
else:
|
||||||
debug.verbose("Check behind:")
|
LOGGER.trace("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:
|
if is_behind == false:
|
||||||
// fetch the repository
|
// fetch the repository
|
||||||
debug.info("sync-local: MANIFEST is up-to-date")
|
LOGGER.info("sync-local: MANIFEST is up-to-date")
|
||||||
else:
|
else:
|
||||||
if reset_instead_of_rebase == true:
|
if reset_instead_of_rebase == true:
|
||||||
debug.info("sync-local: MANIFEST Reset to " + ret_track)
|
LOGGER.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:
|
else:
|
||||||
debug.info("sync-local: MANIFEST Rebase to " + ret_track)
|
LOGGER.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:
|
if os.path.exists(file_source_manifest) == false:
|
||||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'", ret_value=env.ret_manifest_is_not_existing)
|
LOGGER.error("Missing manifest file : '" + str(file_source_manifest) + "'", ret_value=Env.ret_manifest_is_not_existing)
|
||||||
|
|
||||||
mani = manifest.Manifest(file_source_manifest)
|
mani = manifest.Manifest(file_source_manifest)
|
||||||
|
|
||||||
all_project = mani.get_all_configs()
|
all_project = mani.get_all_configs()
|
||||||
debug.info("synchronize : " + str(len(all_project)) + " projects")
|
LOGGER.info("synchronize : " + str(len(all_project)) + " projects")
|
||||||
id_element = 0
|
id_element = 0
|
||||||
count_error = 0
|
count_error = 0
|
||||||
for elem in all_project:
|
for elem in all_project:
|
||||||
id_element += 1
|
id_element += 1
|
||||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||||
debug.info("----------------------------------------------------------------")
|
LOGGER.info("----------------------------------------------------------------")
|
||||||
debug.info("sync-local: " + base_display)
|
LOGGER.info("sync-local: " + base_display)
|
||||||
//debug.debug("elem : " + str(elem))
|
//LOGGER.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:
|
if os.path.exists(git_repo_path) == false:
|
||||||
// The Repository does not exist ==> Nothing to do...
|
// The Repository does not exist ==> Nothing to do...
|
||||||
debug.warning("sync-local: ==> Not download")
|
LOGGER.warn("sync-local: ==> Not download")
|
||||||
count_error += 1
|
count_error += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if os.path.exists(new Path(git_repo_path,".git")) == false:
|
if os.path.exists(new Path(git_repo_path,".git")) == false:
|
||||||
// path already exist but it is not used to as a git repo ==> this is an error
|
// path already exist but it is not used to as a git repo ==> this is an error
|
||||||
debug.warning("sync-local: is already existing but not used for a git repository. Remove it and sync")
|
LOGGER.warn("sync-local: is already existing but not used for a git repository. Remove it and sync")
|
||||||
count_error += 1
|
count_error += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
// simply update the repository ...
|
// simply update the repository ...
|
||||||
debug.verbose("Check modify:")
|
LOGGER.trace("Check modify:")
|
||||||
is_modify = commands.check_repository_is_modify(git_repo_path)
|
is_modify = commands.check_repository_is_modify(git_repo_path)
|
||||||
if is_modify == true:
|
if is_modify == true:
|
||||||
// fetch the repository
|
// fetch the repository
|
||||||
debug.warning("sync-local: Not update ==> the repository is modified (pass through)")
|
LOGGER.warn("sync-local: Not update ==> the repository is modified (pass through)")
|
||||||
count_error += 1
|
count_error += 1
|
||||||
continue
|
continue
|
||||||
debug.verbose("Check tracking and local branch:")
|
LOGGER.trace("Check tracking and local branch:")
|
||||||
// get tracking branch
|
// get tracking branch
|
||||||
ret_track = commands.get_current_tracking_branch(git_repo_path)
|
ret_track = commands.get_current_tracking_branch(git_repo_path)
|
||||||
select_branch = commands.get_current_branch(git_repo_path)
|
select_branch = commands.get_current_branch(git_repo_path)
|
||||||
debug.debug("sync-local: check: " + select_branch + " ==> " + ret_track)
|
LOGGER.debug("sync-local: check: " + select_branch + " ==> " + ret_track)
|
||||||
debug.verbose("Check forward:")
|
LOGGER.trace("Check forward:")
|
||||||
is_forward = commands.is_forward(git_repo_path, ret_track)
|
is_forward = commands.is_forward(git_repo_path, ret_track)
|
||||||
if is_forward == true:
|
if is_forward == true:
|
||||||
// fetch the repository
|
// fetch the repository
|
||||||
debug.warning("sync-local: Not update ==> the repository is forward the remote branch " + str(commands.get_forward(git_repo_path, ret_track)))
|
LOGGER.warn("sync-local: Not update ==> the repository is forward the remote branch " + str(commands.get_forward(git_repo_path, ret_track)))
|
||||||
count_error += 1
|
count_error += 1
|
||||||
continue
|
continue
|
||||||
debug.verbose("Check behind:")
|
LOGGER.trace("Check behind:")
|
||||||
is_behind = commands.is_behind(git_repo_path, ret_track)
|
is_behind = commands.is_behind(git_repo_path, ret_track)
|
||||||
if is_behind == false:
|
if is_behind == false:
|
||||||
// fetch the repository
|
// fetch the repository
|
||||||
debug.info("sync-local: Nothing to do.")
|
LOGGER.info("sync-local: Nothing to do.")
|
||||||
continue
|
continue
|
||||||
if reset_instead_of_rebase == true:
|
if reset_instead_of_rebase == true:
|
||||||
debug.info("sync-local: Reset to " + ret_track)
|
LOGGER.info("sync-local: Reset to " + ret_track)
|
||||||
commands.reset_hard(git_repo_path, ret_track)
|
commands.reset_hard(git_repo_path, ret_track)
|
||||||
else:
|
else:
|
||||||
debug.info("sync-local: Reset to " + ret_track)
|
LOGGER.info("sync-local: Reset to " + ret_track)
|
||||||
commands.rebase(git_repo_path, ret_track)
|
commands.rebase(git_repo_path, ret_track)
|
||||||
if count_error != 0:
|
if count_error != 0:
|
||||||
debug.info(" ***********************************************************")
|
LOGGER.info(" ***********************************************************")
|
||||||
debug.info(" ** local sync partial warning on " + str(count_error) + " repository")
|
LOGGER.info(" ** local sync partial warning on " + str(count_error) + " repository")
|
||||||
debug.info(" ***********************************************************")
|
LOGGER.info(" ***********************************************************")
|
||||||
return env.ret_action_partial_done
|
return Env.ret_action_partial_done
|
||||||
|
|
||||||
//# Update the links:
|
//# Update the links:
|
||||||
have_error = update_links.update(configuration, mani, "sync-local")
|
have_error = update_links.update(configuration, mani, "sync-local")
|
||||||
|
@ -1,190 +0,0 @@
|
|||||||
//!/usr/bin/python
|
|
||||||
// -*- coding: utf-8 -*-
|
|
||||||
//#
|
|
||||||
//# @author Edouard DUPIN
|
|
||||||
//#
|
|
||||||
//# @copyright 2012, Edouard DUPIN, all right reserved
|
|
||||||
//#
|
|
||||||
//# @license MPL v2.0 (see license file)
|
|
||||||
//#
|
|
||||||
|
|
||||||
from realog import debug
|
|
||||||
from island import tools
|
|
||||||
from island import env
|
|
||||||
from island import config
|
|
||||||
from island import multiprocess
|
|
||||||
from island import manifest
|
|
||||||
from island import commands
|
|
||||||
import update_links
|
|
||||||
import os
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @brief Get the global description of the current action
|
|
||||||
//# @return (string) the description string (fist line if reserved for the overview, all is for the specific display)
|
|
||||||
//#
|
|
||||||
public void help():
|
|
||||||
return "Syncronize all the repository referenced"
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @brief at the end of the help wa have the example section
|
|
||||||
//# @return (string) the Example description string
|
|
||||||
//#
|
|
||||||
public void help_example():
|
|
||||||
return "island init https://git.heeroyui.org/atria-tools/island.git"
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @brief Add argument to the specific action
|
|
||||||
//# @param[in,out] my_args (death.Arguments) Argument manager
|
|
||||||
//# @param[in] section Name of the currect action
|
|
||||||
//#
|
|
||||||
public void add_specific_arguments(my_args, section):
|
|
||||||
my_args.add("d", "download", haveParam=false, desc="Just download the 'not download' repository")
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @brief Execute the action required.
|
|
||||||
//#
|
|
||||||
//# @return error value [0 .. 50] the <0 value is reserved system ==> else, what you want.
|
|
||||||
//# None : No error (return program out 0)
|
|
||||||
//# -10 : ACTION is not existing
|
|
||||||
//# -11 : ACTION execution system error
|
|
||||||
//# -12 : ACTION Wrong parameters
|
|
||||||
//#
|
|
||||||
public void execute(_arguments):
|
|
||||||
just_download = false
|
|
||||||
for elem in _arguments:
|
|
||||||
if elem.get_option_name() == "download":
|
|
||||||
just_download = true
|
|
||||||
debug.info("find remote name: '" + elem.get_arg() + "'")
|
|
||||||
else:
|
|
||||||
debug.error("SYNC Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
|
||||||
|
|
||||||
// check system is OK
|
|
||||||
manifest.check_lutin_is_init()
|
|
||||||
|
|
||||||
configuration = config.get_unique_config()
|
|
||||||
|
|
||||||
// TODO: Load Old manifect to check diff ...
|
|
||||||
|
|
||||||
debug.info("update manifest : '" + str(env.get_island_path_manifest()) + "'")
|
|
||||||
is_modify_manifest = commands.check_repository_is_modify(env.get_island_path_manifest())
|
|
||||||
if is_modify_manifest == true:
|
|
||||||
commands.fetch(env.get_island_path_manifest(), "origin")
|
|
||||||
else:
|
|
||||||
commands.pull(env.get_island_path_manifest(), "origin")
|
|
||||||
|
|
||||||
file_source_manifest = new Path(env.get_island_path_manifest(), configuration.get_manifest_name())
|
|
||||||
if os.path.exists(file_source_manifest) == false:
|
|
||||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
|
||||||
|
|
||||||
mani = manifest.Manifest(file_source_manifest)
|
|
||||||
|
|
||||||
all_project = mani.get_all_configs()
|
|
||||||
debug.info("synchronize : " + str(len(all_project)) + " projects")
|
|
||||||
id_element = 0
|
|
||||||
for elem in all_project:
|
|
||||||
id_element += 1
|
|
||||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
|
||||||
debug.info("sync : " + base_display)
|
|
||||||
tools.wait_for_server_if_needed()
|
|
||||||
//debug.debug("elem : " + str(elem))
|
|
||||||
git_repo_path = new Path(env.get_island_root_path(), elem.path)
|
|
||||||
if elem.tag != None:
|
|
||||||
debug.warning("Need to select a specific tag version ... " + elem.tag)
|
|
||||||
if os.path.exists(git_repo_path) == false:
|
|
||||||
// this is a new clone ==> this is easy ...
|
|
||||||
//clone the manifest repository
|
|
||||||
address_manifest = ""
|
|
||||||
//## example git@git.plouf.com:basic_folder
|
|
||||||
address_manifest = elem.select_remote["fetch"]
|
|
||||||
if elem.select_remote["fetch"][0:4] == "git@" \
|
|
||||||
and len(elem.select_remote["fetch"][4:].split(":")) <= 1:
|
|
||||||
address_manifest += ":"
|
|
||||||
else:
|
|
||||||
address_manifest += "/"
|
|
||||||
address_manifest += elem.name
|
|
||||||
debug.info("clone the repo")
|
|
||||||
ret = commands.clone(git_repo_path, address_manifest, branch_name=elem.branch, origin=elem.select_remote["name"])
|
|
||||||
if ret[0] != "" \
|
|
||||||
and ret[0] != false:
|
|
||||||
// all is good, ready to get the system work corectly
|
|
||||||
debug.info("'" + str(ret) + "'")
|
|
||||||
debug.error("Clone repository does not work ... ")
|
|
||||||
continue
|
|
||||||
// add global mirror list
|
|
||||||
for mirror in elem.select_remote["mirror"]:
|
|
||||||
debug.verbose("Add global mirror: " + str(mirror))
|
|
||||||
cmd = "git remote add " + mirror["name"] + " " + mirror["fetch"]
|
|
||||||
if mirror["fetch"][0:4] == "git@":
|
|
||||||
cmd += ":"
|
|
||||||
else:
|
|
||||||
cmd += "/"
|
|
||||||
cmd += elem.name
|
|
||||||
ret = multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
|
||||||
if ret != "" \
|
|
||||||
and ret != false:
|
|
||||||
// all is good, ready to get the system work corectly
|
|
||||||
debug.info("'" + str(ret) + "'")
|
|
||||||
debug.warning("Can not add global mirror ... ")
|
|
||||||
continue
|
|
||||||
debug.verbose("Add global mirror: " + str(mirror) + " (done)")
|
|
||||||
//debug.info("plop " + str(elem.select_remote.keys()))
|
|
||||||
// check submodule if requested:
|
|
||||||
if elem.select_remote["sync"] == true \
|
|
||||||
and os.path.exists(new Path(git_repo_path, ".gitmodules")) == true:
|
|
||||||
debug.info(" ==> update submodule")
|
|
||||||
cmd = "git submodule init"
|
|
||||||
ret = multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
|
||||||
if ret != "" \
|
|
||||||
and ret != false:
|
|
||||||
// all is good, ready to get the system work corectly
|
|
||||||
debug.info("'" + str(ret) + "'")
|
|
||||||
debug.error("Can not init submodules ... ")
|
|
||||||
continue
|
|
||||||
cmd = "git submodule update"
|
|
||||||
ret = multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
|
||||||
if ret[:16] == "Submodule path '":
|
|
||||||
//all is good ...
|
|
||||||
debug.info(" " + ret)
|
|
||||||
elif ret != "" \
|
|
||||||
and ret != false:
|
|
||||||
// all is good, ready to get the system work corectly
|
|
||||||
debug.info("'" + str(ret) + "'")
|
|
||||||
debug.error("Can not init submodules ... ")
|
|
||||||
continue
|
|
||||||
continue
|
|
||||||
|
|
||||||
if just_download == true:
|
|
||||||
debug.info("SYNC: Already downloaded")
|
|
||||||
continue
|
|
||||||
|
|
||||||
if os.path.exists(new Path(git_repo_path,".git")) == false:
|
|
||||||
// path already exist but it is not used to as a git repo ==> this is an error
|
|
||||||
debug.error("path '" + git_repo_path + "' is already existing but not used for a git repository. Clean it and restart")
|
|
||||||
|
|
||||||
// simply update the repository ...
|
|
||||||
debug.verbose("Fetching project: ")
|
|
||||||
|
|
||||||
// get tracking branch
|
|
||||||
ret_track = commands.get_current_tracking_branch(git_repo_path)
|
|
||||||
is_modify = commands.check_repository_is_modify(git_repo_path)
|
|
||||||
select_branch = commands.get_current_branch(git_repo_path)
|
|
||||||
|
|
||||||
if is_modify == true:
|
|
||||||
// fetch the repository
|
|
||||||
commands.fetch(git_repo_path, elem.select_remote["name"])
|
|
||||||
debug.warning("[" + elem.name + "] Not update ==> the repository is modified (just fetch)")
|
|
||||||
continue
|
|
||||||
commands.pull(git_repo_path, elem.select_remote["name"])
|
|
||||||
|
|
||||||
debug.verbose("select branch = '" + select_branch + "' track: '" + str(ret_track) + "'")
|
|
||||||
// check submodule if requested:
|
|
||||||
if elem.select_remote["sync"] == true \
|
|
||||||
and os.path.exists(new Path(git_repo_path, ".gitmodules")) == true:
|
|
||||||
debug.info(" ==> sync submodule")
|
|
||||||
commands.submodule_sync(git_repo_path)
|
|
||||||
|
|
||||||
//# Update the links:
|
|
||||||
have_error = update_links.update(configuration, mani, "sync-local")
|
|
||||||
if have_error == true:
|
|
||||||
return -1
|
|
||||||
return None
|
|
@ -1,86 +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 debug
|
|
||||||
from island import tools
|
|
||||||
from island import env
|
|
||||||
from island import config
|
|
||||||
from island import commands
|
|
||||||
from island import multiprocess
|
|
||||||
from island import manifest
|
|
||||||
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 "Add a 'volatile' repository with a local path (this element is update as an element in the manifest but is not managed by the manifest)"
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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_arg("git repository", optionnal=false, desc="Git repositoty to download")
|
|
||||||
my_args.add_arg("path", optionnal=false, desc="Path to install the new git repository")
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @brief at the end of the help wa have the example section
|
|
||||||
//# @return (string) the Example description string
|
|
||||||
//#
|
|
||||||
public void help_example():
|
|
||||||
return "island volatile-add https://git.heeroyui.org/atria-tools/island.git git"
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @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)
|
|
||||||
//# -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:
|
|
||||||
debug.error("Missing argument to execute the current action [git repository] [path]")
|
|
||||||
|
|
||||||
// the configuration availlable:
|
|
||||||
path = ""
|
|
||||||
address_git = ""
|
|
||||||
for elem in _arguments:
|
|
||||||
if elem.get_option_name() == "git repository":
|
|
||||||
address_git = elem.get_arg()
|
|
||||||
elif elem.get_option_name() == "path":
|
|
||||||
path = elem.get_arg()
|
|
||||||
else:
|
|
||||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
|
||||||
|
|
||||||
if address_git == "":
|
|
||||||
debug.error("volatile-add: Missing git repository address", env.ret_action_wrong_parameters)
|
|
||||||
|
|
||||||
debug.info("Add 'volatile' repository: '" + address_git + "' path='" + path + "'")
|
|
||||||
|
|
||||||
// check system is OK
|
|
||||||
manifest.check_lutin_is_init()
|
|
||||||
|
|
||||||
// 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
|
|
||||||
conf.store()
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
@ -1,53 +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 debug
|
|
||||||
from island import tools
|
|
||||||
from island import env
|
|
||||||
from island import config
|
|
||||||
from island import commands
|
|
||||||
from island import multiprocess
|
|
||||||
from island import manifest
|
|
||||||
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 "List all the volatil repository"
|
|
||||||
|
|
||||||
//#
|
|
||||||
//# @brief Execute the action required.
|
|
||||||
//#
|
|
||||||
//# @return error value [0 .. 50] the <0 value is reserved system ==> else, what you want.
|
|
||||||
//# None : No error (return program out 0)
|
|
||||||
//# -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:
|
|
||||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
|
||||||
|
|
||||||
// check system is OK
|
|
||||||
manifest.check_lutin_is_init()
|
|
||||||
|
|
||||||
conf = config.get_unique_config()
|
|
||||||
volatiles = conf.get_volatile()
|
|
||||||
debug.info("List of all volatiles repository: ")
|
|
||||||
for elem in volatiles:
|
|
||||||
debug.info("\t" + elem["path"] + "\r\t\t\t\t" + elem["git_address"])
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
|||||||
//# @license MPL v2.0 (see license file)
|
//# @license MPL v2.0 (see license file)
|
||||||
//#
|
//#
|
||||||
|
|
||||||
from realog import debug
|
from realog import Log
|
||||||
from island import tools
|
from island import tools
|
||||||
from island import env
|
from island import env
|
||||||
from island import config
|
from island import config
|
||||||
@ -18,117 +18,36 @@ from island import commands
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
default_behind_message = "[DEV] update dev tag version"
|
|
||||||
default_update_message = "[VERSION] update dev tag version"
|
|
||||||
|
|
||||||
|
|
||||||
base_name_of_a_tagged_branch = "branch_on_tag_"
|
|
||||||
|
|
||||||
public void display_status(elem, argument_remote_name, argument_display_tag, id_element, base_display):
|
|
||||||
volatile = ""
|
|
||||||
if elem.volatile == true:
|
|
||||||
volatile = " (volatile)"
|
|
||||||
debug.verbose("status : " + base_display)
|
|
||||||
//debug.debug("elem : " + str(elem))
|
|
||||||
git_repo_path = new Path(env.get_island_root_path(), elem.path)
|
|
||||||
if os.path.exists(git_repo_path) == false:
|
|
||||||
debug.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)
|
|
||||||
debug.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:
|
|
||||||
debug.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 = " *** "
|
|
||||||
|
|
||||||
debug.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)
|
|
||||||
debug.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- - - - -"
|
|
||||||
debug.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"
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
ret_diff = multiprocess.run_command(cmd, cwd=git_repo_path)
|
|
||||||
tmp_color_red = "\033[31m"
|
|
||||||
tmp_color_default= "\033[00m"
|
|
||||||
debug.info(tmp_color_red + ret_diff[1] + tmp_color_default)
|
|
||||||
return in_behind
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void deliver_check(elem, argument_remote_name, id_element, base_display, source_branch, destination_branch):
|
public void deliver_check(elem, argument_remote_name, id_element, base_display, source_branch, destination_branch):
|
||||||
deliver_availlable = true
|
deliver_availlable = true
|
||||||
debug.debug("deliver-ckeck: " + base_display)
|
LOGGER.debug("deliver-ckeck: " + base_display)
|
||||||
debug.debug(" ==> check repo exist")
|
LOGGER.debug(" ==> check repo exist")
|
||||||
// Check the 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:
|
if os.path.exists(git_repo_path) == false:
|
||||||
debug.warning("deliver-ckeck: " + base_display + " ==> MUST be download")
|
LOGGER.warn("deliver-ckeck: " + base_display + " ==> MUST be download")
|
||||||
return false
|
return false
|
||||||
debug.debug(" ==> check is modify")
|
LOGGER.debug(" ==> check is modify")
|
||||||
// check if the curent repo is modify
|
// check if the curent repo is modify
|
||||||
is_modify = commands.check_repository_is_modify(git_repo_path)
|
is_modify = commands.check_repository_is_modify(git_repo_path)
|
||||||
if is_modify == true:
|
if is_modify == true:
|
||||||
debug.warning("deliver-ckeck: " + base_display + " ==> MUST not be modify")
|
LOGGER.warn("deliver-ckeck: " + base_display + " ==> MUST not be modify")
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|
||||||
debug.debug(" ==> check current branch is '" + source_branch + "'")
|
LOGGER.debug(" ==> check current branch is '" + source_branch + "'")
|
||||||
// check if we are on source_branch
|
// check if we are on source_branch
|
||||||
select_branch = commands.get_current_branch(git_repo_path)
|
select_branch = commands.get_current_branch(git_repo_path)
|
||||||
if select_branch != source_branch:
|
if select_branch != source_branch:
|
||||||
debug.warning("deliver-ckeck: " + base_display + " ==> MUST be on source branch: '" + source_branch + "' and is: '" + select_branch + "'")
|
LOGGER.warn("deliver-ckeck: " + base_display + " ==> MUST be on source branch: '" + source_branch + "' and is: '" + select_branch + "'")
|
||||||
return false
|
return false
|
||||||
debug.debug(" ==> check have tracking branch")
|
LOGGER.debug(" ==> check have tracking branch")
|
||||||
// check if we have a remote traking branch
|
// check if we have a remote traking branch
|
||||||
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, select_branch)
|
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, select_branch)
|
||||||
if tracking_remote_branch == None:
|
if tracking_remote_branch == None:
|
||||||
debug.warning("deliver-ckeck: " + base_display + " ==> MUST have a remote tracking branch")
|
LOGGER.warn("deliver-ckeck: " + base_display + " ==> MUST have a remote tracking branch")
|
||||||
deliver_availlable = false
|
deliver_availlable = false
|
||||||
|
|
||||||
|
|
||||||
@ -136,17 +55,17 @@ public void deliver_check(elem, argument_remote_name, id_element, base_display,
|
|||||||
commands.checkout(git_repo_path, destination_branch)
|
commands.checkout(git_repo_path, destination_branch)
|
||||||
// TODO: check return value
|
// TODO: check return value
|
||||||
|
|
||||||
debug.debug(" ==> check current branch is '" + source_branch + "'")
|
LOGGER.debug(" ==> check current branch is '" + source_branch + "'")
|
||||||
// check if we are on "master"
|
// check if we are on "master"
|
||||||
select_branch = commands.get_current_branch(git_repo_path)
|
select_branch = commands.get_current_branch(git_repo_path)
|
||||||
if select_branch != destination_branch:
|
if select_branch != destination_branch:
|
||||||
debug.warning("deliver-ckeck: " + base_display + " ==> Can not checkout branch: '" + destination_branch + "' and is: '" + select_branch + "'")
|
LOGGER.warn("deliver-ckeck: " + base_display + " ==> Can not checkout branch: '" + destination_branch + "' and is: '" + select_branch + "'")
|
||||||
deliver_availlable = false
|
deliver_availlable = false
|
||||||
debug.debug(" ==> check have tracking branch")
|
LOGGER.debug(" ==> check have tracking branch")
|
||||||
// check if we have a remote traking branch
|
// check if we have a remote traking branch
|
||||||
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, select_branch)
|
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, select_branch)
|
||||||
if tracking_remote_branch == None:
|
if tracking_remote_branch == None:
|
||||||
debug.warning("deliver-ckeck: " + base_display + " ==> MUST have a remote tracking branch")
|
LOGGER.warn("deliver-ckeck: " + base_display + " ==> MUST have a remote tracking branch")
|
||||||
deliver_availlable = false
|
deliver_availlable = false
|
||||||
|
|
||||||
|
|
||||||
@ -155,7 +74,7 @@ public void deliver_check(elem, argument_remote_name, id_element, base_display,
|
|||||||
// check if we have a local branch
|
// check if we have a local branch
|
||||||
list_branch_local = commands.get_list_branch_local(git_repo_path)
|
list_branch_local = commands.get_list_branch_local(git_repo_path)
|
||||||
if destination_branch not in list_branch_local:
|
if destination_branch not in list_branch_local:
|
||||||
debug.warning("deliver-ckeck: " + base_display + " ==> MUST have local branch named '" + destination_branch + "'")
|
LOGGER.warn("deliver-ckeck: " + base_display + " ==> MUST have local branch named '" + destination_branch + "'")
|
||||||
deliver_availlable = false
|
deliver_availlable = false
|
||||||
// TODO: check source_branch is up to date
|
// TODO: check source_branch is up to date
|
||||||
|
|
||||||
@ -169,98 +88,6 @@ public void deliver_check(elem, argument_remote_name, id_element, base_display,
|
|||||||
return deliver_availlable
|
return deliver_availlable
|
||||||
|
|
||||||
|
|
||||||
public void checkout_elem(elem, argument_remote_name, branch_to_checkout, base_display):
|
|
||||||
debug.verbose("checkout : " + base_display)
|
|
||||||
git_repo_path = new Path(env.get_island_root_path(), elem.path)
|
|
||||||
if os.path.exists(git_repo_path) == false:
|
|
||||||
debug.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:
|
|
||||||
debug.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:
|
|
||||||
debug.info("checkout " + base_display + " ==> Can not checkout for 'volatile' repository")
|
|
||||||
return true
|
|
||||||
if elem.tag == None:
|
|
||||||
debug.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:
|
|
||||||
debug.info("checkout " + base_display + " ==> No change already on good branch")
|
|
||||||
return true
|
|
||||||
|
|
||||||
// check if we have already checkout the branch before
|
|
||||||
debug.verbose(" check : " + branch_to_checkout + " in " + str(list_branch_local))
|
|
||||||
if branch_to_checkout in list_branch_local:
|
|
||||||
cmd = "git checkout " + branch_to_checkout
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
ret = multiprocess.run_command(cmd, cwd=git_repo_path)
|
|
||||||
if ret[0] != 0 \
|
|
||||||
and ret[1] != "" \
|
|
||||||
and ret != false:
|
|
||||||
debug.info("'" + str(ret) + "'")
|
|
||||||
debug.error("checkout " + base_display + " ==> Can not checkout to the correct branch")
|
|
||||||
return false
|
|
||||||
debug.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:
|
|
||||||
debug.info(" ==> find ...")
|
|
||||||
else:
|
|
||||||
debug.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
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
ret = multiprocess.run_command(cmd, cwd=git_repo_path)
|
|
||||||
if ret[1] != "" \
|
|
||||||
and ret != false:
|
|
||||||
debug.info("'" + str(ret) + "'")
|
|
||||||
debug.error("checkout " + base_display + " ==> Can not checkout to the correct branch")
|
|
||||||
return false
|
|
||||||
debug.info("checkout " + base_display + " ==> create new branch")
|
|
||||||
return true
|
|
||||||
// Checkout a specific tags:
|
|
||||||
if elem.tag in list_tags:
|
|
||||||
debug.info(" ==> find ...")
|
|
||||||
else:
|
|
||||||
debug.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
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
ret = multiprocess.run_command(cmd, cwd=git_repo_path)
|
|
||||||
if ret[1] != "" \
|
|
||||||
and ret != false:
|
|
||||||
debug.info("'" + str(ret) + "'")
|
|
||||||
debug.error("checkout " + base_display + " ==> Can not checkout to the correct tags")
|
|
||||||
return false
|
|
||||||
debug.info("checkout " + base_display + " ==> create new branch: " + branch_to_checkout)
|
|
||||||
return true
|
|
||||||
|
|
||||||
|
|
||||||
public void get_current_version_repo(git_repo_path):
|
public void get_current_version_repo(git_repo_path):
|
||||||
@ -268,26 +95,26 @@ public void get_current_version_repo(git_repo_path):
|
|||||||
add_in_version_management = false
|
add_in_version_management = false
|
||||||
version_description = None
|
version_description = None
|
||||||
if os.path.exists(version_path_file) == false:
|
if os.path.exists(version_path_file) == false:
|
||||||
debug.info("deliver: ==> No 'version.txt' file ==> not manage release version....")
|
LOGGER.info("deliver: ==> No 'version.txt' file ==> not manage release version....")
|
||||||
// Action to do:
|
// Action to do:
|
||||||
valid = false
|
valid = false
|
||||||
while valid == false:
|
while valid == false:
|
||||||
debug.info("Create a new version: (0.0.0)")
|
LOGGER.info("Create a new version: (0.0.0)")
|
||||||
debug.info(" (1) Add in managing version")
|
LOGGER.info(" (1) Add in managing version")
|
||||||
debug.info(" (2) Do NOTHING & continue")
|
LOGGER.info(" (2) Do NOTHING & continue")
|
||||||
input1 = input()
|
input1 = input()
|
||||||
if input1 in ["1", "2"]:
|
if input1 in ["1", "2"]:
|
||||||
valid = true
|
valid = true
|
||||||
else:
|
else:
|
||||||
debug.info("!!! Must select in range " + str(["1", "2"]))
|
LOGGER.info("!!! Must select in range " + str(["1", "2"]))
|
||||||
if input1 == "1":
|
if input1.equals("1":
|
||||||
version_description = [0, 0, 0]
|
version_description = [0, 0, 0]
|
||||||
add_in_version_management = true
|
add_in_version_management = true
|
||||||
elif input1 == "2":
|
} else if input1.equals("2":
|
||||||
debug.info("Continue Not managing for this repository")
|
LOGGER.info("Continue Not managing for this repository")
|
||||||
return (None, None)
|
return (None, None)
|
||||||
else:
|
else:
|
||||||
debug.warning("An error occured for this repository")
|
LOGGER.warn("An error occured for this repository")
|
||||||
return (None, None)
|
return (None, None)
|
||||||
else:
|
else:
|
||||||
version_description = tools.version_string_to_list(tools.file_read_data(version_path_file))
|
version_description = tools.version_string_to_list(tools.file_read_data(version_path_file))
|
||||||
@ -304,10 +131,10 @@ public void create_new_version_repo(git_repo_path, version_description, add_in_v
|
|||||||
for elem_sha1 in ret_destination_branch_sha1:
|
for elem_sha1 in ret_destination_branch_sha1:
|
||||||
if elem_sha1 not in ret_source_branch_sha1:
|
if elem_sha1 not in ret_source_branch_sha1:
|
||||||
message = commands.get_specific_commit_message(git_repo_path, elem_sha1)
|
message = commands.get_specific_commit_message(git_repo_path, elem_sha1)
|
||||||
debug.warning("deliver: Forward commit: '" + message + "'")
|
LOGGER.warn("deliver: Forward commit: '" + message + "'")
|
||||||
have_forward = true
|
have_forward = true
|
||||||
if have_forward == true:
|
if have_forward == true:
|
||||||
debug.error("'" + destination_branch + "' branch must not be forward '" + source_branch + "' branch")
|
LOGGER.error("'" + destination_branch + "' branch must not be forward '" + source_branch + "' branch")
|
||||||
return None
|
return None
|
||||||
behind_message = ""
|
behind_message = ""
|
||||||
behind_count = 0
|
behind_count = 0
|
||||||
@ -317,30 +144,30 @@ public void create_new_version_repo(git_repo_path, version_description, add_in_v
|
|||||||
behind_count += 1
|
behind_count += 1
|
||||||
behind_message = message
|
behind_message = message
|
||||||
if behind_count == 0 and add_in_version_management == false:
|
if behind_count == 0 and add_in_version_management == false:
|
||||||
debug.info("deliver: ==> Nothing to do (1).")
|
LOGGER.info("deliver: ==> Nothing to do (1).")
|
||||||
return None
|
return None
|
||||||
if behind_count == 1 \
|
if behind_count == 1 \
|
||||||
and ( behind_message == default_behind_message
|
and ( behind_message == default_behind_message
|
||||||
or behind_message == default_update_message):
|
or behind_message == default_update_message):
|
||||||
debug.info("deliver: ==> Nothing to do (2).")
|
LOGGER.info("deliver: ==> Nothing to do (2).")
|
||||||
return None
|
return None
|
||||||
for elem_sha1 in ret_source_branch_sha1:
|
for elem_sha1 in ret_source_branch_sha1:
|
||||||
if elem_sha1 not in ret_destination_branch_sha1:
|
if elem_sha1 not in ret_destination_branch_sha1:
|
||||||
message = commands.get_specific_commit_message(git_repo_path, elem_sha1)
|
message = commands.get_specific_commit_message(git_repo_path, elem_sha1)
|
||||||
debug.info("deliver: Behind commit: '" + message + "'")
|
LOGGER.info("deliver: Behind commit: '" + message + "'")
|
||||||
// Choice of the new version:
|
// Choice of the new version:
|
||||||
valid = false
|
valid = false
|
||||||
while valid == false:
|
while valid == false:
|
||||||
debug.info("update version: curent: " + str(version_description))
|
LOGGER.info("update version: curent: " + str(version_description))
|
||||||
debug.info(" (1) Major version (change API)")
|
LOGGER.info(" (1) Major version (change API)")
|
||||||
debug.info(" (2) Medium version (add feature)")
|
LOGGER.info(" (2) Medium version (add feature)")
|
||||||
debug.info(" (3) Minor version (Bug fix & doc)")
|
LOGGER.info(" (3) Minor version (Bug fix & doc)")
|
||||||
debug.info(" (4) Do not release & continue")
|
LOGGER.info(" (4) Do not release & continue")
|
||||||
input1 = input()
|
input1 = input()
|
||||||
if input1 in ["1", "2", "3", "4"]:
|
if input1 in ["1", "2", "3", "4"]:
|
||||||
valid = true
|
valid = true
|
||||||
else:
|
else:
|
||||||
debug.info("!!! Must select in range " + str(["1", "2", "3", "4"]))
|
LOGGER.info("!!! Must select in range " + str(["1", "2", "3", "4"]))
|
||||||
// limit and force at 3 the nuber of variables
|
// limit and force at 3 the nuber of variables
|
||||||
version_description_tmp = version_description
|
version_description_tmp = version_description
|
||||||
version_description = []
|
version_description = []
|
||||||
@ -356,84 +183,84 @@ public void create_new_version_repo(git_repo_path, version_description, add_in_v
|
|||||||
version_description.append(version_description_tmp[2])
|
version_description.append(version_description_tmp[2])
|
||||||
else:
|
else:
|
||||||
version_description.append(0)
|
version_description.append(0)
|
||||||
debug.info("update version: curent: " + str(version_description))
|
LOGGER.info("update version: curent: " + str(version_description))
|
||||||
// increment the version
|
// increment the version
|
||||||
if input1 == "1":
|
if input1.equals("1":
|
||||||
version_description[0] += 1
|
version_description[0] += 1
|
||||||
version_description[1] = 0
|
version_description[1] = 0
|
||||||
version_description[2] = 0
|
version_description[2] = 0
|
||||||
elif input1 == "2":
|
} else if input1.equals("2":
|
||||||
version_description[1] += 1
|
version_description[1] += 1
|
||||||
version_description[2] = 0
|
version_description[2] = 0
|
||||||
elif input1 == "3":
|
} else if input1.equals("3":
|
||||||
version_description[2] += 1
|
version_description[2] += 1
|
||||||
elif input1 == "4":
|
} else if input1.equals("4":
|
||||||
debug.info("No release for this repository")
|
LOGGER.info("No release for this repository")
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
debug.warning("An error occured for this repository")
|
LOGGER.warn("An error occured for this repository")
|
||||||
return None
|
return None
|
||||||
debug.info("update version: curent: " + str(version_description))
|
LOGGER.info("update version: curent: " + str(version_description))
|
||||||
return version_description
|
return version_description
|
||||||
|
|
||||||
|
|
||||||
public void deliver_push(elem, argument_remote_name, destination_branch, source_branch, base_display):
|
public void deliver_push(elem, argument_remote_name, destination_branch, source_branch, base_display):
|
||||||
// Check the 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:
|
if os.path.exists(git_repo_path) == false:
|
||||||
debug.warning("deliver-push: " + base_display + " ==> MUST be download")
|
LOGGER.warn("deliver-push: " + base_display + " ==> MUST be download")
|
||||||
return
|
return
|
||||||
// check if we are on destination_branch
|
// check if we are on destination_branch
|
||||||
select_branch = commands.get_current_branch(git_repo_path)
|
select_branch = commands.get_current_branch(git_repo_path)
|
||||||
if select_branch != destination_branch:
|
if select_branch != destination_branch:
|
||||||
debug.warning("deliver-push: " + base_display + " ==> MUST be on '" + destination_branch + "'")
|
LOGGER.warn("deliver-push: " + base_display + " ==> MUST be on '" + destination_branch + "'")
|
||||||
return
|
return
|
||||||
// check if we have a local branch
|
// check if we have a local branch
|
||||||
list_branch_local = commands.get_list_branch_local(git_repo_path)
|
list_branch_local = commands.get_list_branch_local(git_repo_path)
|
||||||
if source_branch not in list_branch_local:
|
if source_branch not in list_branch_local:
|
||||||
debug.warning("deliver-push: " + base_display + " ==> No '" + source_branch + "' (not managed)")
|
LOGGER.warn("deliver-push: " + base_display + " ==> No '" + source_branch + "' (not managed)")
|
||||||
return
|
return
|
||||||
if destination_branch not in list_branch_local:
|
if destination_branch not in list_branch_local:
|
||||||
debug.warning("deliver-push: " + base_display + " ==> No '" + destination_branch + "' (not managed)")
|
LOGGER.warn("deliver-push: " + base_display + " ==> No '" + destination_branch + "' (not managed)")
|
||||||
return
|
return
|
||||||
list_of_element_to_push = []
|
list_of_element_to_push = []
|
||||||
// check sha1 of destination_branch
|
// check sha1 of destination_branch
|
||||||
sha_1_destination = commands.get_sha1_for_branch(git_repo_path, destination_branch)
|
sha_1_destination = commands.get_sha1_for_branch(git_repo_path, destination_branch)
|
||||||
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, destination_branch)
|
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, destination_branch)
|
||||||
if tracking_remote_branch == None:
|
if tracking_remote_branch == None:
|
||||||
debug.warning("deliver-push: " + base_display + " ==> '" + destination_branch + "' have no tracking branch")
|
LOGGER.warn("deliver-push: " + base_display + " ==> '" + destination_branch + "' have no tracking branch")
|
||||||
deliver_availlable = false
|
deliver_availlable = false
|
||||||
sha_1_destination_tracking = commands.get_sha1_for_branch(git_repo_path, tracking_remote_branch)
|
sha_1_destination_tracking = commands.get_sha1_for_branch(git_repo_path, tracking_remote_branch)
|
||||||
if sha_1_destination == sha_1_destination_tracking:
|
if sha_1_destination == sha_1_destination_tracking:
|
||||||
debug.info("deliver-push: " + base_display + " ==> '" + destination_branch + "' && '" + tracking_remote_branch + "' have the same sha1")
|
LOGGER.info("deliver-push: " + base_display + " ==> '" + destination_branch + "' && '" + tracking_remote_branch + "' have the same sha1")
|
||||||
else:
|
else:
|
||||||
list_of_element_to_push.append(destination_branch)
|
list_of_element_to_push.append(destination_branch)
|
||||||
// check sha1 of source_branch
|
// check sha1 of source_branch
|
||||||
sha_1_source = commands.get_sha1_for_branch(git_repo_path, source_branch)
|
sha_1_source = commands.get_sha1_for_branch(git_repo_path, source_branch)
|
||||||
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, source_branch)
|
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, source_branch)
|
||||||
if tracking_remote_branch == None:
|
if tracking_remote_branch == None:
|
||||||
debug.info("deliver-push: " + base_display + " ==> '" + source_branch + "' have no tracking branch")
|
LOGGER.info("deliver-push: " + base_display + " ==> '" + source_branch + "' have no tracking branch")
|
||||||
deliver_availlable = false
|
deliver_availlable = false
|
||||||
sha_1_source_tracking = commands.get_sha1_for_branch(git_repo_path, tracking_remote_branch)
|
sha_1_source_tracking = commands.get_sha1_for_branch(git_repo_path, tracking_remote_branch)
|
||||||
if sha_1_source == sha_1_source_tracking:
|
if sha_1_source == sha_1_source_tracking:
|
||||||
debug.info("deliver-push: " + base_display + " ==> '" + source_branch + "' && '" + tracking_remote_branch + "' have the same sha1")
|
LOGGER.info("deliver-push: " + base_display + " ==> '" + source_branch + "' && '" + tracking_remote_branch + "' have the same sha1")
|
||||||
else:
|
else:
|
||||||
list_of_element_to_push.append(source_branch)
|
list_of_element_to_push.append(source_branch)
|
||||||
ret_current_tags = commands.get_tags_current(git_repo_path)
|
ret_current_tags = commands.get_tags_current(git_repo_path)
|
||||||
if len(ret_current_tags) == 0:
|
if len(ret_current_tags) == 0:
|
||||||
debug.info("deliver-push: " + base_display + " ==> No tag on the current '" + destination_branch + "'")
|
LOGGER.info("deliver-push: " + base_display + " ==> No tag on the current '" + destination_branch + "'")
|
||||||
return
|
return
|
||||||
if len(ret_current_tags) > 1:
|
if len(ret_current_tags) > 1:
|
||||||
debug.info("deliver-push: " + base_display + " ==> Too mush tags on the current '" + destination_branch + "' : " + str(ret_current_tags) + " ==> only support 1")
|
LOGGER.info("deliver-push: " + base_display + " ==> Too mush tags on the current '" + destination_branch + "' : " + str(ret_current_tags) + " ==> only support 1")
|
||||||
return
|
return
|
||||||
list_remote_tags = commands.get_tags_remote(git_repo_path, argument_remote_name)
|
list_remote_tags = commands.get_tags_remote(git_repo_path, argument_remote_name)
|
||||||
debug.verbose("remote tags: " + str(list_remote_tags))
|
LOGGER.trace("remote tags: " + str(list_remote_tags))
|
||||||
if ret_current_tags[0] not in list_remote_tags:
|
if ret_current_tags[0] not in list_remote_tags:
|
||||||
debug.info("deliver-push: " + base_display + " ==> tag already exist.")
|
LOGGER.info("deliver-push: " + base_display + " ==> tag already exist.")
|
||||||
list_of_element_to_push.append(ret_current_tags[0])
|
list_of_element_to_push.append(ret_current_tags[0])
|
||||||
if len(list_of_element_to_push) == 0:
|
if len(list_of_element_to_push) == 0:
|
||||||
debug.info("deliver-push: " + base_display + " ==> Everything up-to-date")
|
LOGGER.info("deliver-push: " + base_display + " ==> Everything up-to-date")
|
||||||
return
|
return
|
||||||
debug.info("deliver-push: " + base_display + " ==> element to push:" + str(list_of_element_to_push))
|
LOGGER.info("deliver-push: " + base_display + " ==> element to push:" + str(list_of_element_to_push))
|
||||||
//push all on the server:
|
//push all on the server:
|
||||||
commands.push(git_repo_path, argument_remote_name, list_of_element_to_push)
|
commands.push(git_repo_path, argument_remote_name, list_of_element_to_push)
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
//# @license MPL v2.0 (see license file)
|
//# @license MPL v2.0 (see license file)
|
||||||
//#
|
//#
|
||||||
|
|
||||||
from realog import debug
|
from realog import Log
|
||||||
from island import tools
|
from island import tools
|
||||||
from island import env
|
from island import env
|
||||||
import os
|
import os
|
||||||
@ -18,23 +18,23 @@ public void update(configuration, mani, type_call):
|
|||||||
// TODO: do not remove link when not needed
|
// TODO: do not remove link when not needed
|
||||||
if len(configuration.get_links()) != 0 \
|
if len(configuration.get_links()) != 0 \
|
||||||
or len(mani.get_links()) != 0:
|
or len(mani.get_links()) != 0:
|
||||||
debug.info(type_call + ": remove old links ...")
|
LOGGER.info(type_call + ": remove old links ...")
|
||||||
for elem in configuration.get_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"])
|
||||||
debug.info(type_call + ": link: " + str(base_path))
|
LOGGER.info(type_call + ": link: " + str(base_path))
|
||||||
if os.path.islink(base_path) == true:
|
if os.path.islink(base_path) == true:
|
||||||
os.unlink(base_path)
|
os.unlink(base_path)
|
||||||
else:
|
else:
|
||||||
debug.error(type_call + ": remove link is not authorised ==> not a link", crash=false)
|
LOGGER.error(type_call + ": remove link is not authorised ==> not a link", crash=false)
|
||||||
have_error = true
|
have_error = true
|
||||||
configuration.clear_links()
|
configuration.clear_links()
|
||||||
debug.info(type_call + ": add new links ...")
|
LOGGER.info(type_call + ": add new links ...")
|
||||||
for elem in mani.get_links():
|
for elem in mani.get_links():
|
||||||
base_path = new Path(env.get_island_root_path(), elem["destination"])
|
base_path = new Path(Env.get_island_root_path(), elem["destination"])
|
||||||
source_path = new Path(env.get_island_root_path(), elem["source"])
|
source_path = new Path(Env.get_island_root_path(), elem["source"])
|
||||||
debug.info(type_call + ": link: " + str(base_path))
|
LOGGER.info(type_call + ": link: " + str(base_path))
|
||||||
if os.path.exists(base_path) == true:
|
if os.path.exists(base_path) == true:
|
||||||
debug.error(type_call + ": create link is not possible ==> path already exist", crash=false)
|
LOGGER.error(type_call + ": create link is not possible ==> path already exist", crash=false)
|
||||||
have_error = true
|
have_error = true
|
||||||
else:
|
else:
|
||||||
tools.create_directory_of_file(base_path)
|
tools.create_directory_of_file(base_path)
|
||||||
|
@ -1,388 +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)
|
|
||||||
//#
|
|
||||||
|
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
import errno
|
|
||||||
import fnmatch
|
|
||||||
import stat
|
|
||||||
// Local import
|
|
||||||
from realog import debug
|
|
||||||
from . import env
|
|
||||||
from . import multiprocess
|
|
||||||
from . import debug
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
"""
|
|
||||||
public void check_repository_is_modify(path_repository):
|
|
||||||
// check if the repository is modify
|
|
||||||
cmd = "git diff --quiet"
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
multiprocess.generic_display_error(return_value, "check_repository_is_modify", error_only=true, availlable_return=[0,1], display_if_nothing=false)
|
|
||||||
ret_diff = return_value
|
|
||||||
if ret_diff[0] == 0:
|
|
||||||
return false
|
|
||||||
return true
|
|
||||||
|
|
||||||
public void get_list_branch_meta(path_repository):
|
|
||||||
// get local branch
|
|
||||||
cmd = "git branch -a"
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
multiprocess.generic_display_error(return_value, "get_list_branch_meta", error_only=true)
|
|
||||||
ret_branch = return_value
|
|
||||||
list_branch = ret_branch[1].split('\n')
|
|
||||||
out = []
|
|
||||||
for elem_branch in list_branch:
|
|
||||||
is_remote = false
|
|
||||||
branch_name = ""
|
|
||||||
is_selected = false
|
|
||||||
if len(elem_branch.split(" -> ")) != 1:
|
|
||||||
continue
|
|
||||||
// separate the remote element
|
|
||||||
if elem_branch[2:10] == "remotes/":
|
|
||||||
elem_branch = elem_branch[:2] + elem_branch[10:]
|
|
||||||
is_remote = true
|
|
||||||
// separate select branch
|
|
||||||
if elem_branch[:2] == "* ":
|
|
||||||
is_selected = true
|
|
||||||
branch_name = elem_branch[2:]
|
|
||||||
else:
|
|
||||||
branch_name = elem_branch[2:]
|
|
||||||
out.append({
|
|
||||||
"remote": is_remote,
|
|
||||||
"name": branch_name,
|
|
||||||
"select": is_selected
|
|
||||||
})
|
|
||||||
debug.extreme_verbose("List all branch Meta: " + str(out))
|
|
||||||
return out
|
|
||||||
|
|
||||||
|
|
||||||
public void get_list_branch_all(path_repository):
|
|
||||||
tmp = get_list_branch_meta(path_repository)
|
|
||||||
out = []
|
|
||||||
for elem in tmp:
|
|
||||||
out.append(elem["name"])
|
|
||||||
debug.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"])
|
|
||||||
debug.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"])
|
|
||||||
debug.verbose("List remote branch: " + str(out))
|
|
||||||
return out
|
|
||||||
|
|
||||||
public void get_current_branch(path_repository):
|
|
||||||
tmp = get_list_branch_meta(path_repository)
|
|
||||||
for elem in tmp:
|
|
||||||
if elem["select"] == true:
|
|
||||||
debug.verbose("List local branch: " + str(elem["name"]))
|
|
||||||
return elem["name"]
|
|
||||||
debug.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}"
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
if return_value[1] == "@{u}":
|
|
||||||
debug.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
|
|
||||||
debug.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 == "":
|
|
||||||
return ""
|
|
||||||
cmd = "git log --format=%B -n 1 " + sha_1
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
multiprocess.generic_display_error(return_value, "get_specific_commit_message", error_only=true)
|
|
||||||
return return_value[1].split('\n')[0]
|
|
||||||
|
|
||||||
public void get_sha1_for_branch(path_repository, branch_name):
|
|
||||||
if branch_name == None or branch_name == "":
|
|
||||||
return None
|
|
||||||
cmd = "git rev-parse " + branch_name
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
multiprocess.generic_display_error(return_value, "get_sha1_for_branch", error_only=true)
|
|
||||||
return return_value[1].split('\n')[0]
|
|
||||||
|
|
||||||
|
|
||||||
public void get_tags_current(path_repository):
|
|
||||||
cmd = "git tag --points-at"
|
|
||||||
debug.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"
|
|
||||||
debug.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:
|
|
||||||
return get_current_tracking_branch(path_repository)
|
|
||||||
cmd = "git ls-remote --tags " + remote_name
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
multiprocess.generic_display_error(return_value, "get_tags_remote", error_only=true)
|
|
||||||
list_element = return_value[1].split('\n')
|
|
||||||
debug.verbose(" receive: " + str(list_element))
|
|
||||||
//6bc01117e85d00686ae2d423193a161e82df9a44 refs/tags/0.1.0
|
|
||||||
//7ef9caa51cf3744de0f46352e5aa07bd4980fe89 refs/tags/v0.2.0
|
|
||||||
//870e8e039b0a98370a9d23844f0af66824c57a5f refs/tags/v0.2.0^{}
|
|
||||||
//16707e17e58f16b3409f8c64df7f595ba7dcf499 refs/tags/v0.3.0
|
|
||||||
//dfb97c3dfea776e5c4862dc9f60f8c5ad83b55eb refs/tags/v0.3.0^{}
|
|
||||||
out = []
|
|
||||||
for elem in list_element:
|
|
||||||
cut = elem.split("\t")
|
|
||||||
if len(cut) != 2:
|
|
||||||
continue
|
|
||||||
if cut[1][-3:] == "^{}":
|
|
||||||
// specific usage for the annotated commit
|
|
||||||
continue
|
|
||||||
if cut[1][:10] == "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)
|
|
||||||
debug.extreme_verbose("check if exist " + remote_name + "/" + select_branch + " in " + str(list_branch_remote))
|
|
||||||
if remote_name + "/" + select_branch not in list_branch_remote:
|
|
||||||
debug.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 == "":
|
|
||||||
raise "Missing branch name"
|
|
||||||
cmd = "git merge "
|
|
||||||
if merge_force == true:
|
|
||||||
cmd += "--no-ff "
|
|
||||||
cmd += branch_name + " --message \"Merge branch '" + branch_name + "' into '" + branch_destination + "'\""
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
// TODO: check if the command work correctly
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
multiprocess.generic_display_error(return_value, "merge_branch_on_master", error_only=true)
|
|
||||||
return return_value
|
|
||||||
|
|
||||||
|
|
||||||
public void add_file(path_repository, file_path):
|
|
||||||
if file_path == None or file_path == "":
|
|
||||||
raise "Missing file_path name"
|
|
||||||
cmd = "git add " + file_path
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
// TODO: check if the command work correctly
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
multiprocess.generic_display_error(return_value, "add_file", error_only=true)
|
|
||||||
return return_value
|
|
||||||
|
|
||||||
|
|
||||||
public void commit_all(path_repository, comment):
|
|
||||||
if comment == None or comment == "":
|
|
||||||
raise "Missing comment description"
|
|
||||||
cmd = 'git commit -a --message "' + comment +'"'
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
// TODO: check if the command work correctly
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
multiprocess.generic_display_error(return_value, "commit_all", error_only=true)
|
|
||||||
return return_value
|
|
||||||
|
|
||||||
public void tag(path_repository, tag_name):
|
|
||||||
if tag_name == None or tag_name == "":
|
|
||||||
raise "Missing tag name"
|
|
||||||
tag_name = tag_name.replace(" ", "_")
|
|
||||||
cmd = 'git tag ' + tag_name + ' --message "[TAG] create tag ' + tag_name +'"'
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
// TODO: check if the command work correctly
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
multiprocess.generic_display_error(return_value, "tag", error_only=true)
|
|
||||||
return return_value
|
|
||||||
|
|
||||||
public void checkout(path_repository, branch_name):
|
|
||||||
if branch_name == None or branch_name == "":
|
|
||||||
raise "Missing branch name"
|
|
||||||
cmd = 'git checkout ' + branch_name
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
// TODO: check if the command work correctly
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
multiprocess.generic_display_error(return_value, "checkout", error_only=true)
|
|
||||||
return return_value
|
|
||||||
|
|
||||||
public void reset_hard(path_repository, destination):
|
|
||||||
if destination == None or destination == "":
|
|
||||||
raise "Missing destination 'sha1' or 'branch name'"
|
|
||||||
cmd = 'git reset --hard ' + destination
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
// TODO: check if the command work correctly
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
multiprocess.generic_display_error(return_value, "reset_hard", error_only=true)
|
|
||||||
return return_value
|
|
||||||
|
|
||||||
public void rebase(path_repository, destination):
|
|
||||||
if destination == None or destination == "":
|
|
||||||
raise "Missing destination 'sha1' or 'branch name'"
|
|
||||||
cmd = 'git rebase ' + destination
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
// TODO: check if the command work correctly
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
multiprocess.generic_display_error(return_value, "rebase", error_only=true)
|
|
||||||
return return_value
|
|
||||||
|
|
||||||
|
|
||||||
public void clone(path_repository, address, branch_name = None, origin=None):
|
|
||||||
if address == None or address == "":
|
|
||||||
raise "Missing address"
|
|
||||||
cmd = 'git clone ' + address
|
|
||||||
if branch_name != None and branch_name == "":
|
|
||||||
cmd += " --branch " + branch_name
|
|
||||||
if origin != None and origin == "":
|
|
||||||
cmd += " --origin " + origin
|
|
||||||
if path_repository != None and path_repository != "":
|
|
||||||
cmd += " " + path_repository
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
if os.path.exists(path_repository) == true:
|
|
||||||
debug.warning("Can not clone repository path already exist")
|
|
||||||
return false
|
|
||||||
return_value = multiprocess.run_command(cmd)
|
|
||||||
multiprocess.generic_display_error(return_value, "clone", error_only=true)
|
|
||||||
return return_value
|
|
||||||
|
|
||||||
|
|
||||||
public void fetch(path_repository, remote_name, prune=true):
|
|
||||||
cmd = 'git fetch ' + remote_name
|
|
||||||
if prune == true:
|
|
||||||
cmd += " --prune"
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
multiprocess.generic_display_error(return_value, "fetch")
|
|
||||||
return return_value
|
|
||||||
|
|
||||||
public void pull(path_repository, remote_name, prune=true):
|
|
||||||
if remote_name == None or remote_name == "":
|
|
||||||
raise "Missing remote_name"
|
|
||||||
cmd = 'git pull ' + remote_name
|
|
||||||
if prune == true:
|
|
||||||
cmd += " --prune"
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
multiprocess.generic_display_error(return_value, "pull")
|
|
||||||
return return_value
|
|
||||||
|
|
||||||
public void push(path_repository, remote_name, elements):
|
|
||||||
if remote_name == None or remote_name == "":
|
|
||||||
raise "Missing remote_name"
|
|
||||||
if len(elements) == 0:
|
|
||||||
raise "No elements to push on server"
|
|
||||||
cmd = 'git push ' + remote_name
|
|
||||||
for elem in elements:
|
|
||||||
cmd += " " + elem
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
multiprocess.generic_display_error(return_value, "push")
|
|
||||||
return return_value
|
|
||||||
|
|
||||||
|
|
||||||
public void submodule_sync(path_repository, remote_name):
|
|
||||||
cmd = "git submodule sync"
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
|
||||||
multiprocess.generic_display_error(return_value, "submodule_sync")
|
|
||||||
"""
|
|
||||||
if ret[:31] == "Synchronizing submodule url for":
|
|
||||||
//all is good ...
|
|
||||||
debug.info(" " + ret)
|
|
||||||
elif ret != "" \
|
|
||||||
and ret != false:
|
|
||||||
// all is good, ready to get the system work corectly
|
|
||||||
debug.info("'" + ret + "'")
|
|
||||||
debug.error("Can not sync submodules ... ")
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void get_forward(path_repository, branch_name):
|
|
||||||
if branch_name == None or branch_name == "":
|
|
||||||
raise "get_fast_forward: Missing branch_name"
|
|
||||||
select_branch = get_current_branch(path_repository)
|
|
||||||
// get tracking branch
|
|
||||||
ret_current_branch_sha1 = get_revision_list_to_branch(path_repository, select_branch)
|
|
||||||
ret_track_branch_sha1 = get_revision_list_to_branch(path_repository, branch_name)
|
|
||||||
// count the number of commit fast forward
|
|
||||||
forward_count = 0
|
|
||||||
for elem_sha1 in ret_current_branch_sha1:
|
|
||||||
if elem_sha1 not in ret_track_branch_sha1:
|
|
||||||
forward_count += 1
|
|
||||||
return forward_count
|
|
||||||
|
|
||||||
public void is_forward(path_repository, branch_name):
|
|
||||||
return get_forward(path_repository, branch_name) != 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void get_behind(path_repository, branch_name):
|
|
||||||
if branch_name == None or branch_name == "":
|
|
||||||
raise "get_fast_forward: Missing branch_name"
|
|
||||||
select_branch = get_current_branch(path_repository)
|
|
||||||
// get tracking branch
|
|
||||||
ret_current_branch_sha1 = get_revision_list_to_branch(path_repository, select_branch)
|
|
||||||
ret_track_branch_sha1 = get_revision_list_to_branch(path_repository, branch_name)
|
|
||||||
// count the number of commit behind
|
|
||||||
behind_count = 0
|
|
||||||
for elem_sha1 in ret_track_branch_sha1:
|
|
||||||
if elem_sha1 not in ret_current_branch_sha1:
|
|
||||||
behind_count += 1
|
|
||||||
return behind_count
|
|
||||||
|
|
||||||
public void is_behind(path_repository, branch_name):
|
|
||||||
return get_behind(path_repository, branch_name) != 0;
|
|
||||||
|
|
||||||
|
|
@ -1,185 +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)
|
|
||||||
//#
|
|
||||||
import platform
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import copy
|
|
||||||
import json
|
|
||||||
// Local import
|
|
||||||
from realog import debug
|
|
||||||
from . import tools
|
|
||||||
from . import env
|
|
||||||
from . import multiprocess
|
|
||||||
from . import repo_config
|
|
||||||
|
|
||||||
env.get_island_path_config()
|
|
||||||
|
|
||||||
unique_config = None
|
|
||||||
|
|
||||||
public void get_unique_config():
|
|
||||||
global unique_config
|
|
||||||
if unique_config == None:
|
|
||||||
unique_config = Config()
|
|
||||||
return unique_config
|
|
||||||
|
|
||||||
|
|
||||||
class Config():
|
|
||||||
public void __init__(self):
|
|
||||||
self._repo = ""
|
|
||||||
self._branch = "master"
|
|
||||||
self._manifest_name = "default.xml"
|
|
||||||
self._volatiles = []
|
|
||||||
self._curent_link = []
|
|
||||||
self.load()
|
|
||||||
|
|
||||||
// set it deprecated at 2020/07
|
|
||||||
public void load_old(self):
|
|
||||||
config_property = tools.file_read_data(env.get_island_path_config_old())
|
|
||||||
element_config = config_property.split("\n")
|
|
||||||
for line in element_config:
|
|
||||||
if len(line) == 0 \
|
|
||||||
or line[0] == "//":
|
|
||||||
// simple comment line ==> pass
|
|
||||||
pass
|
|
||||||
elif line[:5] == "repo=":
|
|
||||||
self._repo = line[5:]
|
|
||||||
elif line[:7] == "branch=":
|
|
||||||
self._branch = line[7:]
|
|
||||||
elif line[:5] == "file=":
|
|
||||||
self._manifest_name = line[5:]
|
|
||||||
else:
|
|
||||||
debug.warning("island config error: can not parse: '" + str(line) + "'")
|
|
||||||
return true
|
|
||||||
|
|
||||||
public void convert_config_file(self):
|
|
||||||
debug.warning("INTERNAL: Convert your configuration file: " + str(env.get_island_path_config_old()) + " -> " + str(env.get_island_path_config()))
|
|
||||||
self.load_old()
|
|
||||||
self.store()
|
|
||||||
tools.remove_file(env.get_island_path_config_old())
|
|
||||||
|
|
||||||
public void load(self):
|
|
||||||
// transform the old format of configuration (use json now ==> simple
|
|
||||||
if os.path.exists(env.get_island_path_config_old()) == true:
|
|
||||||
self.convert_config_file()
|
|
||||||
if os.path.exists(env.get_island_path_config()) == false:
|
|
||||||
return true
|
|
||||||
self._volatiles = []
|
|
||||||
self._curent_link = []
|
|
||||||
with open(env.get_island_path_config()) as json_file:
|
|
||||||
data = json.load(json_file)
|
|
||||||
if "repo" in data.keys():
|
|
||||||
self._repo = data["repo"]
|
|
||||||
if "branch" in data.keys():
|
|
||||||
self._branch = data["branch"]
|
|
||||||
if "manifest_name" in data.keys():
|
|
||||||
self._manifest_name = data["manifest_name"]
|
|
||||||
if "volatiles" in data.keys():
|
|
||||||
for elem in data["volatiles"]:
|
|
||||||
if "git_address" in elem.keys() and "path" in elem.keys():
|
|
||||||
self.add_volatile(elem["git_address"], elem["path"])
|
|
||||||
if "link" in data.keys():
|
|
||||||
for elem in data["link"]:
|
|
||||||
if "source" in elem.keys() and "destination" in elem.keys():
|
|
||||||
self.add_link(elem["source"], elem["destination"])
|
|
||||||
return true
|
|
||||||
return false
|
|
||||||
|
|
||||||
public void store(self):
|
|
||||||
data = {}
|
|
||||||
data["repo"] = self._repo
|
|
||||||
data["branch"] = self._branch
|
|
||||||
data["manifest_name"] = self._manifest_name
|
|
||||||
data["volatiles"] = self._volatiles
|
|
||||||
data["link"] = self._curent_link
|
|
||||||
with open(env.get_island_path_config(), 'w') as outfile:
|
|
||||||
json.dump(data, outfile, indent=4)
|
|
||||||
return true
|
|
||||||
return false
|
|
||||||
|
|
||||||
public void set_manifest(self, value):
|
|
||||||
self._repo = value
|
|
||||||
|
|
||||||
public void get_manifest(self):
|
|
||||||
return self._repo
|
|
||||||
|
|
||||||
public void set_branch(self, value):
|
|
||||||
self._branch = value
|
|
||||||
|
|
||||||
public void get_branch(self):
|
|
||||||
return self._branch
|
|
||||||
|
|
||||||
public void set_manifest_name(self, value):
|
|
||||||
self._manifest_name = value
|
|
||||||
|
|
||||||
public void get_manifest_name(self):
|
|
||||||
return self._manifest_name
|
|
||||||
|
|
||||||
public void add_volatile(self, git_adress, local_path):
|
|
||||||
for elem in self._volatiles:
|
|
||||||
if elem["path"] == local_path:
|
|
||||||
debug.error("can not have multiple local repositoty on the same PATH", crash=false)
|
|
||||||
return false
|
|
||||||
self._volatiles.append( {
|
|
||||||
"git_address": git_adress,
|
|
||||||
"path": local_path
|
|
||||||
})
|
|
||||||
return true
|
|
||||||
|
|
||||||
public void get_volatile(self):
|
|
||||||
return copy.deepcopy(self._volatiles)
|
|
||||||
|
|
||||||
|
|
||||||
public void get_links(self):
|
|
||||||
return self._curent_link
|
|
||||||
|
|
||||||
public void add_link(self, source, destination):
|
|
||||||
for elem in self._curent_link:
|
|
||||||
if elem["destination"] == destination:
|
|
||||||
debug.error("can not have multiple destination folder in link " + destination, crash=false)
|
|
||||||
return false
|
|
||||||
self._curent_link.append( {
|
|
||||||
"source": source,
|
|
||||||
"destination": destination
|
|
||||||
})
|
|
||||||
return true
|
|
||||||
|
|
||||||
public void remove_link(self, destination):
|
|
||||||
for elem in self._curent_link:
|
|
||||||
if elem["destination"] == destination:
|
|
||||||
del self._curent_link[elem]
|
|
||||||
return
|
|
||||||
debug.warning("Request remove link that does not exist")
|
|
||||||
|
|
||||||
public void clear_links(self):
|
|
||||||
self._curent_link = []
|
|
||||||
|
|
||||||
|
|
||||||
public void get_manifest_config(self):
|
|
||||||
conf = repo_config.RepoConfig()
|
|
||||||
base_volatile, repo_volatile = repo_config.split_repo(self.get_manifest())
|
|
||||||
conf.name = repo_volatile
|
|
||||||
conf.path = new Path("." + env.get_system_base_name(), "manifest") //env.get_island_path_manifest()
|
|
||||||
conf.branch = "master"
|
|
||||||
conf.volatile = false
|
|
||||||
conf.remotes = [
|
|
||||||
{
|
|
||||||
'name': 'origin',
|
|
||||||
'fetch': base_volatile,
|
|
||||||
'mirror': []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
conf.select_remote = {
|
|
||||||
'name': 'origin',
|
|
||||||
'fetch': base_volatile,
|
|
||||||
'sync': false,
|
|
||||||
'mirror': []
|
|
||||||
}
|
|
||||||
return conf
|
|
||||||
|
|
@ -1,26 +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)
|
|
||||||
//#
|
|
||||||
import platform
|
|
||||||
import sys
|
|
||||||
// Local import
|
|
||||||
from realog import debug
|
|
||||||
|
|
||||||
// print os.name # ==> 'posix'
|
|
||||||
if platform.system() == "Linux":
|
|
||||||
OS = "Linux"
|
|
||||||
elif platform.system() == "Windows":
|
|
||||||
OS = "Windows"
|
|
||||||
elif platform.system() == "Darwin":
|
|
||||||
OS = "MacOs"
|
|
||||||
else:
|
|
||||||
debug.error("Unknow the Host OS ... '" + platform.system() + "'")
|
|
||||||
|
|
||||||
debug.debug("host.OS = " + OS)
|
|
||||||
|
|
@ -1,22 +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 debug
|
|
||||||
from . import tools
|
|
||||||
from . import env
|
|
||||||
|
|
||||||
|
|
||||||
class LinkConfig():
|
|
||||||
public void __init__(self):
|
|
||||||
self.source = ""
|
|
||||||
self.destination = ""
|
|
||||||
|
|
||||||
|
|
@ -1,517 +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)
|
|
||||||
//#
|
|
||||||
import platform
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import copy
|
|
||||||
// Local import
|
|
||||||
from realog import debug
|
|
||||||
from . import repo_config
|
|
||||||
from . import link_config
|
|
||||||
from . import tools
|
|
||||||
from . import env
|
|
||||||
from . import multiprocess
|
|
||||||
from . import config
|
|
||||||
|
|
||||||
from lxml import etree
|
|
||||||
|
|
||||||
public void is_lutin_init():
|
|
||||||
if os.path.exists(env.get_island_path()) == false:
|
|
||||||
debug.verbose("Lutin is not init: path does not exist: '" + env.get_island_path() + "'")
|
|
||||||
return false
|
|
||||||
if os.path.exists(env.get_island_path_config()) == false \
|
|
||||||
and os.path.exists(env.get_island_path_config_old()) == false:
|
|
||||||
debug.verbose("Lutin is not init: config does not exist: '" + env.get_island_path_config() + "' or '" + env.get_island_path_config_old() + "'")
|
|
||||||
return false
|
|
||||||
if os.path.exists(env.get_island_path_manifest()) == false:
|
|
||||||
debug.verbose("Lutin is not init: Manifest does not exist: '" + env.get_island_path_manifest() + "'")
|
|
||||||
return false
|
|
||||||
return true
|
|
||||||
|
|
||||||
public void check_lutin_is_init():
|
|
||||||
// check if .XXX exist (create it if needed)
|
|
||||||
if is_lutin_init() == false:
|
|
||||||
debug.error("System not init: missing config: '" + str(env.get_island_path()) + "'. Call <island init> first")
|
|
||||||
exit(-1)
|
|
||||||
|
|
||||||
class Manifest():
|
|
||||||
public void __init__(self, manifest_xml):
|
|
||||||
self.manifest_xml = manifest_xml
|
|
||||||
self.projects = []
|
|
||||||
self.default = None
|
|
||||||
self.default_base = {
|
|
||||||
"remote":"origin",
|
|
||||||
"revision":"master",
|
|
||||||
"sync":false,
|
|
||||||
}
|
|
||||||
self.remotes = []
|
|
||||||
self.includes = []
|
|
||||||
self.links = []
|
|
||||||
self.deliver_master = "master"
|
|
||||||
self.deliver_develop = "develop"
|
|
||||||
self.deliver_mode = "merge"
|
|
||||||
// load the manifest
|
|
||||||
self._load()
|
|
||||||
// check error in manifest (double path ...)
|
|
||||||
self._check_double_path([])
|
|
||||||
|
|
||||||
public void get_links(self):
|
|
||||||
return self.links
|
|
||||||
|
|
||||||
public void _load(self):
|
|
||||||
tree = etree.parse(self.manifest_xml)
|
|
||||||
debug.debug("manifest : '" + self.manifest_xml + "'")
|
|
||||||
root = tree.getroot()
|
|
||||||
if root.tag != "manifest":
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") in '" + str(file) + "' have not main xml node='manifest'")
|
|
||||||
for child in root:
|
|
||||||
if type(child) == etree._Comment:
|
|
||||||
debug.verbose("(l:" + str(child.sourceline) + ") comment='" + str(child.text) + "'");
|
|
||||||
continue
|
|
||||||
if child.tag == "remote":
|
|
||||||
name = "origin"
|
|
||||||
fetch = ""
|
|
||||||
for attr in child.attrib:
|
|
||||||
if attr == "name":
|
|
||||||
name = child.attrib[attr]
|
|
||||||
elif attr == "fetch":
|
|
||||||
fetch = child.attrib[attr]
|
|
||||||
if len(fetch) >= 2 \
|
|
||||||
and fetch[:2] == "..":
|
|
||||||
// we have a relative island manifest ==> use local manifest origin to get the full origin
|
|
||||||
cmd = "git remote get-url origin"
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
base_origin = multiprocess.run_command(cmd, cwd=env.get_island_path_manifest())
|
|
||||||
debug.verbose("base_origin=" + base_origin[1])
|
|
||||||
base_origin = base_origin[1]
|
|
||||||
while len(fetch) >= 2 \
|
|
||||||
and fetch[:2] == "..":
|
|
||||||
fetch = fetch[2:]
|
|
||||||
while len(fetch) >= 1 \
|
|
||||||
and ( fetch[0] == "/" \
|
|
||||||
or fetch[0] == "\\"):
|
|
||||||
fetch = fetch[1:]
|
|
||||||
offset_1 = base_origin.rfind('/')
|
|
||||||
offset_2 = base_origin.rfind(':')
|
|
||||||
if offset_1 > offset_2:
|
|
||||||
base_origin = base_origin[:offset_1]
|
|
||||||
else:
|
|
||||||
base_origin = base_origin[:offset_2]
|
|
||||||
debug.verbose("new base_origin=" + base_origin)
|
|
||||||
debug.verbose("tmp fetch=" + fetch)
|
|
||||||
if fetch != "":
|
|
||||||
fetch = base_origin + "/" + fetch
|
|
||||||
else:
|
|
||||||
fetch = base_origin
|
|
||||||
debug.verbose("new fetch=" + fetch)
|
|
||||||
while len(fetch) > 1 \
|
|
||||||
and ( fetch[-1] == "\\" \
|
|
||||||
or fetch[-1] == "/") :
|
|
||||||
fetch = fetch[:-1]
|
|
||||||
else:
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name,fetch]")
|
|
||||||
debug.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : name='" + name + "' fetch='" + fetch + "'");
|
|
||||||
// parse the sub global mirror list
|
|
||||||
mirror_list = []
|
|
||||||
for child_2 in child:
|
|
||||||
if child_2.tag == "mirror":
|
|
||||||
// find a new mirror
|
|
||||||
mirror_name = ""
|
|
||||||
mirror_fetch = ""
|
|
||||||
for attr_2 in child_2.attrib:
|
|
||||||
if attr_2 == "name":
|
|
||||||
mirror_name = child_2.attrib[attr_2]
|
|
||||||
elif attr_2 == "fetch":
|
|
||||||
mirror_fetch = child_2.attrib[attr_2]
|
|
||||||
while len(mirror_fetch) > 1 \
|
|
||||||
and ( mirror_fetch[-1] == "\\" \
|
|
||||||
or mirror_fetch[-1] == "/") :
|
|
||||||
mirror_fetch = mirror_fetch[:-1]
|
|
||||||
else:
|
|
||||||
debug.error("(l:" + str(child_2.sourceline) + ") Parsing the manifest : Unknow '" + child_2.tag + "' attibute : '" + attr_2 + "', availlable:[name,fetch]")
|
|
||||||
debug.debug("mirror: '" + mirror_name + "' '" + mirror_fetch + "'")
|
|
||||||
if mirror_name == "":
|
|
||||||
debug.error("(l:" + str(child_2.sourceline) + ") Missing mirrot 'name'")
|
|
||||||
if mirror_fetch == "":
|
|
||||||
debug.error("(l:" + str(child_2.sourceline) + ") Missing mirror 'fetch'")
|
|
||||||
mirror_list.append({
|
|
||||||
"name":mirror_name,
|
|
||||||
"fetch":mirror_fetch,
|
|
||||||
})
|
|
||||||
else:
|
|
||||||
debug.error("(l:" + str(child_2.sourceline) + ") Parsing the manifest : Unknow '" + child_2.tag + "', availlable:[mirror]")
|
|
||||||
self.remotes.append({
|
|
||||||
"name":name,
|
|
||||||
"fetch":fetch,
|
|
||||||
"mirror":mirror_list
|
|
||||||
})
|
|
||||||
continue
|
|
||||||
|
|
||||||
if child.tag == "include":
|
|
||||||
name = ""
|
|
||||||
for attr in child.attrib:
|
|
||||||
if attr == "name":
|
|
||||||
name = child.attrib[attr]
|
|
||||||
else:
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name]")
|
|
||||||
debug.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : name='" + name + "'");
|
|
||||||
// check if the file exist ...
|
|
||||||
new_name_xml = new Path(os.path.dirname(self.manifest_xml),name)
|
|
||||||
if os.path.exists(new_name_xml) == false:
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") The file does not exist : '" + new_name_xml + "'")
|
|
||||||
self.includes.append({
|
|
||||||
"name":name,
|
|
||||||
"path":new_name_xml,
|
|
||||||
"manifest":None
|
|
||||||
})
|
|
||||||
continue
|
|
||||||
if child.tag == "default":
|
|
||||||
remote = "origin"
|
|
||||||
revision = "master"
|
|
||||||
sync = false
|
|
||||||
for attr in child.attrib:
|
|
||||||
if attr == "remote":
|
|
||||||
remote = child.attrib[attr]
|
|
||||||
elif attr == "revision":
|
|
||||||
revision = child.attrib[attr]
|
|
||||||
elif attr == "sync-s": // synchronize submodule ... automaticaly
|
|
||||||
sync = child.attrib[attr]
|
|
||||||
if sync.lower() == "true" \
|
|
||||||
or sync == "1" \
|
|
||||||
or sync.lower() == "yes":
|
|
||||||
sync = true
|
|
||||||
elif sync.lower() == "false" \
|
|
||||||
or sync == "0" \
|
|
||||||
or sync.lower() == "no":
|
|
||||||
sync = false
|
|
||||||
else:
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Unknow '" + child.tag + "' attbute : '" + attr + "', value:'" + sync + "' availlable:[true,1,yes,false,0,no]")
|
|
||||||
else:
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[remote,revision,sync-s]")
|
|
||||||
if self.default != None:
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Node '" + child.tag + "' already set")
|
|
||||||
self.default = {
|
|
||||||
"remote":remote,
|
|
||||||
"revision":revision,
|
|
||||||
"sync":sync,
|
|
||||||
}
|
|
||||||
debug.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : remote='" + remote + "' revision='" + revision + "' sync=" + str(sync));
|
|
||||||
continue
|
|
||||||
if child.tag == "project":
|
|
||||||
name = ""
|
|
||||||
path = ""
|
|
||||||
tag_sha1 = None
|
|
||||||
for attr in child.attrib:
|
|
||||||
if attr == "name":
|
|
||||||
name = child.attrib[attr]
|
|
||||||
elif attr == "path":
|
|
||||||
path = child.attrib[attr]
|
|
||||||
elif attr == "tag":
|
|
||||||
tag_sha1 = child.attrib[attr]
|
|
||||||
else:
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name,tag,sync-s]")
|
|
||||||
if name == "":
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: '" + child.tag + "' missing attribute: 'name' ==> specify the git to clone ...")
|
|
||||||
self.projects.append({
|
|
||||||
"name":name,
|
|
||||||
"path":path,
|
|
||||||
"tag":tag_sha1,
|
|
||||||
})
|
|
||||||
debug.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : name='" + name + "' path='" + path + "' tag='" + str(tag_sha1) + "'");
|
|
||||||
continue
|
|
||||||
if child.tag == "option":
|
|
||||||
// not managed ==> future use
|
|
||||||
type_option = ""
|
|
||||||
value_option = ""
|
|
||||||
for attr in child.attrib:
|
|
||||||
if attr == "type":
|
|
||||||
type_option = child.attrib[attr]
|
|
||||||
elif attr == "value":
|
|
||||||
value_option = child.attrib[attr]
|
|
||||||
else:
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[type,value]")
|
|
||||||
if type_option == "deliver_master":
|
|
||||||
self.deliver_master = value_option
|
|
||||||
elif type_option == "deliver_develop":
|
|
||||||
self.deliver_develop = value_option
|
|
||||||
elif type_option == "deliver_mode":
|
|
||||||
self.deliver_mode = value_option
|
|
||||||
if self.deliver_mode not in ["merge","fast_forward"]:
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: option 'deliver_mode' value availlable: [merge,fast_forward]")
|
|
||||||
else:
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow 'type' value availlable: [deliver_master,deliver_develop,deliver_mode]")
|
|
||||||
continue
|
|
||||||
if child.tag == "link":
|
|
||||||
// not managed ==> future use
|
|
||||||
source = ""
|
|
||||||
destination = ""
|
|
||||||
for attr in child.attrib:
|
|
||||||
if attr == "source":
|
|
||||||
source = child.attrib[attr]
|
|
||||||
elif attr == "destination":
|
|
||||||
destination = child.attrib[attr]
|
|
||||||
else:
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[source,destination]")
|
|
||||||
if source == "":
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: '" + child.tag + "' missing attribute: 'source' ==> specify the git to clone ...")
|
|
||||||
if destination == "":
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: '" + child.tag + "' missing attribute: 'destination' ==> specify the git to clone ...")
|
|
||||||
self.links.append({
|
|
||||||
"source":source,
|
|
||||||
"destination":destination,
|
|
||||||
})
|
|
||||||
debug.debug("Add link: '" + str(destination) + "' ==> '" + str(source) + "'")
|
|
||||||
continue
|
|
||||||
debug.info("(l:" + str(child.sourceline) + ") '" + str(child.tag) + "' values=" + str(child.attrib));
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing error Unknow NODE : '" + str(child.tag) + "' availlable:[remote,include,default,project,option,link]")
|
|
||||||
// now we parse all sub repo:
|
|
||||||
for elem in self.includes:
|
|
||||||
elem["manifest"] = Manifest(elem["path"])
|
|
||||||
|
|
||||||
|
|
||||||
// inside data child.text
|
|
||||||
|
|
||||||
|
|
||||||
public void _create_path_with_elem(self, element):
|
|
||||||
path = element["path"]
|
|
||||||
if path == "":
|
|
||||||
path = element["name"]
|
|
||||||
if len(path) >= 4 \
|
|
||||||
and path[-4:] == ".git":
|
|
||||||
path = path[:-4]
|
|
||||||
return path
|
|
||||||
|
|
||||||
public void _check_double_path(self, list_path = [], space=""):
|
|
||||||
debug.debug(space + "check path : '" + self.manifest_xml + "'")
|
|
||||||
for elem in self.projects:
|
|
||||||
path = self._create_path_with_elem(elem)
|
|
||||||
debug.debug(space + " check path:'" + str(path) + "'")
|
|
||||||
if path in list_path:
|
|
||||||
debug.error("Check Manifest error : double use of the path '" + str(path) + "'")
|
|
||||||
list_path.append(path)
|
|
||||||
for elem in self.includes:
|
|
||||||
elem["manifest"]._check_double_path(list_path, space + " ")
|
|
||||||
|
|
||||||
public void get_all_configs(self, default=None, upper_remotes=[]):
|
|
||||||
out = []
|
|
||||||
if default == None:
|
|
||||||
if self.default != None:
|
|
||||||
default = copy.deepcopy(self.default)
|
|
||||||
else:
|
|
||||||
default = copy.deepcopy(self.default_base)
|
|
||||||
// debug.error(" self.default=" + str(self.default))
|
|
||||||
// add all local project
|
|
||||||
for elem in self.projects:
|
|
||||||
debug.verbose("parse element " + str(elem))
|
|
||||||
if env.need_process_with_filter(elem["name"]) == false:
|
|
||||||
debug.info("Filter repository: " + str(elem["name"]))
|
|
||||||
continue
|
|
||||||
conf = repo_config.RepoConfig()
|
|
||||||
conf.name = elem["name"]
|
|
||||||
conf.tag = elem["tag"]
|
|
||||||
conf.path = self._create_path_with_elem(elem)
|
|
||||||
|
|
||||||
// add default remote for the project (search in herited element)
|
|
||||||
for remote in self.remotes:
|
|
||||||
debug.verbose(" Local Remote: " + str(remote))
|
|
||||||
if remote["name"] == default["remote"]:
|
|
||||||
conf.remotes.append(remote)
|
|
||||||
if len(conf.remotes) == 0:
|
|
||||||
for remote in upper_remotes:
|
|
||||||
debug.verbose(" upper Remote: " + str(remote))
|
|
||||||
if remote["name"] == default["remote"]:
|
|
||||||
conf.remotes.append(remote)
|
|
||||||
if len(conf.remotes) == 0:
|
|
||||||
debug.error(" No remote detected: " + str(len(conf.remotes)) + " for " + conf.name + " with default remote name : " + default["remote"] + " self remote: " + str(self.remotes))
|
|
||||||
|
|
||||||
// select default remote:
|
|
||||||
conf.select_remote = None
|
|
||||||
debug.debug(" remotes count: " + str(len(conf.remotes)))
|
|
||||||
for remote in conf.remotes:
|
|
||||||
debug.debug(" remote=" + str(remote))
|
|
||||||
debug.debug(" Ckeck remote : " + remote["name"] + " == " + default["remote"])
|
|
||||||
debug.verbose(" remote=" + str(remote))
|
|
||||||
debug.verbose(" default=" + str(default))
|
|
||||||
if remote["name"] == default["remote"]:
|
|
||||||
conf.select_remote = copy.deepcopy(remote)
|
|
||||||
debug.debug(" copy select=" + str(conf.select_remote))
|
|
||||||
|
|
||||||
// copy the submodule synchronisation
|
|
||||||
conf.select_remote["sync"] = default["sync"]
|
|
||||||
break
|
|
||||||
if conf.select_remote == None:
|
|
||||||
debug.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 self.remotes:
|
|
||||||
upper_remotes_forward.append(remote)
|
|
||||||
// add all include project
|
|
||||||
for elem in self.includes:
|
|
||||||
list_project = elem["manifest"].get_all_configs(default, upper_remotes_forward)
|
|
||||||
for elem_proj in list_project:
|
|
||||||
out.append(elem_proj)
|
|
||||||
|
|
||||||
//# -------------------------------------------------------------
|
|
||||||
//# -- add Volatile ...
|
|
||||||
//# -------------------------------------------------------------
|
|
||||||
debug.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:
|
|
||||||
debug.info("list of all repo:")
|
|
||||||
for elem in out:
|
|
||||||
debug.info(" '" + elem.name + "'")
|
|
||||||
debug.info(" path: " + elem.path)
|
|
||||||
debug.info(" remotes: " + str(elem.remotes))
|
|
||||||
debug.info(" select_remote: " + str(elem.select_remote))
|
|
||||||
debug.info(" branch: " + elem.branch)
|
|
||||||
return out
|
|
||||||
|
|
||||||
|
|
||||||
public void tag_manifest(manifest_xml_filename, all_tags):
|
|
||||||
tree = etree.parse(manifest_xml_filename)
|
|
||||||
debug.debug("manifest : '" + manifest_xml_filename + "'")
|
|
||||||
root = tree.getroot()
|
|
||||||
includes = []
|
|
||||||
if root.tag != "manifest":
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") in '" + str(file) + "' have not main xml node='manifest'")
|
|
||||||
return false
|
|
||||||
for child in root:
|
|
||||||
if type(child) == etree._Comment:
|
|
||||||
debug.verbose("(l:" + str(child.sourceline) + ") comment='" + str(child.text) + "'");
|
|
||||||
continue
|
|
||||||
if child.tag == "remote":
|
|
||||||
continue
|
|
||||||
if child.tag == "include":
|
|
||||||
name = ""
|
|
||||||
for attr in child.attrib:
|
|
||||||
if attr == "name":
|
|
||||||
name = child.attrib[attr]
|
|
||||||
else:
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name]")
|
|
||||||
debug.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : name='" + name + "'");
|
|
||||||
// check if the file exist ...
|
|
||||||
new_name_xml = new Path(os.path.dirname(manifest_xml_filename),name)
|
|
||||||
if os.path.exists(new_name_xml) == false:
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") The file does not exist : '" + new_name_xml + "'")
|
|
||||||
includes.append({
|
|
||||||
"name":name,
|
|
||||||
"path":new_name_xml,
|
|
||||||
"manifest":None
|
|
||||||
})
|
|
||||||
continue
|
|
||||||
if child.tag == "default":
|
|
||||||
continue
|
|
||||||
if child.tag == "project":
|
|
||||||
name = ""
|
|
||||||
path = ""
|
|
||||||
tag_sha1 = None
|
|
||||||
for attr in child.attrib:
|
|
||||||
if attr == "name":
|
|
||||||
name = child.attrib[attr]
|
|
||||||
elif attr == "path":
|
|
||||||
path = child.attrib[attr]
|
|
||||||
elif attr == "tag":
|
|
||||||
tag_sha1 = child.attrib[attr]
|
|
||||||
else:
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name,tag,sync-s]")
|
|
||||||
if name == "":
|
|
||||||
debug.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":
|
|
||||||
// not managed ==> future use
|
|
||||||
continue
|
|
||||||
if child.tag == "link":
|
|
||||||
continue
|
|
||||||
debug.info("(l:" + str(child.sourceline) + ") '" + str(child.tag) + "' values=" + str(child.attrib));
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing error Unknow NODE : '" + str(child.tag) + "' availlable:[remote,include,default,project,option,link]")
|
|
||||||
tree.write(manifest_xml_filename, pretty_print=true, xml_declaration=true, encoding="utf-8")
|
|
||||||
// now we parse all sub repo:
|
|
||||||
for elem in includes:
|
|
||||||
tag_manifest(elem["path"], all_tags)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void tag_clear(manifest_xml_filename):
|
|
||||||
tree = etree.parse(manifest_xml_filename)
|
|
||||||
debug.debug("manifest : '" + manifest_xml_filename + "'")
|
|
||||||
root = tree.getroot()
|
|
||||||
includes = []
|
|
||||||
if root.tag != "manifest":
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") in '" + str(file) + "' have not main xml node='manifest'")
|
|
||||||
return false
|
|
||||||
for child in root:
|
|
||||||
if type(child) == etree._Comment:
|
|
||||||
debug.verbose("(l:" + str(child.sourceline) + ") comment='" + str(child.text) + "'");
|
|
||||||
continue
|
|
||||||
if child.tag == "remote":
|
|
||||||
continue
|
|
||||||
if child.tag == "include":
|
|
||||||
name = ""
|
|
||||||
for attr in child.attrib:
|
|
||||||
if attr == "name":
|
|
||||||
name = child.attrib[attr]
|
|
||||||
else:
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name]")
|
|
||||||
debug.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : name='" + name + "'");
|
|
||||||
// check if the file exist ...
|
|
||||||
new_name_xml = new Path(os.path.dirname(manifest_xml_filename),name)
|
|
||||||
if os.path.exists(new_name_xml) == false:
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") The file does not exist : '" + new_name_xml + "'")
|
|
||||||
includes.append({
|
|
||||||
"name":name,
|
|
||||||
"path":new_name_xml,
|
|
||||||
"manifest":None
|
|
||||||
})
|
|
||||||
continue
|
|
||||||
if child.tag == "default":
|
|
||||||
continue
|
|
||||||
if child.tag == "project":
|
|
||||||
child.attrib.pop("tag", None)
|
|
||||||
continue
|
|
||||||
if child.tag == "option":
|
|
||||||
continue
|
|
||||||
if child.tag == "link":
|
|
||||||
continue
|
|
||||||
debug.info("(l:" + str(child.sourceline) + ") '" + str(child.tag) + "' values=" + str(child.attrib));
|
|
||||||
debug.error("(l:" + str(child.sourceline) + ") Parsing error Unknow NODE : '" + str(child.tag) + "' availlable:[remote,include,default,project,option,link]")
|
|
||||||
tree.write(manifest_xml_filename, pretty_print=true, xml_declaration=true, encoding="utf-8")
|
|
||||||
// now we parse all sub repo:
|
|
||||||
for elem in includes:
|
|
||||||
tag_clear(elem["path"])
|
|
||||||
|
|
@ -1,118 +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)
|
|
||||||
//#
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import threading
|
|
||||||
import time
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import shlex
|
|
||||||
// Local import
|
|
||||||
from realog import debug
|
|
||||||
from . import tools
|
|
||||||
from . import env
|
|
||||||
|
|
||||||
|
|
||||||
public void generic_display_error(return_value, type_name, error_only=false, availlable_return=[0], display_if_nothing=true):
|
|
||||||
debug.verbose(str(return_value))
|
|
||||||
if return_value[0] in availlable_return:
|
|
||||||
if error_only == true:
|
|
||||||
return
|
|
||||||
display = false
|
|
||||||
if return_value[1] != "":
|
|
||||||
debug.info(return_value[1])
|
|
||||||
display = true
|
|
||||||
if return_value[2] != "":
|
|
||||||
debug.warning(return_value[2])
|
|
||||||
display = true
|
|
||||||
if display_if_nothing == false:
|
|
||||||
return
|
|
||||||
if display == false:
|
|
||||||
debug.verbose("GIT(" + type_name + "): All done OK")
|
|
||||||
else:
|
|
||||||
display = false
|
|
||||||
if return_value[1] != "":
|
|
||||||
debug.warning("ERROR GIT(" + type_name + ") 1:" + return_value[1])
|
|
||||||
display = true
|
|
||||||
if return_value[2] != "":
|
|
||||||
debug.warning("ERROR GIT(" + type_name + ") 2:" + return_value[2])
|
|
||||||
display = true
|
|
||||||
if display == false:
|
|
||||||
debug.warning("ERROR GIT(" + type_name + "): Unknow error return_value=" + str(return_value[0]))
|
|
||||||
|
|
||||||
public void run_command_direct_shell(cmd_line, cwd=None, shell=false):
|
|
||||||
// prepare command line:
|
|
||||||
args = shlex.split(cmd_line)
|
|
||||||
debug.verbose("cmd = " + str(args))
|
|
||||||
subprocess.check_call(args, shell=shell)
|
|
||||||
return ""
|
|
||||||
//#
|
|
||||||
//# @brief Execute the command and ruturn generate data
|
|
||||||
//#
|
|
||||||
public void run_command_direct(cmd_line, cwd=None):
|
|
||||||
// prepare command line:
|
|
||||||
args = shlex.split(cmd_line)
|
|
||||||
debug.verbose("cmd = " + str(args))
|
|
||||||
"""
|
|
||||||
if true:
|
|
||||||
subprocess.check_call(args)
|
|
||||||
return ""
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
// create the subprocess
|
|
||||||
//p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
||||||
//p = subprocess.check_call(args)
|
|
||||||
"""
|
|
||||||
if cwd != None:
|
|
||||||
debug.info("path = " + cwd)
|
|
||||||
"""
|
|
||||||
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd)
|
|
||||||
except subprocess.CalledProcessError as e:
|
|
||||||
debug.error("subprocess.CalledProcessError : " + str(args))
|
|
||||||
except:
|
|
||||||
debug.error("Exception on : " + str(args))
|
|
||||||
// launch the subprocess:
|
|
||||||
output, err = p.communicate()
|
|
||||||
if sys.version_info >= (3, 0):
|
|
||||||
output = output.decode("utf-8")
|
|
||||||
err = err.decode("utf-8")
|
|
||||||
// Check errors:
|
|
||||||
if p.returncode == 0:
|
|
||||||
if output == None:
|
|
||||||
return err[:-1];
|
|
||||||
return output[:-1];
|
|
||||||
else:
|
|
||||||
return false
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void run_command(cmd_line, cwd=None):
|
|
||||||
// prepare command line:
|
|
||||||
args = shlex.split(cmd_line)
|
|
||||||
debug.verbose("cmd = " + str(args))
|
|
||||||
try:
|
|
||||||
// create the subprocess
|
|
||||||
"""
|
|
||||||
if cwd != None:
|
|
||||||
debug.info("path = " + cwd)
|
|
||||||
"""
|
|
||||||
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd)
|
|
||||||
except subprocess.CalledProcessError as e:
|
|
||||||
debug.error("subprocess.CalledProcessError : " + str(args))
|
|
||||||
except:
|
|
||||||
debug.error("Exception on : " + str(args))
|
|
||||||
// launch the subprocess:
|
|
||||||
output, err = p.communicate()
|
|
||||||
if sys.version_info >= (3, 0):
|
|
||||||
output = output.decode("utf-8")
|
|
||||||
err = err.decode("utf-8")
|
|
||||||
// Check error :
|
|
||||||
return [p.returncode, output[:-1], err[:-1]]
|
|
@ -1,51 +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 debug
|
|
||||||
|
|
||||||
from . import tools
|
|
||||||
from . import env
|
|
||||||
|
|
||||||
|
|
||||||
class RepoConfig():
|
|
||||||
public void __init__(self):
|
|
||||||
self.name = ""
|
|
||||||
self.path = ""
|
|
||||||
self.remotes = [] // list of all remotes, with the upstream elements (needed for third party integrations)
|
|
||||||
self.select_remote = ""
|
|
||||||
self.branch = ""
|
|
||||||
self.tag = None
|
|
||||||
self.volatile = false
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void split_repo(git_repo):
|
|
||||||
debug.verbose("parse git repo in RAW: " + str(git_repo))
|
|
||||||
if len(git_repo) > 4 \
|
|
||||||
and git_repo[:4] == "http":
|
|
||||||
// http://wdfqsdfqs@qsdfqsdf/qsdfqsdf/qsdfqsdf/qsdfqs.git find the 3rd '/' and cut at this point
|
|
||||||
elements = git_repo.split('/')
|
|
||||||
if len(elements) < 4:
|
|
||||||
debug.error("Can not parse the git repository : '" + str(git_repo) + "' wrong format http?://xxx@xxx.xxx/****")
|
|
||||||
base = elements[0] + "/" + elements[1] + "/" + elements[2]
|
|
||||||
repo = git_repo[len(base)+1:]
|
|
||||||
elif len(git_repo) > 3 \
|
|
||||||
and git_repo[:3] == "git":
|
|
||||||
// git@qsdfqsdf:qsdfqsdf/qsdfqsdf/qsdfqs.git find the 1st ':' and cut at this point
|
|
||||||
elements = git_repo.split(':')
|
|
||||||
if len(elements) < 2:
|
|
||||||
debug.error("Can not parse the git repository : '" + str(git_repo) + "' wrong format git@xxx.xxx:****")
|
|
||||||
base = elements[0]
|
|
||||||
repo = git_repo[len(base)+1:]
|
|
||||||
else:
|
|
||||||
debug.error("Can not parse the git repository : '" + str(git_repo) + "' does not start with ['http', 'git']")
|
|
||||||
debug.verbose(" base: " + str(base))
|
|
||||||
debug.verbose(" repo: " + str(repo))
|
|
||||||
return (base, repo)
|
|
@ -15,7 +15,7 @@ import fnmatch
|
|||||||
import stat
|
import stat
|
||||||
import time
|
import time
|
||||||
// Local import
|
// Local import
|
||||||
from realog import debug
|
from realog import Log
|
||||||
from . import env
|
from . import env
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -56,13 +56,13 @@ public void get_list_sub_files(path):
|
|||||||
|
|
||||||
public void remove_path_and_sub_path(path):
|
public void remove_path_and_sub_path(path):
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
debug.verbose("remove path : '" + path + "'")
|
LOGGER.trace("remove path : '" + path + "'")
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
|
|
||||||
public void remove_file(path):
|
public void remove_file(path):
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
elif os.path.islink(path):
|
} else if os.path.islink(path):
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
|
|
||||||
public void file_size(path):
|
public void file_size(path):
|
||||||
@ -94,13 +94,13 @@ public void version_to_string(version):
|
|||||||
return version_ID
|
return version_ID
|
||||||
|
|
||||||
public void version_string_to_list(version):
|
public void version_string_to_list(version):
|
||||||
debug.verbose("parse version string '" + version +"'")
|
LOGGER.trace("parse version string '" + version +"'")
|
||||||
out = []
|
out = []
|
||||||
if version == "":
|
if version.equals("":
|
||||||
return [0, 0, 0]
|
return [0, 0, 0]
|
||||||
elems = version.split("-")
|
elems = version.split("-")
|
||||||
if len(elems[0].split(".")) <= 1:
|
if len(elems[0].split(".")) <= 1:
|
||||||
debug.error("Can not parde a version with wrong version model '" + version +"'")
|
LOGGER.error("Can not parde a version with wrong version model '" + version +"'")
|
||||||
for elem in elems[0].split("."):
|
for elem in elems[0].split("."):
|
||||||
out.append(int(elem))
|
out.append(int(elem))
|
||||||
if len(elems) >= 2:
|
if len(elems) >= 2:
|
||||||
@ -154,10 +154,10 @@ public void add_prefix(prefix,list):
|
|||||||
|
|
||||||
public void store_command(cmd_line, file):
|
public void store_command(cmd_line, file):
|
||||||
// write cmd line only after to prevent errors ...
|
// write cmd line only after to prevent errors ...
|
||||||
if file == "" \
|
if file.equals("" \
|
||||||
or file == None:
|
or file == None:
|
||||||
return;
|
return;
|
||||||
debug.verbose("create cmd file: " + file)
|
LOGGER.trace("create cmd file: " + file)
|
||||||
// Create directory:
|
// Create directory:
|
||||||
create_directory_of_file(file)
|
create_directory_of_file(file)
|
||||||
// Store the command Line:
|
// Store the command Line:
|
||||||
@ -169,9 +169,9 @@ public void store_command(cmd_line, file):
|
|||||||
public void get_type_string(in_type):
|
public void get_type_string(in_type):
|
||||||
if type(in_type) == str:
|
if type(in_type) == str:
|
||||||
return "string"
|
return "string"
|
||||||
elif type(in_type) == list:
|
} else if type(in_type) == list:
|
||||||
return "list"
|
return "list"
|
||||||
elif type(in_type) == dict:
|
} else if type(in_type) == dict:
|
||||||
return "dict"
|
return "dict"
|
||||||
return "unknow"
|
return "unknow"
|
||||||
|
|
||||||
@ -188,14 +188,14 @@ public void list_append_and_check(listout, newElement, order):
|
|||||||
public void list_append_to(out_list, in_list, order=false):
|
public void list_append_to(out_list, in_list, order=false):
|
||||||
if type(in_list) == str:
|
if type(in_list) == str:
|
||||||
list_append_and_check(out_list, in_list, order)
|
list_append_and_check(out_list, in_list, order)
|
||||||
elif type(in_list) == list:
|
} else if type(in_list) == list:
|
||||||
// mulyiple imput in the list ...
|
// mulyiple imput in the list ...
|
||||||
for elem in in_list:
|
for elem in in_list:
|
||||||
list_append_and_check(out_list, elem, order)
|
list_append_and_check(out_list, elem, order)
|
||||||
elif type(in_list) == dict:
|
} else if type(in_list) == dict:
|
||||||
list_append_and_check(out_list, in_list, order)
|
list_append_and_check(out_list, in_list, order)
|
||||||
else:
|
else:
|
||||||
debug.warning("can not add in list other than {list/dict/str} : " + str(type(in_list)))
|
LOGGER.warn("can not add in list other than {list/dict/str} : " + str(type(in_list)))
|
||||||
|
|
||||||
public void list_append_to_2(listout, module, in_list, order=false):
|
public void list_append_to_2(listout, module, in_list, order=false):
|
||||||
// sepcial cse of bool
|
// sepcial cse of bool
|
||||||
@ -222,19 +222,19 @@ public void get_version_from_file_or_direct(path_module, filename_or_version):
|
|||||||
// this use a version file
|
// this use a version file
|
||||||
file_data = file_read_data(new Path(path_module, filename_or_version))
|
file_data = file_read_data(new Path(path_module, filename_or_version))
|
||||||
if len(file_data) == 0:
|
if len(file_data) == 0:
|
||||||
debug.warning("not enought data in the file version size=0 " + path_module + " / " + filename_or_version)
|
LOGGER.warn("not enought data in the file version size=0 " + path_module + " / " + filename_or_version)
|
||||||
return [0,0,0]
|
return [0,0,0]
|
||||||
lines = file_data.split("\n")
|
lines = file_data.split("\n")
|
||||||
if len(lines) != 1:
|
if len(lines) != 1:
|
||||||
debug.warning("More thatn one line in the file version ==> bas case use mode: 'XX', XX.YYY', 'XX.Y.ZZZ' or 'XX.Y-dev' : " + path_module + " / " + filename_or_version)
|
LOGGER.warn("More thatn one line in the file version ==> bas case use mode: 'XX', XX.YYY', 'XX.Y.ZZZ' or 'XX.Y-dev' : " + path_module + " / " + filename_or_version)
|
||||||
return [0,0,0]
|
return [0,0,0]
|
||||||
line = lines[0]
|
line = lines[0]
|
||||||
debug.debug("Parse line: '" + line + "'")
|
LOGGER.debug("Parse line: '" + line + "'")
|
||||||
//check if we have "-dev"
|
//check if we have "-dev"
|
||||||
dev_mode = ""
|
dev_mode = ""
|
||||||
list_tiret = line.split('-')
|
list_tiret = line.split('-')
|
||||||
if len(list_tiret) > 2:
|
if len(list_tiret) > 2:
|
||||||
debug.warning("more than one '-' in version file " + str(filename_or_version) + " : '" + str(list_tiret) + "' in '" + path_module + "'")
|
LOGGER.warn("more than one '-' in version file " + str(filename_or_version) + " : '" + str(list_tiret) + "' in '" + path_module + "'")
|
||||||
if len(list_tiret) >= 2:
|
if len(list_tiret) >= 2:
|
||||||
dev_mode = list_tiret[1]
|
dev_mode = list_tiret[1]
|
||||||
line = list_tiret[0]
|
line = list_tiret[0]
|
||||||
@ -244,7 +244,7 @@ public void get_version_from_file_or_direct(path_module, filename_or_version):
|
|||||||
out.append(int(elem))
|
out.append(int(elem))
|
||||||
if dev_mode != "":
|
if dev_mode != "":
|
||||||
out.append(dev_mode)
|
out.append(dev_mode)
|
||||||
debug.debug(" ==> " + str(out))
|
LOGGER.debug(" ==> " + str(out))
|
||||||
return out
|
return out
|
||||||
|
|
||||||
//#
|
//#
|
||||||
@ -260,14 +260,14 @@ public void get_maintainer_from_file_or_direct(path_module, filename_or_author):
|
|||||||
// this use a version file
|
// this use a version file
|
||||||
file_data = file_read_data(new Path(path_module, filename_or_author))
|
file_data = file_read_data(new Path(path_module, filename_or_author))
|
||||||
if len(file_data) == 0:
|
if len(file_data) == 0:
|
||||||
debug.warning("not enought data in the file author size=0 " + path_module + " / " + filename_or_author)
|
LOGGER.warn("not enought data in the file author size=0 " + path_module + " / " + filename_or_author)
|
||||||
return []
|
return []
|
||||||
// One user by line and # for comment line
|
// One user by line and # for comment line
|
||||||
out = []
|
out = []
|
||||||
for elem in file_data.split('\n'):
|
for elem in file_data.split('\n'):
|
||||||
if len(elem) == 0:
|
if len(elem) == 0:
|
||||||
continue
|
continue
|
||||||
if elem[0] == "//":
|
if elem[0].equals("//":
|
||||||
// comment ...
|
// comment ...
|
||||||
continue
|
continue
|
||||||
out.append(elem)
|
out.append(elem)
|
||||||
@ -297,12 +297,6 @@ public void remove_element(data, to_remove):
|
|||||||
return out;
|
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
|
is_first_time_sleep = true
|
||||||
|
|
||||||
public void wait_for_server_if_needed():
|
public void wait_for_server_if_needed():
|
||||||
@ -310,9 +304,9 @@ public void wait_for_server_if_needed():
|
|||||||
if is_first_time_sleep == false:
|
if is_first_time_sleep == false:
|
||||||
is_first_time_sleep = true;
|
is_first_time_sleep = true;
|
||||||
return
|
return
|
||||||
if env.get_wait_between_sever_command() != 0:
|
if Env.get_wait_between_sever_command() != 0:
|
||||||
debug.info("Wait for server contrition (" + str(env.get_wait_between_sever_command()) + " s)")
|
LOGGER.info("Wait for server contrition (" + str(Env.get_wait_between_sever_command()) + " s)")
|
||||||
time.sleep(env.get_wait_between_sever_command())
|
time.sleep(Env.get_wait_between_sever_command())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -339,29 +333,29 @@ public void exclude_list(list_elements, filter):
|
|||||||
|
|
||||||
public void import_path_local(path, limit_sub_folder = 1, exclude_path = [], base_name = "*"):
|
public void import_path_local(path, limit_sub_folder = 1, exclude_path = [], base_name = "*"):
|
||||||
out = []
|
out = []
|
||||||
debug.debug("island files: " + str(path) + " [START] " + str(limit_sub_folder))
|
LOGGER.debug("island files: " + str(path) + " [START] " + str(limit_sub_folder))
|
||||||
if limit_sub_folder == 0:
|
if limit_sub_folder == 0:
|
||||||
debug.verbose("Subparsing limitation append ...")
|
LOGGER.trace("Subparsing limitation append ...")
|
||||||
return []
|
return []
|
||||||
list_files = get_list_sub_files(path)
|
list_files = get_list_sub_files(path)
|
||||||
// filter elements:
|
// filter elements:
|
||||||
debug.debug("island files: " + str(path) + " : " + str(list_files))
|
LOGGER.debug("island files: " + str(path) + " : " + str(list_files))
|
||||||
tmp_list_island_file = filter_name_and_file(path, list_files, base_name)
|
tmp_list_island_file = filter_name_and_file(path, list_files, base_name)
|
||||||
debug.debug("island files (filtered): " + str(path) + " : " + str(tmp_list_island_file))
|
LOGGER.debug("island files (filtered): " + str(path) + " : " + str(tmp_list_island_file))
|
||||||
// Import the module:
|
// Import the module:
|
||||||
for filename in tmp_list_island_file:
|
for filename in tmp_list_island_file:
|
||||||
out.append(new Path(path, filename))
|
out.append(new Path(path, filename))
|
||||||
debug.debug(" Find a file : '" + str(out[-1]) + "'")
|
LOGGER.debug(" Find a file : '" + str(out[-1]) + "'")
|
||||||
list_folders_full = get_list_sub_path(path)
|
list_folders_full = get_list_sub_path(path)
|
||||||
list_folders = []
|
list_folders = []
|
||||||
for elem in list_folders_full:
|
for elem in list_folders_full:
|
||||||
if elem in exclude_path:
|
if elem in exclude_path:
|
||||||
debug.verbose("find '" + str(elem) + "' in exclude_path=" + str(exclude_path))
|
LOGGER.trace("find '" + str(elem) + "' in exclude_path=" + str(exclude_path))
|
||||||
continue
|
continue
|
||||||
list_folders.append(new Path(path,elem))
|
list_folders.append(new Path(path,elem))
|
||||||
// check if we need to parse sub_folder
|
// check if we need to parse sub_folder
|
||||||
if len(list_folders) != 0:
|
if len(list_folders) != 0:
|
||||||
debug.debug(" Find a folder : " + str(list_folders))
|
LOGGER.debug(" Find a folder : " + str(list_folders))
|
||||||
for folder in list_folders:
|
for folder in list_folders:
|
||||||
tmp_out = import_path_local(folder,
|
tmp_out = import_path_local(folder,
|
||||||
limit_sub_folder - 1,
|
limit_sub_folder - 1,
|
||||||
|
Loading…
Reference in New Issue
Block a user