-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMPatchCommand.java
More file actions
55 lines (48 loc) · 1.63 KB
/
MPatchCommand.java
File metadata and controls
55 lines (48 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package org.variantsync.diffdetective.shell;
import java.util.List;
/** Single executable command with arguments. */
public class MPatchCommand extends ShellCommand {
private final String[] parts;
private boolean patchingSuccessful;
/**
* Constructs a single command.
* The first argument has to be a path to an executable which will be given all of the
* remaining arguments as parameters on execution.
*
* @param cmd executable path and arguments for the executable
*/
public MPatchCommand(final String... cmd) {
parts = cmd;
}
@Override
public String[] parts() {
return parts;
}
/**
* Interpret the result/exit code returned from a shell command.
* An {@code ShellException} is thrown if the result code is an error.
*
* @param resultCode the code that is to be parsed
* @param output the output of the shell command
* @return the output of the shell command
* @throws ShellException if {@code resultCode} is an error
*/
@Override
public List<String> interpretResult(int resultCode, List<String> output) throws ShellException {
// patching was successful ???
if (resultCode == 0) {
patchingSuccessful = true;
return null;
}
// some hunks cannot be applied or merge conflicts ???
if (resultCode == 1) {
patchingSuccessful = false;
return null;
}
// everything else: "serious trouble": exit code 2 ???
throw new ShellException(output);
}
public boolean isPatchingSuccessful() {
return patchingSuccessful;
}
}