Added environment variables to RepositoryAction#ofCommand.
This commit is contained in:
parent
540616db42
commit
e33b594a5e
4
pom.xml
4
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>nl.andrewl</groupId>
|
||||
<artifactId>distribugit</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.3.1</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
|
@ -38,7 +38,7 @@
|
|||
<dependency>
|
||||
<groupId>org.kohsuke</groupId>
|
||||
<artifactId>github-api</artifactId>
|
||||
<version>1.303</version>
|
||||
<version>1.306</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/info.picocli/picocli -->
|
||||
<dependency>
|
||||
|
|
|
@ -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.
|
||||
* <p>
|
||||
* Commands invoked via this method have access to the following
|
||||
* environment variables:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>DISTRIBUGIT_INVOKE_DIR - The directory in which distribugit
|
||||
* was invoked.</li>
|
||||
* <li>DISTRIBUGIT_WORKING_DIR - The working directory of distribugit,
|
||||
* which contains all repositories.</li>
|
||||
* </ul>
|
||||
* @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();
|
||||
|
|
Loading…
Reference in New Issue