Skip to content

Commit

Permalink
showcase eclipse-jgit#105
Browse files Browse the repository at this point in the history
  • Loading branch information
Jente Sondervorst committed Oct 25, 2024
1 parent 8188c4a commit 2e4b5b5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.idea
/.project
/org.eclipse.jgit.benchmarks/dependency-reduced-pom.xml
target/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.eclipse.jgit.ignore;

import org.junit.Test;

import java.io.ByteArrayInputStream;
import java.io.IOException;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class ShowcaseBehaviour1Test {

//Let's load a "file" containing a single rule for /directory/nested/.
//This should exclude the directory /directory/nested/again
@Test
public void IgnoreNodeUsesPathMatchTrue() throws IOException {
IgnoreNode ignoreNode = new IgnoreNode();
ignoreNode.parse(new ByteArrayInputStream("/directory/nested/".getBytes()));

IgnoreNode.MatchResult isIgnored = ignoreNode.isIgnored("/directory/nested/again", true);

assertEquals(IgnoreNode.MatchResult.IGNORED, isIgnored);
// The result should not be CHECK_PARENT?
}

//IgnoreNode.MatchResult isIgnored = ignoreNode.isIgnored("/directory/nested/again", true);
// ^^^^^^^^^
// Path match is always sent as true (see difference in next test)
// The result is NOT correct

@Test
public void fastIgnoreRuleForNestedDirectory() {
//This PASSES as isMatch returns true
FastIgnoreRule ignoreRule1 = new FastIgnoreRule("/directory/nested/");
assertTrue(ignoreRule1.isMatch("/directory/nested/again", true, false)); // It matches the directory
// ^^^^^

//This FAILS as isMatch returns false
FastIgnoreRule ignoreRule2 = new FastIgnoreRule("/directory/nested/");
assertTrue(ignoreRule2.isMatch("/directory/nested/again", true, true)); // It matches the directory
// ^^^^^
}
}

0 comments on commit 2e4b5b5

Please sign in to comment.