ATBUpdateTool/UpdatePTUDevCtrl/process/check_and_fetch_customer_repository_command.cpp

61 lines
2.3 KiB
C++
Raw Normal View History

2025-02-05 16:25:01 +01:00
#include "process/check_and_fetch_customer_repository_command.h"
#include "worker.h"
2025-02-14 13:20:42 +01:00
#include "utils_internal.h"
2025-02-05 16:25:01 +01:00
CheckAndFetchCustomerRepositoryCommand::CheckAndFetchCustomerRepositoryCommand(
2025-02-14 13:20:42 +01:00
QString const &command, Worker *worker, int nextCommandIndex,
int start_timeout, int finish_timeout)
: UpdateCommand(command, worker, nextCommandIndex, start_timeout, finish_timeout) {
}
void CheckAndFetchCustomerRepositoryCommand::finished(int exitCode, QProcess::ExitStatus exitStatus) {
qCritical() << __func__ << ":" << __LINE__ << command() << exitCode << exitStatus;
Worker *w = worker();
if (w) {
switch (exitCode) {
2025-02-21 12:43:15 +01:00
case internal::GIT_CHECKOUT_ERROR_CODE:
2025-02-14 13:20:42 +01:00
emit w->showCustRepoStatus(internal::GIT_CUSTOMER_REPO_CHECKOUT_ERROR);
break;
2025-02-21 12:43:15 +01:00
case internal::GIT_PULL_ERROR_CODE:
2025-02-14 13:20:42 +01:00
emit w->showCustRepoStatus(internal::GIT_CUSTOMER_REPO_PULL_ERROR);
break;
2025-02-21 12:43:15 +01:00
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;
2025-02-14 13:20:42 +01:00
case 0:
emit w->showCustRepoStatus(internal::GIT_CUSTOMER_REPO_UP_TO_DATE);
default:;
}
}
return UpdateCommand::finished(exitCode, exitStatus);
2025-02-05 16:25:01 +01:00
}
void CheckAndFetchCustomerRepositoryCommand::readyReadStandardOutput() {
2025-02-21 12:43:15 +01:00
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"};
2025-02-14 13:20:42 +01:00
// emit w->showCustRepoStatus(UpdateCommand::GIT_CUSTOMER_REPO_UP_TO_DATE);
// }
//}
}