diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-03-27 14:31:15 +0200 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-04-11 14:21:27 +0200 |
commit | c830b8e3b782da466d73892728a8ddb869e7d47c (patch) | |
tree | 02c0ecf81fd7a2b6136cea672a742f79e95a8a99 /lib/gitlab/git/attributes_parser.rb | |
parent | 863e1a7a053c8b193fb945f24eff25b96079b2c2 (diff) | |
download | gitlab-ce-c830b8e3b782da466d73892728a8ddb869e7d47c.tar.gz |
Client implementation for InfoAttributes
Clients can now request the attributes from `$GIT_DIR/info/attributes`
through Gitaly. The Gitaly migration is described in gitlab-org/gitaly#1082.
The parser algorithm was implemented in a way it could handle both file
contents or a File handle, and both were already tested.
Other than that, using the boy scout rule, I've removed a class,
InfoAttributes, as it was delegating everything to the parser and
therefor wasn't really needed in my opinion.
Diffstat (limited to 'lib/gitlab/git/attributes_parser.rb')
-rw-r--r-- | lib/gitlab/git/attributes_parser.rb | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/gitlab/git/attributes_parser.rb b/lib/gitlab/git/attributes_parser.rb index d8aeabb6cba..08f4d7d4f5c 100644 --- a/lib/gitlab/git/attributes_parser.rb +++ b/lib/gitlab/git/attributes_parser.rb @@ -3,12 +3,8 @@ module Gitlab # Class for parsing Git attribute files and extracting the attributes for # file patterns. class AttributesParser - def initialize(attributes_data) + def initialize(attributes_data = "") @data = attributes_data || "" - - if @data.is_a?(File) - @patterns = parse_file - end end # Returns all the Git attributes for the given path. @@ -28,7 +24,7 @@ module Gitlab # Returns a Hash containing the file patterns and their attributes. def patterns - @patterns ||= parse_file + @patterns ||= parse_data end # Parses an attribute string. @@ -91,8 +87,8 @@ module Gitlab private - # Parses the Git attributes file. - def parse_file + # Parses the Git attributes file contents. + def parse_data pairs = [] comment = '#' |