aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-11-13 16:24:03 -0800
committerDylan Baker <dylan@pnwbakers.com>2020-11-16 10:19:15 -0800
commit85550e8fce3d2a1547db9fccc81e496d278eed90 (patch)
treefaa27463b1e4e94b4462f7f7392ec13088bc2d2d /run_unittests.py
parent6431a0f89d973a9096684d5670cf54b2715aa0cc (diff)
downloadmeson-85550e8fce3d2a1547db9fccc81e496d278eed90.zip
meson-85550e8fce3d2a1547db9fccc81e496d278eed90.tar.gz
meson-85550e8fce3d2a1547db9fccc81e496d278eed90.tar.bz2
run_unittests: correctly handle users setting init.defaultBranch
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/run_unittests.py b/run_unittests.py
index 308a091..4051e3b 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -135,7 +135,15 @@ def is_pull():
return False
def _git_init(project_dir):
- subprocess.check_call(['git', 'init'], cwd=project_dir, stdout=subprocess.DEVNULL)
+ # If a user has git configuration init.defaultBranch set we want to override that
+ with tempfile.TemporaryDirectory() as d:
+ out = git(['--version'], str(d))[1]
+ if version_compare(mesonbuild.environment.search_version(out), '>= 2.28'):
+ extra_cmd = ['--initial-branch', 'master']
+ else:
+ extra_cmd = []
+
+ subprocess.check_call(['git', 'init'] + extra_cmd, cwd=project_dir, stdout=subprocess.DEVNULL)
subprocess.check_call(['git', 'config',
'user.name', 'Author Person'], cwd=project_dir)
subprocess.check_call(['git', 'config',
@@ -9154,8 +9162,16 @@ class SubprojectsCommandTests(BasePlatformTests):
return self._git_remote(['rev-parse', ref], name)
def _git_create_repo(self, path):
+ # If a user has git configuration init.defaultBranch set we want to override that
+ with tempfile.TemporaryDirectory() as d:
+ out = git(['--version'], str(d))[1]
+ if version_compare(mesonbuild.environment.search_version(out), '>= 2.28'):
+ extra_cmd = ['--initial-branch', 'master']
+ else:
+ extra_cmd = []
+
self._create_project(path)
- self._git(['init'], path)
+ self._git(['init'] + extra_cmd, path)
self._git_config(path)
self._git(['add', '.'], path)
self._git(['commit', '-m', 'Initial commit'], path)