updated: add branch switching (#25200)
* switch param * add to ui * fix that * fetch for new branch Co-authored-by: Comma Device <device@comma.ai> old-commit-hash: cc3857eb62cd169be05a4cb22c844a8b2ec94139
This commit is contained in:
@@ -126,6 +126,7 @@ std::unordered_map<std::string, uint32_t> keys = {
|
||||
{"IsOnroad", PERSISTENT},
|
||||
{"IsRHD", PERSISTENT},
|
||||
{"IsTakingSnapshot", CLEAR_ON_MANAGER_START},
|
||||
{"IsTestedBranch", CLEAR_ON_MANAGER_START},
|
||||
{"IsUpdateAvailable", CLEAR_ON_MANAGER_START},
|
||||
{"JoystickDebugMode", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_OFF},
|
||||
{"LaikadEphemeris", PERSISTENT | DONT_LOG},
|
||||
@@ -154,6 +155,7 @@ std::unordered_map<std::string, uint32_t> keys = {
|
||||
{"SnoozeUpdate", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_OFF},
|
||||
{"SshEnabled", PERSISTENT},
|
||||
{"SubscriberInfo", PERSISTENT},
|
||||
{"SwitchToBranch", CLEAR_ON_MANAGER_START},
|
||||
{"TermsVersion", PERSISTENT},
|
||||
{"Timezone", PERSISTENT},
|
||||
{"TrainingVersion", PERSISTENT},
|
||||
|
||||
@@ -20,7 +20,7 @@ from selfdrive.manager.process_config import managed_processes
|
||||
from selfdrive.athena.registration import register, UNREGISTERED_DONGLE_ID
|
||||
from system.swaglog import cloudlog, add_file_handler
|
||||
from system.version import is_dirty, get_commit, get_version, get_origin, get_short_branch, \
|
||||
terms_version, training_version
|
||||
terms_version, training_version, is_tested_branch
|
||||
|
||||
|
||||
sys.path.append(os.path.join(BASEDIR, "pyextra"))
|
||||
@@ -78,6 +78,7 @@ def manager_init() -> None:
|
||||
params.put("GitCommit", get_commit(default=""))
|
||||
params.put("GitBranch", get_short_branch(default=""))
|
||||
params.put("GitRemote", get_origin(default=""))
|
||||
params.put_bool("IsTestedBranch", is_tested_branch())
|
||||
|
||||
# set dongle id
|
||||
reg_res = register(show_spinner=True)
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "selfdrive/ui/ui.h"
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
#include "selfdrive/ui/qt/qt_window.h"
|
||||
#include "selfdrive/ui/qt/widgets/input.h"
|
||||
|
||||
TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) {
|
||||
// param, title, desc, icon
|
||||
@@ -253,7 +254,19 @@ SoftwarePanel::SoftwarePanel(QWidget* parent) : ListWidget(parent) {
|
||||
}
|
||||
std::system("pkill -1 -f selfdrive.updated");
|
||||
});
|
||||
connect(uiState(), &UIState::offroadTransition, updateBtn, &QPushButton::setEnabled);
|
||||
|
||||
branchSwitcherBtn = new ButtonControl(tr("Switch Branch"), tr("ENTER"));
|
||||
connect(branchSwitcherBtn, &ButtonControl::clicked, [=]() {
|
||||
QString branch = InputDialog::getText(tr("Enter name of new branch"), this);
|
||||
if (branch.isEmpty()) {
|
||||
params.remove("SwitchToBranch");
|
||||
} else {
|
||||
params.put("SwitchToBranch", branch.toStdString());
|
||||
}
|
||||
std::system("pkill -1 -f selfdrive.updated");
|
||||
});
|
||||
connect(uiState(), &UIState::offroadTransition, branchSwitcherBtn, &QPushButton::setEnabled);
|
||||
|
||||
auto uninstallBtn = new ButtonControl(tr("Uninstall %1").arg(getBrand()), tr("UNINSTALL"));
|
||||
connect(uninstallBtn, &ButtonControl::clicked, [&]() {
|
||||
@@ -263,8 +276,11 @@ SoftwarePanel::SoftwarePanel(QWidget* parent) : ListWidget(parent) {
|
||||
});
|
||||
connect(uiState(), &UIState::offroadTransition, uninstallBtn, &QPushButton::setEnabled);
|
||||
|
||||
QWidget *widgets[] = {versionLbl, lastUpdateLbl, updateBtn, gitBranchLbl, gitCommitLbl, osVersionLbl, uninstallBtn};
|
||||
QWidget *widgets[] = {versionLbl, lastUpdateLbl, updateBtn, branchSwitcherBtn, gitBranchLbl, gitCommitLbl, osVersionLbl, uninstallBtn};
|
||||
for (QWidget* w : widgets) {
|
||||
if (w == branchSwitcherBtn && params.getBool("IsTestedBranch")) {
|
||||
continue;
|
||||
}
|
||||
addItem(w);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ private:
|
||||
LabelControl *versionLbl;
|
||||
LabelControl *lastUpdateLbl;
|
||||
ButtonControl *updateBtn;
|
||||
ButtonControl *branchSwitcherBtn;
|
||||
|
||||
Params params;
|
||||
QFileSystemWatcher *fs_watch;
|
||||
|
||||
@@ -24,9 +24,9 @@ signals:
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override {
|
||||
void mouseReleaseEvent(QMouseEvent *event) override {
|
||||
if (rect().contains(event->pos())) {
|
||||
emit clicked();
|
||||
emit clicked();
|
||||
}
|
||||
}
|
||||
QString lastText_, elidedText_;
|
||||
|
||||
@@ -311,21 +311,29 @@ def fetch_update(wait_helper: WaitTimeHelper) -> bool:
|
||||
|
||||
cur_hash = run(["git", "rev-parse", "HEAD"], OVERLAY_MERGED).rstrip()
|
||||
upstream_hash = run(["git", "rev-parse", "@{u}"], OVERLAY_MERGED).rstrip()
|
||||
new_version: bool = cur_hash != upstream_hash
|
||||
new_version = cur_hash != upstream_hash
|
||||
git_fetch_result = check_git_fetch_result(git_fetch_output)
|
||||
|
||||
new_branch = Params().get("SwitchToBranch", encoding='utf8')
|
||||
if new_branch is not None:
|
||||
new_version = True
|
||||
|
||||
cloudlog.info(f"comparing {cur_hash} to {upstream_hash}")
|
||||
if new_version or git_fetch_result:
|
||||
cloudlog.info("Running update")
|
||||
|
||||
if new_version:
|
||||
cloudlog.info("git reset in progress")
|
||||
r = [
|
||||
run(["git", "reset", "--hard", "@{u}"], OVERLAY_MERGED, low_priority=True),
|
||||
run(["git", "clean", "-xdf"], OVERLAY_MERGED, low_priority=True ),
|
||||
run(["git", "submodule", "init"], OVERLAY_MERGED, low_priority=True),
|
||||
run(["git", "submodule", "update"], OVERLAY_MERGED, low_priority=True),
|
||||
cmds = [
|
||||
["git", "reset", "--hard", "@{u}"],
|
||||
["git", "clean", "-xdf"],
|
||||
["git", "submodule", "init"],
|
||||
["git", "submodule", "update"],
|
||||
]
|
||||
if new_branch is not None:
|
||||
cloudlog.info(f"switching to branch {repr(new_branch)}")
|
||||
cmds.insert(0, ["git", "checkout", "-f", new_branch])
|
||||
r = [run(cmd, OVERLAY_MERGED, low_priority=True) for cmd in cmds]
|
||||
cloudlog.info("git reset success: %s", '\n'.join(r))
|
||||
|
||||
if AGNOS:
|
||||
|
||||
Reference in New Issue
Block a user