crowdin: Fix for subprojects
* If a project is stored within another projects folder structure,
the current implementation will treat it as "already known" and therefore
never process the project itself
* Search for the biggest path match before continuing
* Fixes: Weather providers (stored in lineage-sdk)
Change-Id: I74cc219c9ce12a6439dfde3bae4a22cdb96ab652
diff --git a/crowdin_sync.py b/crowdin_sync.py
index d69fc98..299f0da 100755
--- a/crowdin_sync.py
+++ b/crowdin_sync.py
@@ -464,21 +464,32 @@
# Search android/default.xml or config/%(branch)_extra_packages.xml
# for the project's name
+ resultPath = None
+ resultProject = None
for project in items:
path = project.attributes['path'].value
if not (result + '/').startswith(path +'/'):
continue
- if result != path:
- if path in all_projects:
- break
- result = path
- all_projects.append(result)
+ # We want the longest match, so projects in subfolders of other projects are also
+ # taken into account
+ if resultPath is None or len(path) > len(resultPath):
+ resultPath = path
+ resultProject = project
- br = project.getAttribute('revision') or branch
+ # Just in case no project was found
+ if resultPath is None:
+ continue
- push_as_commit(files, base_path, result,
- project.getAttribute('name'), br, username)
- break
+ if result != resultPath:
+ if resultPath in all_projects:
+ continue
+ result = resultPath
+ all_projects.append(result)
+
+ br = resultProject.getAttribute('revision') or branch
+
+ push_as_commit(files, base_path, result,
+ resultProject.getAttribute('name'), br, username)
def main():