From da646a6e06d1e7f2b5548e46db77cddae749baad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20L=C3=B3pez?= Date: Wed, 6 Jun 2018 19:31:49 +0200 Subject: [PATCH 01/13] Vendoring ruby dir --- ruby/vendor/gitlab_git/REVISION | 2 +- ruby/vendor/gitlab_git/lib/gitlab/git/commit.rb | 3 +++ ruby/vendor/gitlab_git/lib/gitlab/git/repository.rb | 6 +++++- ruby/vendor/gitlab_git/lib/gitlab/git/rev_list.rb | 9 ++++++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ruby/vendor/gitlab_git/REVISION b/ruby/vendor/gitlab_git/REVISION index a5f63575aa4..f5e2466a89c 100644 --- a/ruby/vendor/gitlab_git/REVISION +++ b/ruby/vendor/gitlab_git/REVISION @@ -1 +1 @@ -930ad88a87b0814173989aaccc6dc8af00d1bf65 +fddcfae6d8cc3790fe100584f8d7c09e014b01e1 diff --git a/ruby/vendor/gitlab_git/lib/gitlab/git/commit.rb b/ruby/vendor/gitlab_git/lib/gitlab/git/commit.rb index 89f761dd515..c9806cdb85f 100644 --- a/ruby/vendor/gitlab_git/lib/gitlab/git/commit.rb +++ b/ruby/vendor/gitlab_git/lib/gitlab/git/commit.rb @@ -60,6 +60,9 @@ module Gitlab # Some weird thing? return nil unless commit_id.is_a?(String) + # This saves us an RPC round trip. + return nil if commit_id.include?(':') + commit = repo.gitaly_migrate(:find_commit) do |is_enabled| if is_enabled repo.gitaly_commit_client.find_commit(commit_id) diff --git a/ruby/vendor/gitlab_git/lib/gitlab/git/repository.rb b/ruby/vendor/gitlab_git/lib/gitlab/git/repository.rb index d1b13ca2342..93f9adaf1f1 100644 --- a/ruby/vendor/gitlab_git/lib/gitlab/git/repository.rb +++ b/ruby/vendor/gitlab_git/lib/gitlab/git/repository.rb @@ -1543,7 +1543,7 @@ module Gitlab end end - def rev_list(including: [], excluding: [], objects: false, &block) + def rev_list(including: [], excluding: [], options: [], objects: false, &block) args = ['rev-list'] args.push(*rev_list_param(including)) @@ -1556,6 +1556,10 @@ module Gitlab args.push('--objects') if objects + if options.any? + args.push(*options) + end + run_git!(args, lazy_block: block) end diff --git a/ruby/vendor/gitlab_git/lib/gitlab/git/rev_list.rb b/ruby/vendor/gitlab_git/lib/gitlab/git/rev_list.rb index 38c3a55f96f..79544ccf13d 100644 --- a/ruby/vendor/gitlab_git/lib/gitlab/git/rev_list.rb +++ b/ruby/vendor/gitlab_git/lib/gitlab/git/rev_list.rb @@ -38,7 +38,10 @@ module Gitlab end def all_objects(require_path: nil, &lazy_block) - get_objects(including: :all, require_path: require_path, &lazy_block) + get_objects(including: :all, + options: ["--filter=blob:limit=#{Gitlab::Git::Blob::LFS_POINTER_MAX_SIZE}"], + require_path: require_path, + &lazy_block) end # This methods returns an array of missed references @@ -54,8 +57,8 @@ module Gitlab repository.rev_list(args).split("\n") end - def get_objects(including: [], excluding: [], require_path: nil) - opts = { including: including, excluding: excluding, objects: true } + def get_objects(including: [], excluding: [], options: [], require_path: nil) + opts = { including: including, excluding: excluding, options: options, objects: true } repository.rev_list(opts) do |lazy_output| objects = objects_from_output(lazy_output, require_path: require_path) -- GitLab From 9ea2d8aa7505ee6ff5478a3428090de30230ad20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20L=C3=B3pez?= Date: Wed, 6 Jun 2018 19:33:27 +0200 Subject: [PATCH 02/13] Adding changelog --- changelogs/unreleased/fj-vendoring-ruby-dir.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/unreleased/fj-vendoring-ruby-dir.yml diff --git a/changelogs/unreleased/fj-vendoring-ruby-dir.yml b/changelogs/unreleased/fj-vendoring-ruby-dir.yml new file mode 100644 index 00000000000..343dfa6b080 --- /dev/null +++ b/changelogs/unreleased/fj-vendoring-ruby-dir.yml @@ -0,0 +1,5 @@ +--- +title: Vendor gitlab_git at fddcfae6d8cc3790fe100584f8d7c09e014b01e1 +merge_request: 753 +author: +type: other -- GitLab From 6d83c41480eeb3c360cb640ea7edec3b8955e379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20L=C3=B3pez?= Date: Wed, 6 Jun 2018 19:35:25 +0200 Subject: [PATCH 03/13] Rephrasing changelog --- changelogs/unreleased/fj-vendoring-ruby-dir.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/unreleased/fj-vendoring-ruby-dir.yml b/changelogs/unreleased/fj-vendoring-ruby-dir.yml index 343dfa6b080..ec957da927e 100644 --- a/changelogs/unreleased/fj-vendoring-ruby-dir.yml +++ b/changelogs/unreleased/fj-vendoring-ruby-dir.yml @@ -1,5 +1,5 @@ --- -title: Vendor gitlab_git at fddcfae6d8cc3790fe100584f8d7c09e014b01e1 +title: Vendoring ruby dir to fddcfae6d8cc3790fe100584f8d7c09e014b01e1 merge_request: 753 author: type: other -- GitLab From d25c6cd00078c6bee8173e948d78478c0f43fb72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20L=C3=B3pez?= Date: Thu, 7 Jun 2018 10:29:23 +0200 Subject: [PATCH 04/13] Re-vendoring again --- changelogs/unreleased/fj-vendoring-ruby-dir.yml | 2 +- ruby/vendor/gitlab_git/REVISION | 2 +- ruby/vendor/gitlab_git/lib/gitlab/git/lfs_changes.rb | 4 +++- ruby/vendor/gitlab_git/lib/gitlab/git/rev_list.rb | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/changelogs/unreleased/fj-vendoring-ruby-dir.yml b/changelogs/unreleased/fj-vendoring-ruby-dir.yml index ec957da927e..9bc9698e1fa 100644 --- a/changelogs/unreleased/fj-vendoring-ruby-dir.yml +++ b/changelogs/unreleased/fj-vendoring-ruby-dir.yml @@ -1,5 +1,5 @@ --- -title: Vendoring ruby dir to fddcfae6d8cc3790fe100584f8d7c09e014b01e1 +title: Vendoring ruby dir to 543459794a96c19e832ccfb6bb855cb60a84247f merge_request: 753 author: type: other diff --git a/ruby/vendor/gitlab_git/REVISION b/ruby/vendor/gitlab_git/REVISION index f5e2466a89c..8cc28f0e7f6 100644 --- a/ruby/vendor/gitlab_git/REVISION +++ b/ruby/vendor/gitlab_git/REVISION @@ -1 +1 @@ -fddcfae6d8cc3790fe100584f8d7c09e014b01e1 +543459794a96c19e832ccfb6bb855cb60a84247f diff --git a/ruby/vendor/gitlab_git/lib/gitlab/git/lfs_changes.rb b/ruby/vendor/gitlab_git/lib/gitlab/git/lfs_changes.rb index b9e5cf258f4..320b2ad007b 100644 --- a/ruby/vendor/gitlab_git/lib/gitlab/git/lfs_changes.rb +++ b/ruby/vendor/gitlab_git/lib/gitlab/git/lfs_changes.rb @@ -39,7 +39,9 @@ module Gitlab end def git_all_pointers - rev_list.all_objects(require_path: true) do |object_ids| + params = { options: ["--filter=blob:limit=#{Gitlab::Git::Blob::LFS_POINTER_MAX_SIZE}"], require_path: true } + + rev_list.all_objects(params) do |object_ids| Gitlab::Git::Blob.batch_lfs_pointers(@repository, object_ids) end end diff --git a/ruby/vendor/gitlab_git/lib/gitlab/git/rev_list.rb b/ruby/vendor/gitlab_git/lib/gitlab/git/rev_list.rb index 79544ccf13d..33b641a090b 100644 --- a/ruby/vendor/gitlab_git/lib/gitlab/git/rev_list.rb +++ b/ruby/vendor/gitlab_git/lib/gitlab/git/rev_list.rb @@ -37,9 +37,9 @@ module Gitlab get_objects(opts, &lazy_block) end - def all_objects(require_path: nil, &lazy_block) + def all_objects(options: [], require_path: nil, &lazy_block) get_objects(including: :all, - options: ["--filter=blob:limit=#{Gitlab::Git::Blob::LFS_POINTER_MAX_SIZE}"], + options: options, require_path: require_path, &lazy_block) end -- GitLab From 8bf7dd77d1268b3b4f84eeab610fbb4b6bc544a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20L=C3=B3pez?= Date: Thu, 7 Jun 2018 17:50:35 +0200 Subject: [PATCH 05/13] Re-vendoring --- changelogs/unreleased/fj-vendoring-ruby-dir.yml | 2 +- ruby/vendor/gitlab_git/REVISION | 2 +- ruby/vendor/gitlab_git/lib/gitlab/git/lfs_changes.rb | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/changelogs/unreleased/fj-vendoring-ruby-dir.yml b/changelogs/unreleased/fj-vendoring-ruby-dir.yml index 9bc9698e1fa..f4ac4994d09 100644 --- a/changelogs/unreleased/fj-vendoring-ruby-dir.yml +++ b/changelogs/unreleased/fj-vendoring-ruby-dir.yml @@ -1,5 +1,5 @@ --- -title: Vendoring ruby dir to 543459794a96c19e832ccfb6bb855cb60a84247f +title: Vendoring ruby dir to 570c4928aaca1a0842c2dfdc8240f99e72ba1fc4 merge_request: 753 author: type: other diff --git a/ruby/vendor/gitlab_git/REVISION b/ruby/vendor/gitlab_git/REVISION index 8cc28f0e7f6..a614bd6d5ea 100644 --- a/ruby/vendor/gitlab_git/REVISION +++ b/ruby/vendor/gitlab_git/REVISION @@ -1 +1 @@ -543459794a96c19e832ccfb6bb855cb60a84247f +570c4928aaca1a0842c2dfdc8240f99e72ba1fc4 diff --git a/ruby/vendor/gitlab_git/lib/gitlab/git/lfs_changes.rb b/ruby/vendor/gitlab_git/lib/gitlab/git/lfs_changes.rb index 320b2ad007b..b230289e7bf 100644 --- a/ruby/vendor/gitlab_git/lib/gitlab/git/lfs_changes.rb +++ b/ruby/vendor/gitlab_git/lib/gitlab/git/lfs_changes.rb @@ -39,7 +39,11 @@ module Gitlab end def git_all_pointers - params = { options: ["--filter=blob:limit=#{Gitlab::Git::Blob::LFS_POINTER_MAX_SIZE}"], require_path: true } + params = { require_path: true } + + if Gitlab::Git.version >= Gitlab::VersionInfo.parse('2.16.0') + params[:options] = ["--filter=blob:limit=#{Gitlab::Git::Blob::LFS_POINTER_MAX_SIZE}"] + end rev_list.all_objects(params) do |object_ids| Gitlab::Git::Blob.batch_lfs_pointers(@repository, object_ids) -- GitLab From ef7cff1fda14a3b6da78602d6950e3b1d61ffc10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20L=C3=B3pez?= Date: Thu, 7 Jun 2018 17:56:14 +0200 Subject: [PATCH 06/13] Adding Gitlab::VersionInfo to the vendoring --- _support/vendor-gitlab-git | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_support/vendor-gitlab-git b/_support/vendor-gitlab-git index 705de323997..124128ef527 100755 --- a/_support/vendor-gitlab-git +++ b/_support/vendor-gitlab-git @@ -5,7 +5,8 @@ FILE_LIST = %w[ lib/gitlab/git.rb lib/gitlab/git lib/gitlab/encoding_helper.rb - lib/gitlab/utils/strong_memoize.rb + lib/gitlab/utils/strong_memoize.rb + lib/gitlab/version_info.rb ].freeze REMOTE = 'https://gitlab.com/gitlab-org/gitlab-ce'.freeze -- GitLab From 5ebf884ae35307b70d6cf557a214254a8ac24af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20L=C3=B3pez?= Date: Thu, 7 Jun 2018 18:02:03 +0200 Subject: [PATCH 07/13] Adding Gitlab::VersionInfo file --- .../unreleased/fj-vendoring-ruby-dir.yml | 2 +- ruby/vendor/gitlab_git/REVISION | 2 +- .../gitlab_git/lib/gitlab/version_info.rb | 54 +++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 ruby/vendor/gitlab_git/lib/gitlab/version_info.rb diff --git a/changelogs/unreleased/fj-vendoring-ruby-dir.yml b/changelogs/unreleased/fj-vendoring-ruby-dir.yml index f4ac4994d09..2d8afe171f6 100644 --- a/changelogs/unreleased/fj-vendoring-ruby-dir.yml +++ b/changelogs/unreleased/fj-vendoring-ruby-dir.yml @@ -1,5 +1,5 @@ --- -title: Vendoring ruby dir to 570c4928aaca1a0842c2dfdc8240f99e72ba1fc4 +title: Vendoring ruby dir to 3b3b705ab5ca690459e40a63e101372e34f2701b merge_request: 753 author: type: other diff --git a/ruby/vendor/gitlab_git/REVISION b/ruby/vendor/gitlab_git/REVISION index a614bd6d5ea..ec4fa65ec43 100644 --- a/ruby/vendor/gitlab_git/REVISION +++ b/ruby/vendor/gitlab_git/REVISION @@ -1 +1 @@ -570c4928aaca1a0842c2dfdc8240f99e72ba1fc4 +3b3b705ab5ca690459e40a63e101372e34f2701b diff --git a/ruby/vendor/gitlab_git/lib/gitlab/version_info.rb b/ruby/vendor/gitlab_git/lib/gitlab/version_info.rb new file mode 100644 index 00000000000..6ee41e85cc9 --- /dev/null +++ b/ruby/vendor/gitlab_git/lib/gitlab/version_info.rb @@ -0,0 +1,54 @@ +module Gitlab + class VersionInfo + include Comparable + + attr_reader :major, :minor, :patch + + def self.parse(str) + if str && m = str.match(/(\d+)\.(\d+)\.(\d+)/) + VersionInfo.new(m[1].to_i, m[2].to_i, m[3].to_i) + else + VersionInfo.new + end + end + + def initialize(major = 0, minor = 0, patch = 0) + @major = major + @minor = minor + @patch = patch + end + + def <=>(other) + return unless other.is_a? VersionInfo + return unless valid? && other.valid? + + if other.major < @major + 1 + elsif @major < other.major + -1 + elsif other.minor < @minor + 1 + elsif @minor < other.minor + -1 + elsif other.patch < @patch + 1 + elsif @patch < other.patch + -1 + else + 0 + end + end + + def to_s + if valid? + "%d.%d.%d" % [@major, @minor, @patch] + else + "Unknown" + end + end + + def valid? + @major >= 0 && @minor >= 0 && @patch >= 0 && @major + @minor + @patch > 0 + end + end +end -- GitLab From 88208da5cf4b2bf11ace7156446434a8d00845cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20L=C3=B3pez?= Date: Thu, 7 Jun 2018 18:22:29 +0200 Subject: [PATCH 08/13] Requiring VersionInfo --- ruby/lib/gitlab/git.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/ruby/lib/gitlab/git.rb b/ruby/lib/gitlab/git.rb index fd984d3db09..aeac7aafb78 100644 --- a/ruby/lib/gitlab/git.rb +++ b/ruby/lib/gitlab/git.rb @@ -28,6 +28,7 @@ vendor_gitlab_git = '../../vendor/gitlab_git/' # Some later requires are order-sensitive. Manually require whatever we need. require_relative File.join(vendor_gitlab_git, 'lib/gitlab/encoding_helper.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/utils/strong_memoize.rb') +require_relative File.join(vendor_gitlab_git, 'lib/gitlab/version_info.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/git.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/git/popen.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/git/ref.rb') -- GitLab From 9179739a022c4b9a894c96a0c174879ed9ecfa2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20L=C3=B3pez?= Date: Thu, 7 Jun 2018 18:28:29 +0200 Subject: [PATCH 09/13] Requiring first popen --- ruby/lib/gitlab/git.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruby/lib/gitlab/git.rb b/ruby/lib/gitlab/git.rb index aeac7aafb78..b89c20a8fed 100644 --- a/ruby/lib/gitlab/git.rb +++ b/ruby/lib/gitlab/git.rb @@ -28,9 +28,9 @@ vendor_gitlab_git = '../../vendor/gitlab_git/' # Some later requires are order-sensitive. Manually require whatever we need. require_relative File.join(vendor_gitlab_git, 'lib/gitlab/encoding_helper.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/utils/strong_memoize.rb') +require_relative File.join(vendor_gitlab_git, 'lib/gitlab/git/popen.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/version_info.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/git.rb') -require_relative File.join(vendor_gitlab_git, 'lib/gitlab/git/popen.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/git/ref.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/git/repository_mirroring.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/git/storage/circuit_breaker_settings.rb') -- GitLab From dc02e47619d2ce32f9f4c40a36162a58f31c41ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20L=C3=B3pez?= Date: Thu, 7 Jun 2018 18:37:18 +0200 Subject: [PATCH 10/13] Playing with the order --- ruby/lib/gitlab/git.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruby/lib/gitlab/git.rb b/ruby/lib/gitlab/git.rb index b89c20a8fed..aeac7aafb78 100644 --- a/ruby/lib/gitlab/git.rb +++ b/ruby/lib/gitlab/git.rb @@ -28,9 +28,9 @@ vendor_gitlab_git = '../../vendor/gitlab_git/' # Some later requires are order-sensitive. Manually require whatever we need. require_relative File.join(vendor_gitlab_git, 'lib/gitlab/encoding_helper.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/utils/strong_memoize.rb') -require_relative File.join(vendor_gitlab_git, 'lib/gitlab/git/popen.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/version_info.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/git.rb') +require_relative File.join(vendor_gitlab_git, 'lib/gitlab/git/popen.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/git/ref.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/git/repository_mirroring.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/git/storage/circuit_breaker_settings.rb') -- GitLab From 1c081781724f10868552b2d20ed801218cb702f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20L=C3=B3pez?= Date: Thu, 7 Jun 2018 18:51:56 +0200 Subject: [PATCH 11/13] Trying monkey patch --- ruby/lib/gitlab/git.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ruby/lib/gitlab/git.rb b/ruby/lib/gitlab/git.rb index aeac7aafb78..55a5cac08dd 100644 --- a/ruby/lib/gitlab/git.rb +++ b/ruby/lib/gitlab/git.rb @@ -76,6 +76,10 @@ module Gitlab raise NotAvailableInGitalyRuby end end + + def version + Gitlab::VersionInfo.parse(Gitlab::Git.popen(%W(#{Gitlab.config.git.bin_path} --version)).first) + end end end -- GitLab From 8d1ba9a849401f18c8742f8f70396b648722a3f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20L=C3=B3pez?= Date: Thu, 7 Jun 2018 18:57:29 +0200 Subject: [PATCH 12/13] Changing the monkey patch --- ruby/lib/gitlab/git.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ruby/lib/gitlab/git.rb b/ruby/lib/gitlab/git.rb index 55a5cac08dd..62d02e12f35 100644 --- a/ruby/lib/gitlab/git.rb +++ b/ruby/lib/gitlab/git.rb @@ -77,8 +77,10 @@ module Gitlab end end - def version - Gitlab::VersionInfo.parse(Gitlab::Git.popen(%W(#{Gitlab.config.git.bin_path} --version)).first) + class << self + def version + Gitlab::VersionInfo.parse(Gitlab::Git.popen(%W(#{Gitlab.config.git.bin_path} --version)).first) + end end end end -- GitLab From fe255758ac08d37497eef4469b92959c94e85328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20L=C3=B3pez?= Date: Thu, 7 Jun 2018 19:05:03 +0200 Subject: [PATCH 13/13] Adding Gitlab::Popen --- _support/vendor-gitlab-git | 1 + .../unreleased/fj-vendoring-ruby-dir.yml | 2 +- ruby/lib/gitlab/git.rb | 7 +-- ruby/vendor/gitlab_git/REVISION | 2 +- ruby/vendor/gitlab_git/lib/gitlab/popen.rb | 48 +++++++++++++++++++ 5 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 ruby/vendor/gitlab_git/lib/gitlab/popen.rb diff --git a/_support/vendor-gitlab-git b/_support/vendor-gitlab-git index 124128ef527..38976655776 100755 --- a/_support/vendor-gitlab-git +++ b/_support/vendor-gitlab-git @@ -7,6 +7,7 @@ FILE_LIST = %w[ lib/gitlab/encoding_helper.rb lib/gitlab/utils/strong_memoize.rb lib/gitlab/version_info.rb + lib/gitlab/popen.rb ].freeze REMOTE = 'https://gitlab.com/gitlab-org/gitlab-ce'.freeze diff --git a/changelogs/unreleased/fj-vendoring-ruby-dir.yml b/changelogs/unreleased/fj-vendoring-ruby-dir.yml index 2d8afe171f6..ad0ded60403 100644 --- a/changelogs/unreleased/fj-vendoring-ruby-dir.yml +++ b/changelogs/unreleased/fj-vendoring-ruby-dir.yml @@ -1,5 +1,5 @@ --- -title: Vendoring ruby dir to 3b3b705ab5ca690459e40a63e101372e34f2701b +title: Vendoring ruby dir to 290ca339adc952bcd939d1782af95f90d3b88716 merge_request: 753 author: type: other diff --git a/ruby/lib/gitlab/git.rb b/ruby/lib/gitlab/git.rb index 62d02e12f35..5dbd174e276 100644 --- a/ruby/lib/gitlab/git.rb +++ b/ruby/lib/gitlab/git.rb @@ -29,6 +29,7 @@ vendor_gitlab_git = '../../vendor/gitlab_git/' require_relative File.join(vendor_gitlab_git, 'lib/gitlab/encoding_helper.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/utils/strong_memoize.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/version_info.rb') +require_relative File.join(vendor_gitlab_git, 'lib/gitlab/popen.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/git.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/git/popen.rb') require_relative File.join(vendor_gitlab_git, 'lib/gitlab/git/ref.rb') @@ -76,12 +77,6 @@ module Gitlab raise NotAvailableInGitalyRuby end end - - class << self - def version - Gitlab::VersionInfo.parse(Gitlab::Git.popen(%W(#{Gitlab.config.git.bin_path} --version)).first) - end - end end end diff --git a/ruby/vendor/gitlab_git/REVISION b/ruby/vendor/gitlab_git/REVISION index ec4fa65ec43..39e832ccbfc 100644 --- a/ruby/vendor/gitlab_git/REVISION +++ b/ruby/vendor/gitlab_git/REVISION @@ -1 +1 @@ -3b3b705ab5ca690459e40a63e101372e34f2701b +290ca339adc952bcd939d1782af95f90d3b88716 diff --git a/ruby/vendor/gitlab_git/lib/gitlab/popen.rb b/ruby/vendor/gitlab_git/lib/gitlab/popen.rb new file mode 100644 index 00000000000..b9832a724c4 --- /dev/null +++ b/ruby/vendor/gitlab_git/lib/gitlab/popen.rb @@ -0,0 +1,48 @@ +require 'fileutils' +require 'open3' + +module Gitlab + module Popen + extend self + + Result = Struct.new(:cmd, :stdout, :stderr, :status, :duration) + + # Returns [stdout + stderr, status] + def popen(cmd, path = nil, vars = {}, &block) + result = popen_with_detail(cmd, path, vars, &block) + + [result.stdout << result.stderr, result.status&.exitstatus] + end + + # Returns Result + def popen_with_detail(cmd, path = nil, vars = {}) + unless cmd.is_a?(Array) + raise "System commands must be given as an array of strings" + end + + path ||= Dir.pwd + vars['PWD'] = path + options = { chdir: path } + + unless File.directory?(path) + FileUtils.mkdir_p(path) + end + + cmd_stdout = '' + cmd_stderr = '' + cmd_status = nil + start = Time.now + + Open3.popen3(vars, *cmd, options) do |stdin, stdout, stderr, wait_thr| + yield(stdin) if block_given? + stdin.close + + cmd_stdout = stdout.read + cmd_stderr = stderr.read + cmd_status = wait_thr.value + end + + Result.new(cmd, cmd_stdout, cmd_stderr, cmd_status, Time.now - start) + end + end +end -- GitLab