Skip to content

Commit f78cb00

Browse files
committed
feat: add remove-project functionality
1 parent 3dcf254 commit f78cb00

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

TODO.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
- make vendor pulling work for multiple devices
33
- GSI/patch handling
44
- fix telegram/curl failure on devices like "poplar_canada"
5+
- project linkfile handling

py-utils/xml_manifest_gen.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66
from urllib.request import urlopen, Request
77

88

9-
def is_in_manifest(manifest: xml, project_path: str = "", project_remote: str = "") -> bool:
9+
def is_in_manifest(manifest: xml, project_path: str = "", project_remote: str = "", project_remove: str = "") -> bool:
1010
for manifest_project in manifest.findall("project"):
1111
if project_path == manifest_project.get("path"):
1212
return True
1313

14+
for manifest_project in manifest.findall("remove-project"):
15+
if project_remove == manifest_project.get("name"):
16+
return True
17+
1418
for manifest_project in manifest.findall("remote"):
1519
if project_remote == manifest_project.get("name"):
1620
return True
@@ -40,6 +44,20 @@ def add_project_to_manifest(manifest: xml, project_name: str, project_path: str,
4044
manifest.append(element)
4145
return manifest
4246

47+
def add_project_remove_to_manifest(manifest: xml, project_remove_name: str) -> xml:
48+
if is_in_manifest(manifest=manifest, project_remove=project_remove_name):
49+
return manifest
50+
51+
element = ElementTree.Element(
52+
"remove-project",
53+
attrib={
54+
"name": project_remove_name,
55+
},
56+
)
57+
58+
manifest.append(element)
59+
return manifest
60+
4361

4462
def add_remote_to_manifest(manifest: xml, remote_name: str, remote_fetch: str, remote_revision: str = "") -> xml:
4563
if is_in_manifest(manifest=manifest, project_remote=remote_name):
@@ -74,6 +92,12 @@ def generate_manifest(local_manifest: xml, remote_manifest: xml) -> xml:
7492
remote_revision=revision
7593
)
7694

95+
for projects in remote_manifest.findall("remove-project"):
96+
local_manifest = add_project_remove_to_manifest(
97+
manifest=local_manifest,
98+
project_remove_name=projects.get("name")
99+
)
100+
77101
for projects in remote_manifest.findall("project"):
78102
if projects.get("remote") == "":
79103
remote = ""

0 commit comments

Comments
 (0)