Selaa lähdekoodia

FastIgnoreRule: include bad pattern in log message

When a .gitignore pattern cannot be parsed include the pattern in the
log message. Just reporting "not closed bracket" isn't helpful if the
user doesn't know in which pattern the problem occurred.

Even better would be to include the full path of the .gitignore file
that contained the offending pattern. This is not implemented in this
change; it may need new API and needs more thought.

Bug: 571143
Change-Id: Id5b16d9cf550544ba3ad409a02041946fa8516ab
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
tags/v5.11.0.202102240950-m3
Thomas Wolf 3 vuotta sitten
vanhempi
commit
4e745c57f7

+ 1
- 0
org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties Näytä tiedosto

@@ -30,6 +30,7 @@ badEntryDelimiter=Bad entry delimiter
badEntryName=Bad entry name: {0}
badEscape=Bad escape: {0}
badGroupHeader=Bad group header
badIgnorePattern=Cannot parse .gitignore pattern ''{0}''
badObjectType=Bad object type: {0}
badRef=Bad ref: {0}: {1}
badSectionEntry=Bad section entry: {0}

+ 6
- 1
org.eclipse.jgit/src/org/eclipse/jgit/ignore/FastIgnoreRule.java Näytä tiedosto

@@ -14,8 +14,11 @@ import static org.eclipse.jgit.ignore.internal.Strings.isDirectoryPattern;
import static org.eclipse.jgit.ignore.internal.Strings.stripTrailing;
import static org.eclipse.jgit.ignore.internal.Strings.stripTrailingWhitespace;

import java.text.MessageFormat;

import org.eclipse.jgit.errors.InvalidPatternException;
import org.eclipse.jgit.ignore.internal.PathMatcher;
import org.eclipse.jgit.internal.JGitText;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@@ -96,7 +99,9 @@ public class FastIgnoreRule {
Character.valueOf(PATH_SEPARATOR), dirOnly);
} catch (InvalidPatternException e) {
m = NO_MATCH;
LOG.error(e.getMessage(), e);
LOG.error(MessageFormat.format(
JGitText.get().badIgnorePattern,
e.getPattern()), e);
}
this.matcher = m;
}

+ 1
- 0
org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java Näytä tiedosto

@@ -58,6 +58,7 @@ public class JGitText extends TranslationBundle {
/***/ public String badEntryName;
/***/ public String badEscape;
/***/ public String badGroupHeader;
/***/ public String badIgnorePattern;
/***/ public String badObjectType;
/***/ public String badRef;
/***/ public String badSectionEntry;

Loading…
Peruuta
Tallenna