Skip to content

Commit 478ee13

Browse files
committed
fix: allow the file protocol during git tests
Unfortunately, the simple way that is using Git.default_options does not work for recursive initialization of submodules (since the config is not propagated to the submodules themselves)
1 parent 7131a39 commit 478ee13

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/import/test_git.rb

+23
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@
44
attr_reader :pkg, :importer, :gitrepo
55

66
before do
7+
xdg_config_home = make_tmpdir
8+
git_config = File.join(xdg_config_home, "git", "config")
9+
FileUtils.mkdir_p File.dirname(git_config)
10+
@current_xdg_config_home = ENV["XDG_CONFIG_HOME"]
11+
ENV["XDG_CONFIG_HOME"] = xdg_config_home
12+
13+
File.write(git_config, <<~GIT_CONFIG)
14+
[user]
15+
16+
name = Someone
17+
18+
[protocol "file"]
19+
allow = always
20+
GIT_CONFIG
21+
22+
unless system("git", "config", "--global", "protocol.file.allow", "always")
23+
raise "could not set up temporary global git configuration"
24+
end
25+
726
tempdir = untar('gitrepo.tar')
827
@gitrepo = File.join(tempdir, 'gitrepo.git')
928
@pkg = Autobuild::Package.new 'test'
@@ -12,6 +31,10 @@
1231
pkg.importer = importer
1332
end
1433

34+
after do
35+
ENV["XDG_CONFIG_HOME"] = @current_xdg_config_home
36+
end
37+
1538
describe "#initialize" do
1639
it "allows passing the branch as second argument for backward-compatibility way" do
1740
Autobuild.silent = true

0 commit comments

Comments
 (0)