Merge "AIDEGen: skip generating vcs.xml when importing whole Android."
diff --git a/aidegen/lib/project_file_gen.py b/aidegen/lib/project_file_gen.py
index 3af1c66..5b70998 100644
--- a/aidegen/lib/project_file_gen.py
+++ b/aidegen/lib/project_file_gen.py
@@ -542,7 +542,7 @@
def _generate_vcs_xml(module_path):
"""Generate vcs.xml file.
- IntelliJ use vcs.xml to record version control software's information.
+ IntelliJ uses vcs.xml to record version control software's information.
Since we are using a single project file, it will only contain the
module itself. If there is no git folder inside, it would find it in
parent's folder.
@@ -553,6 +553,12 @@
Return:
String: A module's git path.
"""
+ # When importing whole Android repo, it shouldn't add vcs.xml,
+ # because IntelliJ doesn't handle repo as a version control.
+ if module_path == constant.ANDROID_ROOT_PATH:
+ # TODO(b/135103553): Do a survey about: does devs want add
+ # every git into IntelliJ when importing whole Android.
+ return None
git_path = module_path
while not os.path.isdir(os.path.join(git_path, _GIT_FOLDER_NAME)):
git_path = str(pathlib.Path(git_path).parent)
diff --git a/aidegen/lib/project_file_gen_unittest.py b/aidegen/lib/project_file_gen_unittest.py
index 9897196..4447652 100644
--- a/aidegen/lib/project_file_gen_unittest.py
+++ b/aidegen/lib/project_file_gen_unittest.py
@@ -189,6 +189,8 @@
sample_vcs = sample_vcs.replace(self._LOCAL_PATH_TOKEN,
self._ANDROID_PROJECT_PATH)
self.assertEqual(test_vcs, sample_vcs)
+ self.assertIsNone(
+ project_file_gen._generate_vcs_xml(constant.ANDROID_ROOT_PATH))
def test_get_uniq_iml_name(self):
"""Test the unique name cache mechanism.