diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2025-02-25 10:02:34 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2025-02-25 11:01:00 +0100 |
commit | 8501e5d6ae374f779ab60abe2ad2eaa7ed07b071 (patch) | |
tree | 8963f12ea68c7f08dc4dc6ed88c11f4b26391b2f | |
parent | 68f454af418224b1ba654337c073bfb06cfb16c6 (diff) | |
download | jgit-8501e5d6ae374f779ab60abe2ad2eaa7ed07b071.tar.gz jgit-8501e5d6ae374f779ab60abe2ad2eaa7ed07b071.zip |
DescribeCommand: remove unnecessary else clause
and reduce indentation.
Change-Id: I60a6f721eed051d67aa385a143e2bd3a950485f7
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java index 898f4464fd..d2526287f9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java @@ -313,39 +313,39 @@ public class DescribeCommand extends GitCommand<String> { } else if (matchers.isEmpty() && excludeMatchers.isEmpty()) { Collections.sort(tags, TAG_TIE_BREAKER); return Optional.of(tags.get(0)); - } else { - Stream<Ref> matchingTags; - if (!matchers.isEmpty()) { - // Find the first tag that matches in the stream of all tags - // filtered by matchers ordered by tie break order - matchingTags = Stream.empty(); - for (FileNameMatcher matcher : matchers) { - Stream<Ref> m = tags.stream().filter( + } + + Stream<Ref> matchingTags; + if (!matchers.isEmpty()) { + // Find the first tag that matches in the stream of all tags + // filtered by matchers ordered by tie break order + matchingTags = Stream.empty(); + for (FileNameMatcher matcher : matchers) { + Stream<Ref> m = tags.stream().filter( // tag -> { matcher.append(formatRefName(tag.getName())); boolean result = matcher.isMatch(); matcher.reset(); return result; }); - matchingTags = Stream.of(matchingTags, m).flatMap(i -> i); - } - } else { - // If there are no matchers, there are only excluders - // Assume all tags match for now before applying excluders - matchingTags = tags.stream(); + matchingTags = Stream.of(matchingTags, m).flatMap(i -> i); } + } else { + // If there are no matchers, there are only excluders + // Assume all tags match for now before applying excluders + matchingTags = tags.stream(); + } - for (FileNameMatcher matcher : excludeMatchers) { - matchingTags = matchingTags.filter( + for (FileNameMatcher matcher : excludeMatchers) { + matchingTags = matchingTags.filter( // tag -> { matcher.append(formatRefName(tag.getName())); boolean result = matcher.isMatch(); matcher.reset(); return !result; }); - } - return matchingTags.sorted(TAG_TIE_BREAKER).findFirst(); } + return matchingTags.sorted(TAG_TIE_BREAKER).findFirst(); } private ObjectId getObjectIdFromRef(Ref r) throws JGitInternalException { |