diff --git a/pom.xml b/pom.xml index 9e4afbf..2ef3d2e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ nl.andrewl distribugit - 1.3.0 + 1.3.1 17 @@ -38,7 +38,7 @@ org.kohsuke github-api - 1.303 + 1.306 diff --git a/src/main/java/nl/andrewl/distribugit/RepositoryAction.java b/src/main/java/nl/andrewl/distribugit/RepositoryAction.java index 21fe36e..3e24413 100644 --- a/src/main/java/nl/andrewl/distribugit/RepositoryAction.java +++ b/src/main/java/nl/andrewl/distribugit/RepositoryAction.java @@ -17,6 +17,16 @@ public interface RepositoryAction { * An action which executes a system command, as handled by * {@link ProcessBuilder}. Note that the working directory of the command * is set to the directory of the repository. + *

+ * Commands invoked via this method have access to the following + * environment variables: + *

+ * * @param command The command to run. * @return The command action. */ @@ -24,6 +34,8 @@ public interface RepositoryAction { return git -> { ProcessBuilder pb = new ProcessBuilder(command); pb.directory(git.getRepository().getWorkTree()); + pb.environment().put("DISTRIBUGIT_INVOKE_DIR", pb.directory().getParentFile().getParentFile().getAbsolutePath()); + pb.environment().put("DISTRIBUGIT_WORKING_DIR", pb.directory().getParentFile().getAbsolutePath()); pb.inheritIO(); Process p = pb.start(); int result = p.waitFor();