summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaman Tenneti <rtenneti@google.com>2021-02-01 11:15:16 -0800
committerRaman Tenneti <rtenneti@google.com>2021-02-01 12:24:51 -0800
commit7caa3658b2d9c7f8d48d8c659a39bb412037f74f (patch)
tree0ebc3aba17548389f23c57d9c3d846d2338b20f2
parent9e7875315f8d49a8a58a1b22c5750a11b90ca751 (diff)
downloadgit-repo-7caa3658b2d9c7f8d48d8c659a39bb412037f74f.tar.gz
sync: Do a git pull with --use-superproject if superproject tree already exists.
Tested the code with the following commands. $ ./run_tests -v tests/test_git_superproject.py $ ./run_tests -v Tested the sync code by copying all the repo changes into my Android AOSP checkout and doing a repo sync --use-superproject twice. .../WORKING_DIRECTORY$ repo sync --use-superproject Bug: https://crbug.com/gerrit/13709 Bug: https://crbug.com/gerrit/13707 Tested-by: Raman Tenneti <rtenneti@google.com> Change-Id: I7e4b1e51ca1d18b836a5fa8d139a0765262ba500
-rw-r--r--git_superproject.py2
-rw-r--r--tests/test_git_superproject.py7
2 files changed, 8 insertions, 1 deletions
diff --git a/git_superproject.py b/git_superproject.py
index e2045cfd..157a1fbb 100644
--- a/git_superproject.py
+++ b/git_superproject.py
@@ -63,7 +63,7 @@ class Superproject(object):
63 True if 'git clone <url> <branch>' is successful, or False. 63 True if 'git clone <url> <branch>' is successful, or False.
64 """ 64 """
65 os.mkdir(self._superproject_path) 65 os.mkdir(self._superproject_path)
66 cmd = ['clone', url, '--filter', 'blob:none'] 66 cmd = ['clone', url, '--depth', '1']
67 if branch: 67 if branch:
68 cmd += ['--branch', branch] 68 cmd += ['--branch', branch]
69 p = GitCommand(None, 69 p = GitCommand(None,
diff --git a/tests/test_git_superproject.py b/tests/test_git_superproject.py
index 67a75a17..4012ec26 100644
--- a/tests/test_git_superproject.py
+++ b/tests/test_git_superproject.py
@@ -61,6 +61,13 @@ class SuperprojectTestCase(unittest.TestCase):
61 with mock.patch.object(self._superproject, '_Clone', return_value=False): 61 with mock.patch.object(self._superproject, '_Clone', return_value=False):
62 self._superproject.GetAllProjectsSHAs(url='localhost') 62 self._superproject.GetAllProjectsSHAs(url='localhost')
63 63
64 def test_superproject_get_project_shas_mock_pull(self):
65 """Test with _Pull failing."""
66 with self.assertRaises(GitError):
67 with mock.patch.object(self._superproject, '_Clone', return_value=True):
68 with mock.patch.object(self._superproject, '_Pull', return_value=False):
69 self._superproject.GetAllProjectsSHAs(url='localhost')
70
64 def test_superproject_get_project_shas_mock_ls_tree(self): 71 def test_superproject_get_project_shas_mock_ls_tree(self):
65 """Test with LsTree being a mock.""" 72 """Test with LsTree being a mock."""
66 data = ('120000 blob 158258bdf146f159218e2b90f8b699c4d85b5804\tAndroid.bp\x00' 73 data = ('120000 blob 158258bdf146f159218e2b90f8b699c4d85b5804\tAndroid.bp\x00'