repo: Add support for leaf_devices
Change-Id: I4769f8fcb512f5196929f81ac76126d2f608932c
diff --git a/repo/repo_settings.py b/repo/repo_settings.py
index 34194ae..a6401fc 100755
--- a/repo/repo_settings.py
+++ b/repo/repo_settings.py
@@ -19,14 +19,17 @@
import requests
import subprocess
import sys
+import yaml
from xml.etree import ElementTree
PORT = "29418"
GERRIT = "review.leafos.org"
+leaf_devices = "leaf/devices/devices.yaml"
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("-b", "--branch")
+ parser.add_argument("-d", "--device")
parser.add_argument("-f", "--project_file",
default=".repo/manifests/snippets/leaf.xml")
return parser.parse_args()
@@ -97,6 +100,19 @@
check=False,
)
+def get_projects_from_devices(device, branch):
+ projects = []
+
+ with open(leaf_devices) as f:
+ root = yaml.safe_load(f)
+
+ for item in root:
+ if device in item["device"]:
+ for repository in item["repositories"]:
+ projects.append({"name": repository["name"], "revision": branch})
+
+ return projects
+
def get_projects_from_manifests(project_file, branch):
projects = []
@@ -116,7 +132,10 @@
gh_token = check_gh_token()
gh_user = check_gh_user(gh_token)
- projects = get_projects_from_manifests(args.project_file, args.branch)
+ if (args.device):
+ projects = get_projects_from_devices(args.device, args.branch)
+ else:
+ projects = get_projects_from_manifests(args.project_file, args.branch)
for project in projects:
name = project["name"]
if ("LeafOS-Project" in name) or ("LeafOS-Blobs" in name) or ("LeafOS-Devices" in name):