Added debug messages.
Fixed gitBlob(): do not check for existing customer repository.
This commit is contained in:
		| @@ -29,22 +29,36 @@ GitClient::GitClient(QString const &customerNrStr, | ||||
|  | ||||
| void GitClient::onIsmasUpdatesAvailable() { | ||||
|     if (QDir(m_customerRepository).exists()) { | ||||
|         qInfo() << "FETCHING OF" << m_repositoryPath | ||||
|                 << "INTO" << m_customerRepository; | ||||
|  | ||||
|  | ||||
|         qInfo() << UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST, | ||||
|                                 QString("FETCHING OF ") + m_repositoryPath + | ||||
|                                 QString(" INTO ") + m_customerRepository); | ||||
|  | ||||
|         std::optional<QString> changes = gitFetch(); | ||||
|  | ||||
|         if (changes) { | ||||
|             std::optional<QStringList> changedFileNames = gitDiff(changes.value()); | ||||
|             if (changedFileNames) { | ||||
|                 for (int i=0;i<changedFileNames.value().size();++i) { | ||||
|                     QString fname = changedFileNames.value().at(i); | ||||
|                     QString lastCommit = gitLastCommit(fname); | ||||
|                     qDebug() << "CCCC" << changedFileNames.value().at(i) << lastCommit; | ||||
|                 } | ||||
|  | ||||
|                 qInfo() << UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_SUCCESS, | ||||
|                                         QString("FETCHED NEW FILES ") + | ||||
|                                         changedFileNames.value().join(",") + | ||||
|                                         QString(" INTO ") + m_customerRepository); | ||||
|                 if (gitPull()) { | ||||
|                     qInfo() << UpdateStatus(UPDATE_STATUS::GIT_PULL_UPDATES_SUCCESS, | ||||
|                                             QString("PULL NEW FILES ") + | ||||
|                                             changedFileNames.value().join(",") + | ||||
|                                             QString(" INTO ") + m_customerRepository); | ||||
|  | ||||
|                     emit m_worker->handleChangedFiles(changedFileNames.value()); | ||||
|  | ||||
|                 } else { | ||||
|                     qCritical() << "PULL FAILED FOR" << m_repositoryPath | ||||
|                                 << "IN " << m_customerRepository; | ||||
|                     qCritical() << UpdateStatus(UPDATE_STATUS::GIT_PULL_UPDATES_FAILURE, | ||||
|                                                 QString("PULLING NEW FILES ") + | ||||
|                                                 changedFileNames.value().join(",") + | ||||
|                                                 QString(" INTO ") + m_customerRepository + " FAILED"); | ||||
|  | ||||
|                     emit m_worker->terminateUpdateProcess(); | ||||
|                 } | ||||
|             } else { | ||||
| @@ -53,8 +67,10 @@ void GitClient::onIsmasUpdatesAvailable() { | ||||
|                 emit m_worker->finishUpdateProcess(false); | ||||
|             } | ||||
|         } else { | ||||
|             qCritical() << "NO CHANGES IN" << m_repositoryPath | ||||
|                         << "(" << m_customerRepository << ")"; | ||||
|             qCritical() << UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE, | ||||
|                                         QString("NO CHANGES IN ") + m_repositoryPath + | ||||
|                                         QString(" (%1)").arg(m_customerRepository)); | ||||
|  | ||||
|             emit m_worker->finishUpdateProcess(false); | ||||
|         } | ||||
|     } else { | ||||
| @@ -78,7 +94,7 @@ bool GitClient::gitCloneCustomerRepository() { | ||||
|             << "CLONE" << m_repositoryPath << "..."; | ||||
|  | ||||
|     if (c.execute(m_workingDirectory)) { // execute the command in wd | ||||
|         QString result = c.getCommandResult(); | ||||
|         QString const result = c.getCommandResult(); | ||||
|         if (!result.isEmpty()) { | ||||
|             // Cloning into 'customer_281'...\n | ||||
|             static QRegularExpression re("(^\\s*Cloning\\s+into\\s+[']\\s*)(.*)(\\s*['].*$)"); | ||||
| @@ -91,8 +107,9 @@ bool GitClient::gitCloneCustomerRepository() { | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             qCritical() << "ERROR CLONE RESULT HAS WRONG FORMAT"; | ||||
|         } | ||||
|         qCritical() << "ERROR CLONE RESULT HAS WRONG FORMAT. CLONE_RESULT=" | ||||
|                     << result; | ||||
|     } | ||||
|     return false; | ||||
| } | ||||
| @@ -126,8 +143,14 @@ bool GitClient::gitCloneAndCheckoutBranch() { | ||||
|     qInfo() << "CLONE" << m_repositoryPath << "AND CHECKOUT" << m_branchName; | ||||
|     if (gitCloneCustomerRepository()) { | ||||
|         //if (copyGitConfigFromMaster()) { | ||||
|             return gitCheckoutBranch(); | ||||
|             if (gitCheckoutBranch()) { | ||||
|                 return true; | ||||
|             } else { | ||||
|                 m_worker->terminateUpdateProcess(); | ||||
|             } | ||||
|         //} | ||||
|     } else { | ||||
|         m_worker->terminateUpdateProcess(); | ||||
|     } | ||||
|     return false; | ||||
| } | ||||
| @@ -181,6 +204,9 @@ std::optional<QString> GitClient::gitFetch() { | ||||
|         Command c("git fetch"); | ||||
|         if (c.execute(m_customerRepository)) { | ||||
|             QString const s = c.getCommandResult().trimmed(); | ||||
|  | ||||
|             qCritical() << "GIT RESULT" << s; | ||||
|  | ||||
|             if (!s.isEmpty()) { | ||||
|                 QStringList lines = Update::split(s, '\n'); | ||||
|                 if (!lines.empty()) { | ||||
| @@ -257,19 +283,17 @@ QString GitClient::gitLastCommit(QString fileName) { | ||||
|     return ""; | ||||
| } | ||||
|  | ||||
| // get the blob of the file(name) passed as $1 | ||||
| // note: this can be used for any file in the filesystem | ||||
| // fileName has to an absolute path | ||||
| QString GitClient::gitBlob(QString fileName) { | ||||
|     if (QDir(m_customerRepository).exists()) { | ||||
|         QString const filePath | ||||
|             = QDir::cleanPath(m_customerRepository + QDir::separator() + fileName); | ||||
|     QFileInfo fi(fileName); | ||||
|     if (fi.exists()) { | ||||
|         QString const gitCommand = QString("git hash-object %1").arg(fileName); | ||||
|         Command c(gitCommand); | ||||
|         if (c.execute(m_customerRepository)) { | ||||
|             return c.getCommandResult(); | ||||
|         if (c.execute(m_workingDirectory)) { | ||||
|             return c.getCommandResult().trimmed(); | ||||
|         } | ||||
|     } | ||||
|     return ""; | ||||
|     return "N/A"; | ||||
| } | ||||
|  | ||||
| QString GitClient::gitCommitForBlob(QString blob) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user