spec/integration/integration_helper.rb in braid-1.1.4 vs spec/integration/integration_helper.rb in braid-1.1.5
- old
+ new
@@ -91,11 +91,11 @@
# Rough equivalent of git.require_version within Braid, but without pulling in a
# bunch of dependencies from Braid::Operations. This small amount of code
# duplication seems like a lesser evil than sorting out all the dependencies.
def git_require_version(required)
- actual = run_command('git --version').sub(/^.* version/, '').strip
+ actual = run_command('git --version').sub(/^.* version/, '').strip.sub(/ .*$/, '').strip
Gem::Version.new(actual) >= Gem::Version.new(required)
end
def update_dir_from_fixture(dir, fixture = dir)
to_dir = File.join(TMP_PATH, dir)
@@ -109,13 +109,16 @@
email = options[:email] || DEFAULT_EMAIL
git_repo = File.join(TMP_PATH, directory)
update_dir_from_fixture(directory, fixture_name)
in_dir(git_repo) do
- # Avoid a warning emitted by because we use the old default default branch name
- run_command('git config --global init.defaultBranch master')
-
- run_command('git init')
+ # If we don't specify the initial branch name, Git >= 2.30 warns that the
+ # default of `master` is subject to change. We're still using `master` for
+ # now, so avoid the warning by specifying it explicitly. Git >= 2.28 honors
+ # init.defaultBranch, while older versions of Git ignore it and are
+ # hard-coded to use `master`. (Using the `--initial-branch=master` option
+ # would cause an error on Git < 2.28, so we don't do that.)
+ run_command('git -c init.defaultBranch=master init')
run_command("git config --local user.email \"#{email}\"")
run_command("git config --local user.name \"#{name}\"")
run_command('git config --local commit.gpgsign false')
run_command('git add .')
run_command("git commit -m \"initial commit of #{fixture_name}\"")