diff options
author | Jacob Vosmaer (GitLab) <jacob@gitlab.com> | 2017-06-28 12:30:02 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-06-28 12:30:02 +0300 |
commit | 489d8e11b39f7eae6b36d2bdcf3098548ed62e53 (patch) | |
tree | 7d3fb9c278822c4a3db0ab01d3e08d1609b4ccae /spec/support/unpack-gitlab-git-test | |
parent | 5dd6d9a9ec8aaf61d74f7509cdebf700874d8cbd (diff) |
Vendor the gitlab-git-test repo
Diffstat (limited to 'spec/support/unpack-gitlab-git-test')
-rwxr-xr-x | spec/support/unpack-gitlab-git-test | 38 |
1 files changed, 38 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..d5b4912457d --- /dev/null +++ b/spec/support/unpack-gitlab-git-test @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby +require 'fileutils' + +REPO = 'spec/support/gitlab-git-test.git'.freeze +PACK_DIR = REPO + '/objects/pack' +GIT = %W[git --git-dir=#{REPO}].freeze +BASE_PACK = 'pack-691247af2a6acb0b63b73ac0cb90540e93614043'.freeze + +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 |