Skip to content

Commit

Permalink
fix: allow the file protocol during git tests
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
doudou committed Sep 8, 2024
1 parent 7131a39 commit 478ee13
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/import/test_git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@
attr_reader :pkg, :importer, :gitrepo

before do
xdg_config_home = make_tmpdir
git_config = File.join(xdg_config_home, "git", "config")
FileUtils.mkdir_p File.dirname(git_config)
@current_xdg_config_home = ENV["XDG_CONFIG_HOME"]
ENV["XDG_CONFIG_HOME"] = xdg_config_home

File.write(git_config, <<~GIT_CONFIG)
[user]
email = [email protected]
name = Someone
[protocol "file"]
allow = always
GIT_CONFIG

unless system("git", "config", "--global", "protocol.file.allow", "always")
raise "could not set up temporary global git configuration"
end

tempdir = untar('gitrepo.tar')
@gitrepo = File.join(tempdir, 'gitrepo.git')
@pkg = Autobuild::Package.new 'test'
Expand All @@ -12,6 +31,10 @@
pkg.importer = importer
end

after do
ENV["XDG_CONFIG_HOME"] = @current_xdg_config_home
end

describe "#initialize" do
it "allows passing the branch as second argument for backward-compatibility way" do
Autobuild.silent = true
Expand Down

0 comments on commit 478ee13

Please sign in to comment.