limited branches to those available from updated

This commit is contained in:
Rick Lan
2024-07-17 19:40:43 +08:00
parent 8e013f7537
commit cb29e7ffc9
2 changed files with 12 additions and 6 deletions
+6 -5
View File
@@ -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);
}
}
+6 -1
View File
@@ -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: