diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2018-03-29 18:35:52 +0300 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2018-03-29 18:35:52 +0300 |
commit | ad3de4e5c25c22d679df490bffb45aa190196c48 (patch) | |
tree | d89b499304c702f344eddb5752f5d7b81891e5cd | |
parent | 425eade570d1af260b744f6946c0f9bf3bf49f1d (diff) |
Vendor gitlab_git at 9b76d8512a5491202e5a953
10 files changed, 37 insertions, 26 deletions
diff --git a/ruby/vendor/gitlab_git/REVISION b/ruby/vendor/gitlab_git/REVISION index 0c2a58c1f..8d480b032 100644 --- a/ruby/vendor/gitlab_git/REVISION +++ b/ruby/vendor/gitlab_git/REVISION @@ -1 +1 @@ -79aa00321063daf8f650683373db29832c8e13f1 +9b76d8512a5491202e5a953950cc815be9536648 diff --git a/ruby/vendor/gitlab_git/lib/gitlab/encoding_helper.rb b/ruby/vendor/gitlab_git/lib/gitlab/encoding_helper.rb index 6659efa09..0b8f6cfe3 100644 --- a/ruby/vendor/gitlab_git/lib/gitlab/encoding_helper.rb +++ b/ruby/vendor/gitlab_git/lib/gitlab/encoding_helper.rb @@ -90,7 +90,7 @@ module Gitlab end def clean(message) - message.encode("UTF-16BE", undef: :replace, invalid: :replace, replace: "") + message.encode("UTF-16BE", undef: :replace, invalid: :replace, replace: "".encode("UTF-16BE")) .encode("UTF-8") .gsub("\0".encode("UTF-8"), "") end diff --git a/ruby/vendor/gitlab_git/lib/gitlab/git/conflict/file.rb b/ruby/vendor/gitlab_git/lib/gitlab/git/conflict/file.rb index 2a9cf10a0..f08dab59c 100644 --- a/ruby/vendor/gitlab_git/lib/gitlab/git/conflict/file.rb +++ b/ruby/vendor/gitlab_git/lib/gitlab/git/conflict/file.rb @@ -2,17 +2,19 @@ module Gitlab module Git module Conflict class File + UnsupportedEncoding = Class.new(StandardError) + attr_reader :their_path, :our_path, :our_mode, :repository, :commit_oid - attr_accessor :content + attr_accessor :raw_content - def initialize(repository, commit_oid, conflict, content) + def initialize(repository, commit_oid, conflict, raw_content) @repository = repository @commit_oid = commit_oid @their_path = conflict[:theirs][:path] @our_path = conflict[:ours][:path] @our_mode = conflict[:ours][:mode] - @content = content + @raw_content = raw_content end def lines @@ -29,6 +31,14 @@ module Gitlab end end + def content + @content ||= @raw_content.dup.force_encoding('UTF-8') + + raise UnsupportedEncoding unless @content.valid_encoding? + + @content + end + def type lines unless @type diff --git a/ruby/vendor/gitlab_git/lib/gitlab/git/conflict/parser.rb b/ruby/vendor/gitlab_git/lib/gitlab/git/conflict/parser.rb index 3effa9d2d..fb5717dd5 100644 --- a/ruby/vendor/gitlab_git/lib/gitlab/git/conflict/parser.rb +++ b/ruby/vendor/gitlab_git/lib/gitlab/git/conflict/parser.rb @@ -4,7 +4,6 @@ module Gitlab class Parser UnresolvableError = Class.new(StandardError) UnmergeableFile = Class.new(UnresolvableError) - UnsupportedEncoding = Class.new(UnresolvableError) # Recoverable errors - the conflict can be resolved in an editor, but not with # sections. @@ -75,10 +74,6 @@ module Gitlab def validate_text!(text) raise UnmergeableFile if text.blank? # Typically a binary file raise UnmergeableFile if text.length > 200.kilobytes - - text.force_encoding('UTF-8') - - raise UnsupportedEncoding unless text.valid_encoding? end def validate_delimiter!(condition) diff --git a/ruby/vendor/gitlab_git/lib/gitlab/git/gitlab_projects.rb b/ruby/vendor/gitlab_git/lib/gitlab/git/gitlab_projects.rb index a142ed6b2..dc0bc8518 100644 --- a/ruby/vendor/gitlab_git/lib/gitlab/git/gitlab_projects.rb +++ b/ruby/vendor/gitlab_git/lib/gitlab/git/gitlab_projects.rb @@ -212,7 +212,7 @@ module Gitlab end def shard_name_from_shard_path(shard_path) - Gitlab.config.repositories.storages.find { |_, info| info['path'] == shard_path }&.first || + Gitlab.config.repositories.storages.find { |_, info| info.legacy_disk_path == shard_path }&.first || raise(ShardNameNotFoundError, "no shard found for path '#{shard_path}'") end diff --git a/ruby/vendor/gitlab_git/lib/gitlab/git/lfs_pointer_file.rb b/ruby/vendor/gitlab_git/lib/gitlab/git/lfs_pointer_file.rb index da12ed7d1..2ae0a8895 100644 --- a/ruby/vendor/gitlab_git/lib/gitlab/git/lfs_pointer_file.rb +++ b/ruby/vendor/gitlab_git/lib/gitlab/git/lfs_pointer_file.rb @@ -1,13 +1,16 @@ module Gitlab module Git class LfsPointerFile + VERSION = "https://git-lfs.github.com/spec/v1".freeze + VERSION_LINE = "version #{VERSION}".freeze + def initialize(data) @data = data end def pointer @pointer ||= <<~FILE - version https://git-lfs.github.com/spec/v1 + #{VERSION_LINE} oid sha256:#{sha256} size #{size} FILE @@ -20,6 +23,10 @@ module Gitlab def sha256 @sha256 ||= Digest::SHA256.hexdigest(@data) end + + def inspect + "#<#{self.class}:#{object_id} @size=#{size}, @sha256=#{sha256.inspect}>" + end end end end diff --git a/ruby/vendor/gitlab_git/lib/gitlab/git/repository.rb b/ruby/vendor/gitlab_git/lib/gitlab/git/repository.rb index fbc935426..2d16a81c8 100644 --- a/ruby/vendor/gitlab_git/lib/gitlab/git/repository.rb +++ b/ruby/vendor/gitlab_git/lib/gitlab/git/repository.rb @@ -8,6 +8,7 @@ module Gitlab class Repository include Gitlab::Git::RepositoryMirroring include Gitlab::Git::Popen + include Gitlab::EncodingHelper ALLOWED_OBJECT_DIRECTORIES_VARIABLES = %w[ GIT_OBJECT_DIRECTORY @@ -93,7 +94,7 @@ module Gitlab @relative_path = relative_path @gl_repository = gl_repository - storage_path = Gitlab.config.repositories.storages[@storage]['path'] + storage_path = Gitlab.config.repositories.storages[@storage].legacy_disk_path @gitlab_projects = Gitlab::Git::GitlabProjects.new( storage_path, relative_path, @@ -516,10 +517,6 @@ module Gitlab end end - def sha_from_ref(ref) - rev_parse_target(ref).oid - end - # Return the object that +revspec+ points to. If +revspec+ is an # annotated tag, then return the tag's target instead. def rev_parse_target(revspec) @@ -1002,8 +999,9 @@ module Gitlab # This only checks the root .gitattributes file, # it does not traverse subfolders to find additional .gitattributes files # - # This method is around 30 times slower than `attributes`, - # which uses `$GIT_DIR/info/attributes` + # This method is around 30 times slower than `attributes`, which uses + # `$GIT_DIR/info/attributes`. Consider caching AttributesAtRefParser + # and reusing that for multiple calls instead of this method. def attributes_at(ref, file_path) parser = AttributesAtRefParser.new(self, ref) parser.attributes(file_path) @@ -1389,7 +1387,7 @@ module Gitlab offset = 2 args = %W(grep -i -I -n -z --before-context #{offset} --after-context #{offset} -E -e #{Regexp.escape(query)} #{ref || root_ref}) - run_git(args).first.scrub.split(/^--$/) + run_git(args).first.scrub.split(/^--\n/) end def can_be_merged?(source_sha, target_branch) @@ -1482,7 +1480,7 @@ module Gitlab names.lines.each do |line| next unless line.start_with?(refs_prefix) - refs << line.rstrip[left_slice_count..-1] + refs << encode_utf8(line.rstrip[left_slice_count..-1]) end refs @@ -2408,6 +2406,10 @@ module Gitlab def rev_list_param(spec) spec == :all ? ['--all'] : spec end + + def sha_from_ref(ref) + rev_parse_target(ref).oid + end end end end diff --git a/ruby/vendor/gitlab_git/lib/gitlab/git/storage/checker.rb b/ruby/vendor/gitlab_git/lib/gitlab/git/storage/checker.rb index d3c37f821..2f611cef3 100644 --- a/ruby/vendor/gitlab_git/lib/gitlab/git/storage/checker.rb +++ b/ruby/vendor/gitlab_git/lib/gitlab/git/storage/checker.rb @@ -35,7 +35,7 @@ module Gitlab def initialize(storage, logger = Rails.logger) @storage = storage config = Gitlab.config.repositories.storages[@storage] - @storage_path = config['path'] + @storage_path = config.legacy_disk_path @logger = logger @hostname = Gitlab::Environment.hostname diff --git a/ruby/vendor/gitlab_git/lib/gitlab/git/storage/circuit_breaker.rb b/ruby/vendor/gitlab_git/lib/gitlab/git/storage/circuit_breaker.rb index 898bb1b65..e35054466 100644 --- a/ruby/vendor/gitlab_git/lib/gitlab/git/storage/circuit_breaker.rb +++ b/ruby/vendor/gitlab_git/lib/gitlab/git/storage/circuit_breaker.rb @@ -25,7 +25,7 @@ module Gitlab if !config.present? NullCircuitBreaker.new(storage, hostname, error: Misconfiguration.new("Storage '#{storage}' is not configured")) - elsif !config['path'].present? + elsif !config.legacy_disk_path.present? NullCircuitBreaker.new(storage, hostname, error: Misconfiguration.new("Path for storage '#{storage}' is not configured")) else new(storage, hostname) diff --git a/ruby/vendor/gitlab_git/lib/gitlab/git/wiki.rb b/ruby/vendor/gitlab_git/lib/gitlab/git/wiki.rb index 52b44b9b3..8d8282091 100644 --- a/ruby/vendor/gitlab_git/lib/gitlab/git/wiki.rb +++ b/ruby/vendor/gitlab_git/lib/gitlab/git/wiki.rb @@ -29,7 +29,6 @@ module Gitlab @repository.gitaly_migrate(:wiki_write_page) do |is_enabled| if is_enabled gitaly_write_page(name, format, content, commit_details) - gollum_wiki.clear_cache else gollum_write_page(name, format, content, commit_details) end @@ -40,7 +39,6 @@ module Gitlab @repository.gitaly_migrate(:wiki_delete_page) do |is_enabled| if is_enabled gitaly_delete_page(page_path, commit_details) - gollum_wiki.clear_cache else gollum_delete_page(page_path, commit_details) end @@ -51,7 +49,6 @@ module Gitlab @repository.gitaly_migrate(:wiki_update_page) do |is_enabled| if is_enabled gitaly_update_page(page_path, title, format, content, commit_details) - gollum_wiki.clear_cache else gollum_update_page(page_path, title, format, content, commit_details) end |