-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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)
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' | ||
|
@@ -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 | ||
|