From 2189684cad5f5f6df488c831553b650688d9c457 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 21 Feb 2025 12:43:15 +0100 Subject: [PATCH] Minor: use constants in internal:: --- ..._and_fetch_customer_repository_command.cpp | 34 ++++++++++++++----- ...ck_and_fetch_customer_repository_command.h | 1 + 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/UpdatePTUDevCtrl/process/check_and_fetch_customer_repository_command.cpp b/UpdatePTUDevCtrl/process/check_and_fetch_customer_repository_command.cpp index 06e98cc..f2520af 100644 --- a/UpdatePTUDevCtrl/process/check_and_fetch_customer_repository_command.cpp +++ b/UpdatePTUDevCtrl/process/check_and_fetch_customer_repository_command.cpp @@ -13,12 +13,20 @@ void CheckAndFetchCustomerRepositoryCommand::finished(int exitCode, QProcess::Ex Worker *w = worker(); if (w) { switch (exitCode) { - case -2: + case internal::GIT_CHECKOUT_ERROR_CODE: emit w->showCustRepoStatus(internal::GIT_CUSTOMER_REPO_CHECKOUT_ERROR); break; - case -4: + case internal::GIT_PULL_ERROR_CODE: emit w->showCustRepoStatus(internal::GIT_CUSTOMER_REPO_PULL_ERROR); break; + case internal::GIT_NOT_NECESSARY_CODE: + emit w->showCustRepoStatus(internal::GIT_CUSTOMER_REPO_NOT_NECESSARY); + exitCode = 0; + break; + case internal::GIT_UPDATED_CODE: + emit w->showCustRepoStatus(internal::GIT_CUSTOMER_REPO_UPDATED); + exitCode = 0; + break; case 0: emit w->showCustRepoStatus(internal::GIT_CUSTOMER_REPO_UP_TO_DATE); default:; @@ -29,13 +37,21 @@ void CheckAndFetchCustomerRepositoryCommand::finished(int exitCode, QProcess::Ex } void CheckAndFetchCustomerRepositoryCommand::readyReadStandardOutput() { - //QProcess *p = (QProcess *)sender(); - //if (p) { - // Worker *w = worker(); - // if (w) { - // QString s = p->readAllStandardOutput().trimmed(); - // - // qCritical() << __func__ << ":" << __LINE__ << s; + QProcess *p = (QProcess *)sender(); + if (p) { + Worker *w = worker(); + if (w) { + QString s = p->readAllStandardOutput().trimmed(); + m_commandResult += s; + if (m_commandResult.contains(internal::GIT_CUSTOMER_REPO_NO_UPDATE_NECESSARY)) { + //emit w->showCustRepoStatus(internal::GIT_CUSTOMER_REPO_NOT_NECESSARY); + m_commandResult.clear(); + } else + if (m_commandResult.contains(internal::GIT_CUSTOMER_REPO_UPDATED)) { + //emit w->showCustRepoStatus(internal::GIT_CUSTOMER_REPO_UPDATED); + } + } + } // static constexpr const char *GIT_CUSTOMER_REPO_UP_TO_DATE{"up to date"}; // emit w->showCustRepoStatus(UpdateCommand::GIT_CUSTOMER_REPO_UP_TO_DATE); diff --git a/UpdatePTUDevCtrl/process/check_and_fetch_customer_repository_command.h b/UpdatePTUDevCtrl/process/check_and_fetch_customer_repository_command.h index 71054b5..cb25c39 100644 --- a/UpdatePTUDevCtrl/process/check_and_fetch_customer_repository_command.h +++ b/UpdatePTUDevCtrl/process/check_and_fetch_customer_repository_command.h @@ -10,6 +10,7 @@ public: int nextCommandIndex, int start_timeout = 100000, int finish_timeout = 100000); + QString m_commandResult{}; public slots: virtual void readyReadStandardOutput() override; virtual void finished(int exitCode, QProcess::ExitStatus exitStatus) override;