Commit db76e22f authored by Toon Claes's avatar Toon Claes

TaskHelpers: Enable git protocol v2

Doing git-fetch(1) to get an object by ID might fail when the git
repository is a shallow clone. To make sure, even older versions of, git
is able to pull those in, configure the repository to use git protocol
version 2.
parent 1e9b0186
......@@ -190,6 +190,9 @@ module Gitlab
end
def checkout_version(version, target_dir)
# Explicitly setting the git protocol version to v2 allows older Git binaries
# to do have a shallow clone obtain objects by object ID.
run_command!(%W[#{Gitlab.config.git.bin_path} -C #{target_dir} config protocol.version 2])
run_command!(%W[#{Gitlab.config.git.bin_path} -C #{target_dir} fetch --quiet origin #{version}])
run_command!(%W[#{Gitlab.config.git.bin_path} -C #{target_dir} checkout -f --quiet FETCH_HEAD --])
end
......
......@@ -71,6 +71,8 @@ RSpec.describe Gitlab::TaskHelpers do
describe '#checkout_version' do
it 'clones the repo in the target dir' do
expect(subject)
.to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} config protocol.version 2])
expect(subject)
.to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} fetch --quiet origin #{tag}])
expect(subject)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment