summaryrefslogtreecommitdiff
path: root/tests/test_wrapper.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2026-03-06 17:31:33 -0500
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2026-03-12 20:09:19 -0700
commit551087cd980976775470cde5f7ede264a90b5349 (patch)
tree1d8470bd651a65e798af5454ac9cf05d9f3e917e /tests/test_wrapper.py
parent8da56a0cc5e936646b82ebf0e9fa6d61b4ba19c7 (diff)
downloadgit-repo-551087cd980976775470cde5f7ede264a90b5349.tar.gz
git-repo-551087cd980976775470cde5f7ede264a90b5349.zip
tests: add a util module for sharing code
We've started duplicating code among test modules. Start a common utils module to hold that, and migrate over TempGitTree to start. Change-Id: I10b2abd133535c90fbda4d6686602d7e5861d875 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/559041 Tested-by: Mike Frysinger <vapier@google.com> Commit-Queue: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'tests/test_wrapper.py')
-rw-r--r--tests/test_wrapper.py16
1 files changed, 3 insertions, 13 deletions
diff --git a/tests/test_wrapper.py b/tests/test_wrapper.py
index 77ceda8f7..a38705675 100644
--- a/tests/test_wrapper.py
+++ b/tests/test_wrapper.py
@@ -23,7 +23,8 @@ import tempfile
import unittest
from unittest import mock
-import git_command
+import utils_for_test
+
import main
import wrapper
@@ -408,18 +409,7 @@ class GitCheckoutTestCase(RepoWrapperTestCase):
remote = os.path.join(cls.GIT_DIR, "remote")
os.mkdir(remote)
- # Tests need to assume, that main is default branch at init,
- # which is not supported in config until 2.28.
- if git_command.git_require((2, 28, 0)):
- initstr = "--initial-branch=main"
- else:
- # Use template dir for init.
- templatedir = tempfile.mkdtemp(prefix=".test-template")
- with open(os.path.join(templatedir, "HEAD"), "w") as fp:
- fp.write("ref: refs/heads/main\n")
- initstr = "--template=" + templatedir
-
- run_git("init", initstr, cwd=remote)
+ utils_for_test.init_git_tree(remote)
run_git("commit", "--allow-empty", "-minit", cwd=remote)
run_git("branch", "stable", cwd=remote)
run_git("tag", "v1.0", cwd=remote)