From 910796c4b43213eb9ff61b1b7d006feaa292b758 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Sun, 9 Jan 2022 20:26:19 +0100 Subject: [PATCH] DEV: Fix git deprecation warnings in specs (#15503) The warnings on git 2.28+ are: ``` hint: Using 'master' as the name for the initial branch. This default branch name hint: is subject to change. To configure the initial branch name to use in all hint: of your new repositories, which will suppress this warning, call: hint: hint: git config --global init.defaultBranch hint: hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and hint: 'development'. The just-created branch can be renamed via this command: hint: hint: git branch -m ``` --- spec/support/helpers.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 'someone@cool.com'` `cd #{repo_dir} && git config user.name 'The Cool One'` `cd #{repo_dir} && git config commit.gpgsign 'false'`