Commit d63d1dde authored by Josip Sokcevic's avatar Josip Sokcevic Committed by LUCI CQ

Set default branch in fake_repos

Tests should start to rely on fake_repos.DEFAULT_BRANCH so it can be
renamed in the future. This is a quick fix in case
git.init.defaultBranch is set to a custom value.

Bug: 1144918
Change-Id: I1c8cd591bee6b5fe14a5de4683111a89224cb2b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2521655
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
parent e2f2c25d
......@@ -28,6 +28,8 @@ import gclient_utils
import scm
import subprocess2
DEFAULT_BRANCH = 'master'
def write(path, content):
f = open(path, 'wb')
......@@ -160,7 +162,11 @@ class FakeReposBase(object):
except (OSError, subprocess2.CalledProcessError):
return False
for repo in ['repo_%d' % r for r in range(1, self.NB_GIT_REPOS + 1)]:
# TODO(crbug.com/114712) use git.init -b and remove 'checkout' once git is
# upgraded to 2.28 on all builders.
subprocess2.check_call(['git', 'init', '-q', join(self.git_base, repo)])
subprocess2.check_call(['git', 'checkout', '-q', '-b', DEFAULT_BRANCH],
cwd=join(self.git_base, repo))
self.git_hashes[repo] = [(None, None)]
self.populateGit()
self.initialized = True
......
......@@ -18,6 +18,8 @@ import unittest
import gclient_utils
DEFAULT_BRANCH = 'master'
if sys.version_info.major == 3:
# pylint: disable=redefined-builtin
basestring = (str,)
......@@ -297,9 +299,12 @@ class GitRepo(object):
self.to_schema_refs = ['--branches']
# TODO(crbug.com/114712) use git.init -b and remove 'checkout' once git is
# upgraded to 2.28 on all builders.
self.git('init')
self.git('config', 'user.name', 'testcase')
self.git('config', 'user.email', 'testcase@example.com')
self.git('checkout', '-b', DEFAULT_BRANCH)
for commit in schema.walk():
self._add_schema_commit(commit, schema.data_for(commit.name))
self.last_commit = self[commit.name]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment