Skip to content

Commit

Permalink
Merge 2ef77b2 into 353f39b
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-harms committed Oct 26, 2018
2 parents 353f39b + 2ef77b2 commit bc74ed1
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
import com.uber.jenkins.phabricator.LauncherFactory;
import com.uber.jenkins.phabricator.conduit.ArcanistClient;
import com.uber.jenkins.phabricator.utils.Logger;
import hudson.model.Computer;
import org.apache.commons.lang.StringUtils;

import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

public class ApplyPatchTask extends Task {

Expand Down Expand Up @@ -58,7 +61,7 @@ public ApplyPatchTask(
this.diffID = diffID;
this.conduitUrl = conduitUrl;
this.conduitToken = conduitToken;
this.arcPath = arcPath;
this.arcPath = isWindows() ? arcPath + ".bat" : arcPath;
this.gitPath = gitPath;
this.createCommit = createCommit;
this.skipForcedClean = skipForcedClean;
Expand Down Expand Up @@ -151,6 +154,26 @@ protected void execute() {
}
}

/**
* @return true if the current executor is on Windows
*/
private boolean isWindows() {
try {
Computer remoteComputer = Computer.currentComputer();
if (remoteComputer != null) {
Map<Object, Object> remoteProperties = remoteComputer.getSystemProperties();
if (remoteProperties.containsKey("os.name")) {
return StringUtils.startsWithIgnoreCase(remoteProperties.get("os.name").toString(), "Windows");
}
}
} catch (IOException e) {
info("IOException attempting to determine whether the OS is Windows.\n" + e.getMessage());
} catch (InterruptedException e) {
info("InterruptedException attempting to determine whether the OS is Windows.\n" + e.getMessage());
}
return false;
}

/**
* {@inheritDoc}
*/
Expand Down

0 comments on commit bc74ed1

Please sign in to comment.