diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-04 06:08:52 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-04 06:08:52 +0300 |
commit | 7e96b8ca7aca03af3c66d00c83eff81a3273c107 (patch) | |
tree | 1737459ce8db5b0c99694934ef4c48bf1323f391 /spec/support/unpack-gitlab-git-test | |
parent | e3bac3b0e2bcc39ba899bc38d946ceb6921b7c14 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/unpack-gitlab-git-test')
-rwxr-xr-x | spec/support/unpack-gitlab-git-test | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/support/unpack-gitlab-git-test b/spec/support/unpack-gitlab-git-test new file mode 100755 index 00000000000..5d5f1b7d082 --- /dev/null +++ b/spec/support/unpack-gitlab-git-test @@ -0,0 +1,40 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'fileutils' + +REPO = 'spec/support/gitlab-git-test.git' +PACK_DIR = REPO + '/objects/pack' +GIT = %W[git --git-dir=#{REPO}].freeze +BASE_PACK = 'pack-691247af2a6acb0b63b73ac0cb90540e93614043' + +def main + unpack + # We want to store the refs in a packed-refs file because if we don't + # they can get mangled by filesystems. + abort unless system(*GIT, *%w[pack-refs --all]) + abort unless system(*GIT, 'fsck') +end + +# We don't want contributors to commit new pack files because those +# create unnecessary churn. +def unpack + pack_files = Dir[File.join(PACK_DIR, '*')].reject do |pack| + pack.start_with?(File.join(PACK_DIR, BASE_PACK)) + end + return if pack_files.empty? + + pack_files.each do |pack| + unless pack.end_with?('.pack') + FileUtils.rm(pack) + next + end + + File.open(pack, 'rb') do |open_pack| + File.unlink(pack) + abort unless system(*GIT, 'unpack-objects', in: open_pack) + end + end +end + +main |