Mercurial > hg > icedrobot > ika
changeset 14:8a417ad3e271
Sanitise output. Contributed by Giulio Franco.
author | Mario Torre <neugens.limasoftware@gmail.com> |
---|---|
date | Fri, 01 Apr 2011 00:37:47 +0200 |
parents | ffeb5d49c3f2 |
children | e3ccb9fa6a64 |
files | src/main/java/org/icedrobot/ika/runtime/IkaRuntime.java src/main/java/org/icedrobot/ika/runtime/scm/GITRepository.java src/main/java/org/icedrobot/ika/runtime/scm/HGRepository.java src/main/resources/org/icedrobot/ika/plugins/borg/repositories.properties src/main/resources/org/icedrobot/ika/plugins/borg/subrepositories.properties |
diffstat | 5 files changed, 26 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/org/icedrobot/ika/runtime/IkaRuntime.java Tue Mar 29 23:54:31 2011 +0200 +++ b/src/main/java/org/icedrobot/ika/runtime/IkaRuntime.java Fri Apr 01 00:37:47 2011 +0200 @@ -22,6 +22,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.util.Arrays; import java.util.logging.Level; import java.util.logging.Logger; import org.icedrobot.ika.plugins.IkaPluginException; @@ -31,10 +32,15 @@ /** * Executes the given command on the passed path. */ - public static void exec(String command, File path) { + public static void exec(File path, String... command) { try { - System.err.println("command: " + command + ", path: " + path); - Process process = Runtime.getRuntime().exec(command, null, path); + System.err.println("command: " + Arrays.toString(command) + + ", path: " + path); + + ProcessBuilder pb = new ProcessBuilder(command); + pb.redirectErrorStream(true); + pb.directory(path); + Process process = pb.start(); InputStream is = process.getInputStream(); InputStreamReader reader = new InputStreamReader(is); @@ -48,8 +54,8 @@ } catch (IOException ex) { Logger.getLogger(IkaRuntime.class.getName()). - log(Level.SEVERE, "cannot execute: " + command, ex); - throw new IkaPluginException("cannot execute: " + command, ex); + log(Level.SEVERE, "cannot execute: " + Arrays.toString(command), ex); + throw new IkaPluginException("cannot execute: " + Arrays.toString(command), ex); } } }
--- a/src/main/java/org/icedrobot/ika/runtime/scm/GITRepository.java Tue Mar 29 23:54:31 2011 +0200 +++ b/src/main/java/org/icedrobot/ika/runtime/scm/GITRepository.java Fri Apr 01 00:37:47 2011 +0200 @@ -60,9 +60,9 @@ */ @Override public void makeClone() { - String command = "git clone -b " + getBranch() + " " + remotePath; + String command = "git clone --progress -b " + getBranch() + " " + remotePath; System.err.println(command); - IkaRuntime.exec(command, getFullPath()); + IkaRuntime.exec(getFullPath(), "git", "clone", "--progress", "-b", getBranch(), remotePath); } @@ -74,23 +74,23 @@ String command = "git init ."; System.err.println(command); - IkaRuntime.exec(command, getFullPath()); + IkaRuntime.exec(getFullPath(), "git", "init"); command = "git add --all"; System.err.println(command); - IkaRuntime.exec(command, getFullPath()); + IkaRuntime.exec(getFullPath(), "git", "add", "--all"); command = "git commit -m initial_repository --verbose"; System.err.println(command); - IkaRuntime.exec(command, getFullPath()); + IkaRuntime.exec(getFullPath(), "git", "commit", "-m", "initial_repository", "--verbose"); command = "git branch " + branch; System.err.println(command); - IkaRuntime.exec(command, getFullPath()); + IkaRuntime.exec(getFullPath(), "git", "branch", branch); command = "git checkout " + branch; System.err.println(command); - IkaRuntime.exec(command, getFullPath()); + IkaRuntime.exec(getFullPath(), "git", "checkout", branch); System.err.println(">>>>>>>> done: " + this + " <<<<<<<<"); } @@ -117,7 +117,7 @@ public void applyPatchQueue() { String command = "guilt push --all"; System.err.println(command); - IkaRuntime.exec(command, getFullPath()); + IkaRuntime.exec(getFullPath(), "guilt", "push", "--all"); } @Override @@ -125,6 +125,6 @@ String command = "guilt init"; System.err.println(command); - IkaRuntime.exec(command, getFullPath()); + IkaRuntime.exec(getFullPath(), "guilt", "init"); } }
--- a/src/main/java/org/icedrobot/ika/runtime/scm/HGRepository.java Tue Mar 29 23:54:31 2011 +0200 +++ b/src/main/java/org/icedrobot/ika/runtime/scm/HGRepository.java Fri Apr 01 00:37:47 2011 +0200 @@ -53,7 +53,7 @@ public void makeClone() { String command = "hg clone " + remotePath + " " + getFullPath(); System.err.println(command); - IkaRuntime.exec(command, getFullPath()); + IkaRuntime.exec(getFullPath(), "hg", "clone", remotePath, getFullPath().toString()); } @Override @@ -82,15 +82,15 @@ String command = "hg init ."; System.err.println(command); - IkaRuntime.exec(command, getFullPath()); + IkaRuntime.exec(getFullPath(), "hg", "init"); command = "hg add"; System.err.println(command); - IkaRuntime.exec(command, getFullPath()); + IkaRuntime.exec(getFullPath(), "hg", "add"); command = "hg commit -minitial_repository"; System.err.println(command); - IkaRuntime.exec(command, getFullPath()); + IkaRuntime.exec(getFullPath(), "hg", "commit", "-minitial_repository"); } @Override
--- a/src/main/resources/org/icedrobot/ika/plugins/borg/repositories.properties Tue Mar 29 23:54:31 2011 +0200 +++ b/src/main/resources/org/icedrobot/ika/plugins/borg/repositories.properties Fri Apr 01 00:37:47 2011 +0200 @@ -3,3 +3,4 @@ core=system,git://android.git.kernel.org/platform/system/core.git,android-2.3.2_r1 safe-iop=external,git://android.git.kernel.org/platform/external/safe-iop.git,android-2.3.2_r1 base=frameworks,git://android.git.kernel.org/platform/frameworks/base.git,android-2.3.2_r1 +#libcore=.,git://android.git.kernel.org/platform/libcore.git,android-2.3.2_r1 \ No newline at end of file
--- a/src/main/resources/org/icedrobot/ika/plugins/borg/subrepositories.properties Tue Mar 29 23:54:31 2011 +0200 +++ b/src/main/resources/org/icedrobot/ika/plugins/borg/subrepositories.properties Fri Apr 01 00:37:47 2011 +0200 @@ -2,4 +2,4 @@ dalvik=vm,libnativehelper,libdex,dx safe-iop=. core=libcutils -base=. +base=. \ No newline at end of file