From 478ee139ebca4729ab563702df38c4492c17d27b Mon Sep 17 00:00:00 2001 From: Sylvain Date: Sun, 8 Sep 2024 15:46:21 -0300 Subject: [PATCH] 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) --- test/import/test_git.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/import/test_git.rb b/test/import/test_git.rb index f8917c26..343bab1d 100644 --- a/test/import/test_git.rb +++ b/test/import/test_git.rb @@ -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 = someone.testing@autobuild.org + 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' @@ -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