Example usage for org.eclipse.jgit.attributes AttributesNode parse

List of usage examples for org.eclipse.jgit.attributes AttributesNode parse

Introduction

In this page you can find the example usage for org.eclipse.jgit.attributes AttributesNode parse.

Prototype

public void parse(InputStream in) throws IOException 

Source Link

Document

Parse files according to gitattribute standards.

Usage

From source file:com.diffplug.gradle.spotless.GitAttributesLineEndingPolicy.java

License:Apache License

/** Parses a list of rules from the given file, returning an empty list if the file doesn't exist. */
private static List<AttributesRule> parseRules(File file) {
    if (file.exists() && file.isFile()) {
        try (InputStream stream = new FileInputStream(file)) {
            AttributesNode parsed = new AttributesNode();
            parsed.parse(stream);
            return parsed.getRules();
        } catch (IOException e) {
            // no need to crash the whole plugin
            System.err.println("Problem parsing " + file.getAbsolutePath());
            e.printStackTrace();//  ww  w.j a  va 2s.  c o  m
        }
    }
    return Collections.emptyList();
}

From source file:com.diffplug.spotless.extra.GitAttributesLineEndings.java

License:Apache License

/** Parses a list of rules from the given file, returning an empty list if the file doesn't exist. */
private static List<AttributesRule> parseRules(@Nullable File file) {
    if (file != null && file.exists() && file.isFile()) {
        try (InputStream stream = new FileInputStream(file)) {
            AttributesNode parsed = new AttributesNode();
            parsed.parse(stream);
            return parsed.getRules();
        } catch (IOException e) {
            // no need to crash the whole plugin
            System.err.println("Problem parsing " + file.getAbsolutePath());
            e.printStackTrace();/*from   w  w w .  j av  a2  s . c  o  m*/
        }
    }
    return Collections.emptyList();
}