Class Gitlab::Git::Attributes
In: lib/gitlab_git/attributes.rb
Parent: Object

Class for parsing Git attribute files and extracting the attributes for file patterns.

Unlike Rugged this parser only needs a single IO call (a call to `open`), vastly reducing the time spent in extracting attributes.

This class only supports parsing the attributes file located at `$GIT_DIR/info/attributes` as GitLab doesn‘t use any other files (`.gitattributes` is copied to this particular path).

Basic usage:

    attributes = Gitlab::Git::Attributes.new(some_repo.path)

    attributes.attributes('README.md') # => { "eol" => "lf }

Methods

Public Class methods

path - The path to the Git repository.

Public Instance methods

Returns all the Git attributes for the given path.

path - A path to a file for which to get the attributes.

Returns a Hash.

Iterates over every line in the attributes file.

Parses an attribute string.

These strings can be in the following formats:

    text      # => { "text" => true }
    -text     # => { "text" => false }
    key=value # => { "key" => "value" }

string - The string to parse.

Returns a Hash containing the attributes and their values.

Returns a Hash containing the file patterns and their attributes.

[Validate]