Skip to content

Commit

Permalink
Workaround for bug ignoring file in folder that doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
rcraggs committed Nov 22, 2019
1 parent 8e29599 commit 386a02d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/gitruler/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public class Command implements Runnable {

public void run() {


int exitCode = 1; // So that it can be used to fail a build in continuous integration

// Read the config
if (repositoryPath == null){
repositoryPath = System.getProperty("user.dir");
Expand Down Expand Up @@ -125,6 +128,7 @@ public void run() {
String congratulationsString = "";
if (totalScore == config.getTotalAvailableScore()) {
congratulationsString = " Perfect!";
exitCode = 0; // exit as not a fail for a CI build
}

System.out.println();
Expand All @@ -143,6 +147,7 @@ public void run() {
}

System.out.println(resultOutput);
System.exit(exitCode);
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/gitruler/GitInteractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,13 @@ private RuleResult gitWouldIgnore(Rule r) {
}
}

// Pass the rule if the parent folder doesn't exist and the command
// doesn't tell us to do otherwise.
if (!Files.exists(Paths.get(path.toString()).getParent())){
result.setPassed(true);
return result;
}

// Create a file
try {
Files.write(path, DUMMY_CONTENT.getBytes(), StandardOpenOption.CREATE_NEW);
Expand Down

0 comments on commit 386a02d

Please sign in to comment.