From 8d43dea6ea4b7d1664632e555e207f617e54657b Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Sun, 7 Feb 2021 16:30:27 -0800 Subject: sync: pass --bare option when doing git clone of superproject. Changed "git pull" to "git fetch" as we are using --bare option. Used the following command to fetch: git fetch origin +refs/heads/*:refs/heads/* --prune Pass --branch argument to Superproject's UpdateProjectsRevisionId function. Returned False/None when directories don't exist instead of raise GitError exception from _Fetch and _LsTree functions. The caller of Fetch does Clone if Fetch fails. Tested the code with the following commands. $ ./run_tests -v Tested the init and sync code by copying all the repo changes into my Android AOSP checkout and running repo sync with --use-superproject option. Bug: https://crbug.com/gerrit/13709 Bug: https://crbug.com/gerrit/13707 Tested-by: Raman Tenneti Change-Id: I3e441ecdfc87c735f46eff0eb98efa63cc2eb22a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/296222 Reviewed-by: Mike Frysinger --- tests/test_git_superproject.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/test_git_superproject.py') diff --git a/tests/test_git_superproject.py b/tests/test_git_superproject.py index d2c2f501..fc9101dd 100644 --- a/tests/test_git_superproject.py +++ b/tests/test_git_superproject.py @@ -78,11 +78,11 @@ class SuperprojectTestCase(unittest.TestCase): with mock.patch.object(self._superproject, '_Clone', return_value=False): self._superproject._GetAllProjectsSHAs(url='localhost') - def test_superproject_get_project_shas_mock_pull(self): - """Test with _Pull failing.""" + def test_superproject_get_project_shas_mock_fetch(self): + """Test with _Fetch failing.""" with self.assertRaises(GitError): with mock.patch.object(self._superproject, '_Clone', return_value=True): - with mock.patch.object(self._superproject, '_Pull', return_value=False): + with mock.patch.object(self._superproject, '_Fetch', return_value=False): self._superproject._GetAllProjectsSHAs(url='localhost') def test_superproject_get_project_shas_mock_ls_tree(self): @@ -141,7 +141,7 @@ class SuperprojectTestCase(unittest.TestCase): data = ('160000 commit 2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea\tart\x00' '160000 commit e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06\tbootable/recovery\x00') with mock.patch.object(self._superproject, '_Clone', return_value=True): - with mock.patch.object(self._superproject, '_Pull', return_value=True): + with mock.patch.object(self._superproject, '_Fetch', return_value=True): with mock.patch.object(self._superproject, '_LsTree', return_value=data): # Create temporary directory so that it can write the file. os.mkdir(self._superproject._superproject_path) -- cgit v1.2.3-54-g00ecf