implement mercurial pre-receive hook

This commit is contained in:
Sebastian Sdorra
2011-09-28 09:42:16 +02:00
parent 8cf66a7f15
commit b07810c2d1
4 changed files with 150 additions and 26 deletions

View File

@@ -47,6 +47,8 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
@@ -68,6 +70,20 @@ public class SimpleCommand implements Command
*/
public SimpleCommand(String... command)
{
this(null, command);
}
/**
* Constructs ...
*
*
* @param environment
* @param command
* @since 1.8
*/
public SimpleCommand(Map<String, String> environment, String... command)
{
this.environment = environment;
this.command = command;
}
@@ -91,6 +107,18 @@ public class SimpleCommand implements Command
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param environment
* @since 1.8
*/
public void setEnvironment(Map<String, String> environment)
{
this.environment = environment;
}
/**
* Method description
*
@@ -134,6 +162,11 @@ public class SimpleCommand implements Command
processBuilder = processBuilder.directory(workDirectory);
}
if (environment != null)
{
processBuilder.environment().putAll(environment);
}
return processBuilder.redirectErrorStream(true).start();
}
@@ -208,6 +241,9 @@ public class SimpleCommand implements Command
/** Field description */
private String[] command;
/** Field description */
private Map<String, String> environment;
/** Field description */
private File workDirectory;
}