From e788f4f587be91fdd1bcae89078fcea788d6a13d Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Fri, 8 Oct 2021 13:49:09 +0200 Subject: [PATCH] installer: leave some space after strings --- selfdrive/ui/installer/installer.cc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/selfdrive/ui/installer/installer.cc b/selfdrive/ui/installer/installer.cc index 2bade6afe3..25bb5c68b4 100644 --- a/selfdrive/ui/installer/installer.cc +++ b/selfdrive/ui/installer/installer.cc @@ -14,7 +14,16 @@ #include "selfdrive/ui/qt/util.h" #include "selfdrive/ui/qt/qt_window.h" -#define GIT_URL "https://github.com/commaai/openpilot.git" +std::string get_str(std::string const s) { + std::string::size_type pos = s.find('?'); + assert(pos != std::string::npos); + return s.substr(0, pos); +}; + +// Leave some extra space for the fork installer +const std::string GIT_URL = get_str("https://github.com/commaai/openpilot.git" "? "); +const std::string BRANCH_STR = get_str(BRANCH "? "); + #define GIT_SSH_URL "git@github.com:commaai/openpilot.git" #ifdef QCOM @@ -116,7 +125,7 @@ void Installer::doInstall() { void Installer::freshClone() { qDebug() << "Doing fresh clone"; - proc.start("git", {"clone", "--progress", GIT_URL, "-b", BRANCH, + proc.start("git", {"clone", "--progress", GIT_URL.c_str(), "-b", BRANCH_STR.c_str(), "--depth=1", "--recurse-submodules", TMP_INSTALL_PATH}); } @@ -126,12 +135,12 @@ void Installer::cachedFetch(const QString &cache) { run(QString("cp -rp %1 %2").arg(cache, TMP_INSTALL_PATH).toStdString().c_str()); int err = chdir(TMP_INSTALL_PATH); assert(err == 0); - run("git remote set-branches --add origin " BRANCH); + run(("git remote set-branches --add origin " + BRANCH_STR).c_str()); updateProgress(10); proc.setWorkingDirectory(TMP_INSTALL_PATH); - proc.start("git", {"fetch", "--progress", "origin", BRANCH}); + proc.start("git", {"fetch", "--progress", "origin", BRANCH_STR.c_str()}); } void Installer::readProgress() { @@ -165,8 +174,8 @@ void Installer::cloneFinished(int exitCode, QProcess::ExitStatus exitStatus) { // ensure correct branch is checked out int err = chdir(TMP_INSTALL_PATH); assert(err == 0); - run("git checkout " BRANCH); - run("git reset --hard origin/" BRANCH); + run(("git checkout " + BRANCH_STR).c_str()); + run(("git reset --hard origin/" + BRANCH_STR).c_str()); // move into place run("mv " TMP_INSTALL_PATH " " INSTALL_PATH);