-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add blank commit/duplicate branch guards to Git CLI delegate
- Loading branch information
Showing
2 changed files
with
56 additions
and
18 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/main/java/com/neo4j/sandbox/git/CommandIOException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.neo4j.sandbox.git; | ||
|
||
import java.io.IOException; | ||
|
||
class CommandIOException extends IOException { | ||
|
||
private final String stdout; | ||
private final String stderr; | ||
|
||
public CommandIOException(String faultyCommand, int status, String stdout, String stderr) { | ||
super(String.format("Expected Git operation %s to succeed but got exit status %d. See error below%n%s", | ||
faultyCommand, status, combinedOutputs(stdout, stderr))); | ||
|
||
this.stdout = stdout; | ||
this.stderr = stderr; | ||
} | ||
|
||
public boolean commandOutputContains(String msg) { | ||
return this.stdout.contains(msg) || this.stderr.contains(msg); | ||
} | ||
|
||
private static String combinedOutputs(String stdout, String stderr) { | ||
StringBuilder builder = new StringBuilder(); | ||
builder.append(String.format("=====%n")); | ||
builder.append(String.format("Error stream%n")); | ||
builder.append(String.format("=====%n")); | ||
builder.append(stderr); | ||
builder.append("\n"); | ||
builder.append(String.format("=====%n")); | ||
builder.append(String.format("Output stream%n")); | ||
builder.append(String.format("=====%n")); | ||
builder.append(stdout); | ||
builder.append("\n"); | ||
return builder.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters