Skip to content

A platform for community discussion. Free, open, simple.

DEV: Fix git deprecation warnings in specs (#15503)

Jarek Radosz910796c4b432
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index 69aa330e788..21a91ca0cae 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true
+GIT_INITIAL_BRANCH_SUPPORTED = Gem::Version.new(`git --version`.match(/[\d\.]+/)[0]) >= Gem::Version.new("2.28.0")
+
module Helpers
extend ActiveSupport::Concern
@@ -157,7 +159,7 @@ module Helpers
def setup_git_repo(files)
repo_dir = Dir.mktmpdir
- `cd #{repo_dir} && git init .`
+ `cd #{repo_dir} && git init . #{"--initial-branch=main" if GIT_INITIAL_BRANCH_SUPPORTED}`
`cd #{repo_dir} && git config user.email '[email protected]'`
`cd #{repo_dir} && git config user.name 'The Cool One'`
`cd #{repo_dir} && git config commit.gpgsign 'false'`