DEV: Fix a spec incompatibility with pre-2.28 git (#10892)

DEV: Fix a spec incompatibility with pre-2.28 git (#10892)

Regression introduced in 6932a373a34a7150f8514af7edaf9048cc719a7d

diff --git a/spec/components/version_spec.rb b/spec/components/version_spec.rb
index c843a5c..6d519a2 100644
--- a/spec/components/version_spec.rb
+++ b/spec/components/version_spec.rb
@@ -106,7 +106,7 @@ describe Discourse::VERSION do
 
         # Simulate a remote upstream
         `cd #{path} && git remote add origin #{path}/.git && git fetch -q`
-        `cd #{path} && git branch -u origin/main`
+        `cd #{path} && git branch -u origin/$(git branch --show-current)`
       end
 
       path
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index 24af7fd..6cc43fc 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -165,7 +165,7 @@ module Helpers
 
   def setup_git_repo(files)
     repo_dir = Dir.mktmpdir
-    `cd #{repo_dir} && git init . --initial-branch=main`
+    `cd #{repo_dir} && git init .`
     `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'`

GitHub sha: 572da7a5

This commit appears in #10892 which was approved by danielwaterworth. It was merged by CvX.