From cb29e7ffc92040706270505ba7b10d37974eddad Mon Sep 17 00:00:00 2001 From: Rick Lan Date: Wed, 17 Jul 2024 19:40:43 +0800 Subject: [PATCH] limited branches to those available from updated --- selfdrive/ui/qt/offroad/software_settings.cc | 11 ++++++----- system/updated/updated.py | 7 ++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/selfdrive/ui/qt/offroad/software_settings.cc b/selfdrive/ui/qt/offroad/software_settings.cc index 549ae529b..c46a9f27a 100644 --- a/selfdrive/ui/qt/offroad/software_settings.cc +++ b/selfdrive/ui/qt/offroad/software_settings.cc @@ -64,11 +64,12 @@ SoftwarePanel::SoftwarePanel(QWidget* parent) : ListWidget(parent) { connect(targetBranchBtn, &ButtonControl::clicked, [=]() { auto current = params.get("GitBranch"); QStringList branches = QString::fromStdString(params.get("UpdaterAvailableBranches")).split(","); - for (QString b : {current.c_str(), "devel-staging", "devel", "nightly", "master-ci", "master"}) { - auto i = branches.indexOf(b); - if (i >= 0) { - branches.removeAt(i); - branches.insert(0, b); + if (!branches.isEmpty()) { + QString current = QString::fromStdString(params.get("CurrentBranch")); + int currentIndex = branches.indexOf(current); + if (currentIndex >= 0) { + branches.removeAt(currentIndex); + branches.insert(0, current); } } diff --git a/system/updated/updated.py b/system/updated/updated.py index e753fd76f..c87f79e66 100755 --- a/system/updated/updated.py +++ b/system/updated/updated.py @@ -271,13 +271,18 @@ class Updater: def get_commit_hash(self, path: str = OVERLAY_MERGED) -> str: return run(["git", "rev-parse", "HEAD"], path).rstrip() + def filter_branches(self, branches, prefixes): + return [branch for branch in branches if any(branch.startswith(prefix) for prefix in prefixes)] + def set_params(self, update_success: bool, failed_count: int, exception: str | None) -> None: self.params.put("UpdateFailedCount", str(failed_count)) self.params.put("UpdaterTargetBranch", self.target_branch) self.params.put_bool("UpdaterFetchAvailable", self.update_available) if len(self.branches): - self.params.put("UpdaterAvailableBranches", ','.join(self.branches.keys())) + allowed_prefixes = ['beta3', 'release3'] + filtered_branches = self.filter_branches(self.branches.keys(), allowed_prefixes) + self.params.put("UpdaterAvailableBranches", ','.join(filtered_branches)) last_update = datetime.datetime.now(datetime.UTC).replace(tzinfo=None) if update_success: