Closed anukriti-chawla closed 6 years ago
I have tried directory() function which is changing my directory however "git clone" when done through cmd gives me following output :
Cloning into 'gitrepo'... remote: Counting objects: 92, done remote: Finding sources: 100% (92/92) remote: Getting sizes: 100% (76/76) remote: Compressing objects: 98% (2370/2400) remote: Total 92 (delta 14), reused 89 (delta 14) Unpacking objects: 100% (92/92), done. Checking connectivity... done.
But running the same "git clone" thorugh zt-exec return only the first line of output : Cloning into 'gitrepo'...
hi @anukriti-chawla, can you please try:
String output = new ProcessExecutor().dir("D:/myfolder").command("git", "clone", "--depth", "1", url).readOutput(true).execute()
.outputUTF8();
and provide the output and the log for the process running zt-exec?
Hi @shelajev I tried the above mentioned command, gives me only the first line as out put : "Cloning into 'gitrepo'..."
All other lines are actually the stderr, so if you redirect the error stream you should see it:
String output = new ProcessExecutor() .dir("D:/myfolder") .command("git", "clone", "--depth", "1", url) .redirectErrorStream(true) .readOutput(true) .execute() .outputUTF8();
Also, please verify that the repository actually gets cloned in the correct directory.
I tried .redirectErrorStream(true) , but only getting the first line as earlier. Yes the repository is getting clonned successfully.
.redirectErrorStream(true)
is the default anyways.
Maybe the git command depends on whether it's used via terminal or not.
For the latest version, the dir function has been renamed to "directory(File directory)"
I am trying the following code :
But getting an exception : Exception in thread "main" java.io.IOException: Could not execute [cd D:/myfolder]. at org.zeroturnaround.exec.ProcessExecutor.invokeStart(ProcessExecutor.java:936) at org.zeroturnaround.exec.ProcessExecutor.startInternal(ProcessExecutor.java:910) at org.zeroturnaround.exec.ProcessExecutor.execute(ProcessExecutor.java:860) at .git.zttest.main(zttest.java:16) Caused by: java.io.IOException: Cannot run program " cd D:/myfolder": CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(Unknown Source) at org.zeroturnaround.exec.ProcessExecutor.invokeStart(ProcessExecutor.java:931) ... 3 more Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 5 more
How this command can be executed using zt-exec. Also after this is done my whole command is :
cd <mydirectory> && D: && <gitlocation>/git clone --depth 1 <url>
Is this possible?