Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2018-08-20 10:13:30 +0300
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2018-08-20 16:52:03 +0300
commit37b108114c939df0e461cc9bb65eae199812127c (patch)
treece8b969409f30f30cd6cb6c68c4426d41fbe3e38
parentf99c85470021973088f7757e2945bd10cb2773c7 (diff)
Stop vendoring Attributes parsing files
-rwxr-xr-x_support/vendor-gitlab-git2
-rw-r--r--changelogs/unreleased/zj-stop-vendering-files.yml5
-rw-r--r--ruby/vendor/gitlab_git/lib/gitlab/git/attributes_at_ref_parser.rb14
-rw-r--r--ruby/vendor/gitlab_git/lib/gitlab/git/attributes_parser.rb111
4 files changed, 7 insertions, 125 deletions
diff --git a/_support/vendor-gitlab-git b/_support/vendor-gitlab-git
index f74a6d0cd..745071993 100755
--- a/_support/vendor-gitlab-git
+++ b/_support/vendor-gitlab-git
@@ -10,6 +10,8 @@ FILE_LIST = %w[
# We have (already) stopped vendoring these files.
EXCLUDE = %w[
+ lib/gitlab/git/attributes_at_ref_parser.rb
+ lib/gitlab/git/attributes_parser.rb
lib/gitlab/git/blame.rb
lib/gitlab/git/blob.rb
lib/gitlab/git/branch.rb
diff --git a/changelogs/unreleased/zj-stop-vendering-files.yml b/changelogs/unreleased/zj-stop-vendering-files.yml
new file mode 100644
index 000000000..38b2a433d
--- /dev/null
+++ b/changelogs/unreleased/zj-stop-vendering-files.yml
@@ -0,0 +1,5 @@
+---
+title: Stop vendoring some Gitlab::Git::* classes
+merge_request: 865
+author:
+type: changed
diff --git a/ruby/vendor/gitlab_git/lib/gitlab/git/attributes_at_ref_parser.rb b/ruby/vendor/gitlab_git/lib/gitlab/git/attributes_at_ref_parser.rb
deleted file mode 100644
index 26b5bd520..000000000
--- a/ruby/vendor/gitlab_git/lib/gitlab/git/attributes_at_ref_parser.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-module Gitlab
- module Git
- # Parses root .gitattributes file at a given ref
- class AttributesAtRefParser
- delegate :attributes, to: :@parser
-
- def initialize(repository, ref)
- blob = repository.blob_at(ref, '.gitattributes')
-
- @parser = AttributesParser.new(blob&.data)
- end
- end
- end
-end
diff --git a/ruby/vendor/gitlab_git/lib/gitlab/git/attributes_parser.rb b/ruby/vendor/gitlab_git/lib/gitlab/git/attributes_parser.rb
deleted file mode 100644
index 08f4d7d4f..000000000
--- a/ruby/vendor/gitlab_git/lib/gitlab/git/attributes_parser.rb
+++ /dev/null
@@ -1,111 +0,0 @@
-module Gitlab
- module Git
- # Class for parsing Git attribute files and extracting the attributes for
- # file patterns.
- class AttributesParser
- def initialize(attributes_data = "")
- @data = attributes_data || ""
- end
-
- # Returns all the Git attributes for the given path.
- #
- # file_path - A path to a file for which to get the attributes.
- #
- # Returns a Hash.
- def attributes(file_path)
- absolute_path = File.join('/', file_path)
-
- patterns.each do |pattern, attrs|
- return attrs if File.fnmatch?(pattern, absolute_path)
- end
-
- {}
- end
-
- # Returns a Hash containing the file patterns and their attributes.
- def patterns
- @patterns ||= parse_data
- end
-
- # 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.
- def parse_attributes(string)
- values = {}
- dash = '-'
- equal = '='
- binary = 'binary'
-
- string.split(/\s+/).each do |chunk|
- # Data such as "foo = bar" should be treated as "foo" and "bar" being
- # separate boolean attributes.
- next if chunk == equal
-
- key = chunk
-
- # Input: "-foo"
- if chunk.start_with?(dash)
- key = chunk.byteslice(1, chunk.length - 1)
- value = false
-
- # Input: "foo=bar"
- elsif chunk.include?(equal)
- key, value = chunk.split(equal, 2)
-
- # Input: "foo"
- else
- value = true
- end
-
- values[key] = value
-
- # When the "binary" option is set the "diff" option should be set to
- # the inverse. If "diff" is later set it should overwrite the
- # automatically set value.
- values['diff'] = false if key == binary && value
- end
-
- values
- end
-
- # Iterates over every line in the attributes file.
- def each_line
- @data.each_line do |line|
- break unless line.valid_encoding?
-
- yield line.strip
- end
- end
-
- private
-
- # Parses the Git attributes file contents.
- def parse_data
- pairs = []
- comment = '#'
-
- each_line do |line|
- next if line.start_with?(comment) || line.empty?
-
- pattern, attrs = line.split(/\s+/, 2)
-
- parsed = attrs ? parse_attributes(attrs) : {}
-
- absolute_pattern = File.join('/', pattern)
- pairs << [absolute_pattern, parsed]
- end
-
- # Newer entries take precedence over older entries.
- pairs.reverse.to_h
- end
- end
- end
-end