mirror of
https://gerrit.googlesource.com/git-repo
synced 2026-07-15 21:27:00 +00:00
init: Add --use-local-gitdirs for standard Git layouts
Introduce --use-local-gitdirs to bypass repo's symlink-based layouts in favor of standard local .git directories. Bug: 513329573 Bug: 508146070 Change-Id: I53d1602e61be0b86964529bcbea3dc801471f9c9 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/569001 Tested-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com> Reviewed-by: Dan Willemsen <dwillemsen@google.com>
This commit is contained in:
committed by
gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
2d54384a5e
commit
b8531133de
@@ -819,6 +819,26 @@ class TestProjectElement:
|
||||
str(repo_client.topdir), ".repo", "projects", "..git"
|
||||
)
|
||||
|
||||
def test_get_project_paths_local_gitdirs(
|
||||
self, repo_client: RepoClient
|
||||
) -> None:
|
||||
"""Check GetProjectPaths with UseLocalGitDirs."""
|
||||
manifest = repo_client.get_xml_manifest(
|
||||
'<?xml version="1.0" encoding="UTF-8"?><manifest></manifest>'
|
||||
)
|
||||
manifest.manifestProject.config.SetBoolean("repo.uselocalgitdirs", True)
|
||||
|
||||
relpath, worktree, gitdir, objdir, use_git_worktrees = (
|
||||
manifest.GetProjectPaths("foo", "bar", "origin")
|
||||
)
|
||||
|
||||
assert os.path.normpath(gitdir) == os.path.normpath(
|
||||
os.path.join(str(repo_client.topdir), "bar", ".git")
|
||||
)
|
||||
assert os.path.normpath(objdir) == os.path.normpath(
|
||||
os.path.join(str(repo_client.topdir), "bar", ".git")
|
||||
)
|
||||
|
||||
def test_bad_path_name_checks(self, repo_client: RepoClient) -> None:
|
||||
"""Check handling of bad path & name attributes."""
|
||||
|
||||
|
||||
@@ -657,6 +657,9 @@ class ManifestPropertiesFetchedCorrectly(unittest.TestCase):
|
||||
fakeproj.config.SetBoolean("repo.worktree", False)
|
||||
self.assertFalse(fakeproj.use_worktree)
|
||||
|
||||
fakeproj.config.SetBoolean("repo.uselocalgitdirs", False)
|
||||
self.assertFalse(fakeproj.use_local_gitdirs)
|
||||
|
||||
fakeproj.config.SetBoolean("repo.clonebundle", False)
|
||||
self.assertFalse(fakeproj.clone_bundle)
|
||||
|
||||
@@ -691,6 +694,54 @@ class ManifestPropertiesFetchedCorrectly(unittest.TestCase):
|
||||
fakeproj.config.SetString("manifest.platform", "auto")
|
||||
self.assertEqual(fakeproj.manifest_platform, "auto")
|
||||
|
||||
def test_sync_use_local_gitdirs_worktree_conflict(self):
|
||||
"""Test that --use-local-gitdirs conflicts with --worktree."""
|
||||
with utils_for_test.TempGitTree() as tempdir:
|
||||
fakeproj = self.setUpManifest(tempdir)
|
||||
|
||||
class DummyManifest:
|
||||
is_submanifest = False
|
||||
|
||||
def GetDefaultGroupsStr(self, with_platform=False):
|
||||
return ""
|
||||
|
||||
fakeproj.manifest = DummyManifest()
|
||||
|
||||
result = fakeproj.Sync(use_local_gitdirs=True, worktree=True)
|
||||
self.assertFalse(result)
|
||||
|
||||
def test_sync_use_local_gitdirs_archive_conflict(self):
|
||||
"""Test that --use-local-gitdirs conflicts with --archive."""
|
||||
with utils_for_test.TempGitTree() as tempdir:
|
||||
fakeproj = self.setUpManifest(tempdir)
|
||||
|
||||
class DummyManifest:
|
||||
is_submanifest = False
|
||||
|
||||
def GetDefaultGroupsStr(self, with_platform=False):
|
||||
return ""
|
||||
|
||||
fakeproj.manifest = DummyManifest()
|
||||
|
||||
result = fakeproj.Sync(use_local_gitdirs=True, archive=True)
|
||||
self.assertFalse(result)
|
||||
|
||||
def test_sync_use_local_gitdirs_mirror_conflict(self):
|
||||
"""Test that --use-local-gitdirs conflicts with --mirror."""
|
||||
with utils_for_test.TempGitTree() as tempdir:
|
||||
fakeproj = self.setUpManifest(tempdir)
|
||||
|
||||
class DummyManifest:
|
||||
is_submanifest = False
|
||||
|
||||
def GetDefaultGroupsStr(self, with_platform=False):
|
||||
return ""
|
||||
|
||||
fakeproj.manifest = DummyManifest()
|
||||
|
||||
result = fakeproj.Sync(use_local_gitdirs=True, mirror=True)
|
||||
self.assertFalse(result)
|
||||
|
||||
|
||||
class StatelessSyncTests(unittest.TestCase):
|
||||
"""Tests for stateless sync strategy."""
|
||||
|
||||
Reference in New Issue
Block a user