Support 'ext = *' to let a formatter handle all file extensions
This is useful to configure a default formatter for all files that
applies if no other formatter can handle a file.
E.g.:
[formatter "PLAIN_TEXT"]
ext = *
prio = -1
Change-Id: I4f2eb8fdf15e2abd55913f46f83071f7caa1809e
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/xdocs/formatter/Formatters.java b/src/main/java/com/googlesource/gerrit/plugins/xdocs/formatter/Formatters.java
index 3c486d9..a1e3e84 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/xdocs/formatter/Formatters.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/xdocs/formatter/Formatters.java
@@ -114,7 +114,7 @@
}
for (String ext :
formatterCfg.getStringList(KEY_EXT)) {
- if (extension.equals(ext)) {
+ if (extension.equals(ext) || "*".equals(ext)) {
int prio = formatterCfg.getInt(KEY_PRIO, 0);
if (formatter == null || prio > formatterPrio) {
formatter = new FormatterProvider(e.getKey(), e.getValue());
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
index 647d063..9bb7cf1 100644
--- a/src/main/resources/Documentation/config.md
+++ b/src/main/resources/Documentation/config.md
@@ -34,6 +34,8 @@
formatter.<formatter>.ext
: Extension of files that should be rendered by this formatter.
+ If set to `*` all file extensions are handled by this formatter.
+
Multiple extensions may be specified for a formatter.
Overrides the [globally configured file extensions](#formatterExt)
@@ -136,6 +138,8 @@
formatter.<formatter>.ext
: Extension of files that will be rendered by this formatter.
+ If set to `*` all file extensions are handled by this formatter.
+
Multiple extensions may be specified for a formatter.
Can be overridden on [project-level](#ext).