@ -63,8 +63,7 @@ import org.eclipse.jgit.api.errors.RefNotFoundException;
import org.eclipse.jgit.errors.IncorrectObjectTypeException ;
import org.eclipse.jgit.errors.IncorrectObjectTypeException ;
import org.eclipse.jgit.errors.InvalidPatternException ;
import org.eclipse.jgit.errors.InvalidPatternException ;
import org.eclipse.jgit.errors.MissingObjectException ;
import org.eclipse.jgit.errors.MissingObjectException ;
import org.eclipse.jgit.ignore.internal.IMatcher ;
import org.eclipse.jgit.fnmatch.FileNameMatcher ;
import org.eclipse.jgit.ignore.internal.PathMatcher ;
import org.eclipse.jgit.internal.JGitText ;
import org.eclipse.jgit.internal.JGitText ;
import org.eclipse.jgit.lib.Constants ;
import org.eclipse.jgit.lib.Constants ;
import org.eclipse.jgit.lib.ObjectId ;
import org.eclipse.jgit.lib.ObjectId ;
@ -104,7 +103,7 @@ public class DescribeCommand extends GitCommand<String> {
/ * *
/ * *
* Pattern matchers to be applied to tags under consideration .
* Pattern matchers to be applied to tags under consideration .
* /
* /
private List < I Matcher> matchers = new ArrayList < > ( ) ;
private List < FileName Matcher> matchers = new ArrayList < > ( ) ;
/ * *
/ * *
* Whether to use all tags ( incl . lightweight ) or not .
* Whether to use all tags ( incl . lightweight ) or not .
@ -242,7 +241,7 @@ public class DescribeCommand extends GitCommand<String> {
* /
* /
public DescribeCommand setMatch ( String . . . patterns ) throws InvalidPatternException {
public DescribeCommand setMatch ( String . . . patterns ) throws InvalidPatternException {
for ( String p : patterns ) {
for ( String p : patterns ) {
matchers . add ( PathMatcher . createPath Matcher( p , null , false ) ) ;
matchers . add ( new FileName Matcher( p , null ) ) ;
}
}
return this ;
return this ;
}
}
@ -275,9 +274,15 @@ public class DescribeCommand extends GitCommand<String> {
// Find the first tag that matches in the stream of all tags
// Find the first tag that matches in the stream of all tags
// filtered by matchers ordered by tie break order
// filtered by matchers ordered by tie break order
Stream < Ref > matchingTags = Stream . empty ( ) ;
Stream < Ref > matchingTags = Stream . empty ( ) ;
for ( I Matcher matcher : matchers ) {
for ( FileName Matcher matcher : matchers ) {
Stream < Ref > m = tags . stream ( ) . filter (
Stream < Ref > m = tags . stream ( ) . filter (
tag - > matcher . matches ( tag . getName ( ) , false , false ) ) ;
tag - > {
matcher . append (
tag . getName ( ) . substring ( R_TAGS . length ( ) ) ) ;
boolean result = matcher . isMatch ( ) ;
matcher . reset ( ) ;
return result ;
} ) ;
matchingTags = Stream . of ( matchingTags , m ) . flatMap ( i - > i ) ;
matchingTags = Stream . of ( matchingTags , m ) . flatMap ( i - > i ) ;
}
}
return matchingTags . sorted ( TAG_TIE_BREAKER ) . findFirst ( ) ;
return matchingTags . sorted ( TAG_TIE_BREAKER ) . findFirst ( ) ;