Replace regex in gitCloneCustomerRepository() with straight-forward
steing-handling: regex sometimes returned error.
This commit is contained in:
parent
37bd5c90d3
commit
6865056f4b
@ -68,7 +68,11 @@ bool GitClient::gitCloneCustomerRepository() {
|
|||||||
|
|
||||||
Note: git v2.18 does not support treeless clones: --filter=tree:0.
|
Note: git v2.18 does not support treeless clones: --filter=tree:0.
|
||||||
*/
|
*/
|
||||||
QString gitCommand("git clone --filter=blob:none ");
|
|
||||||
|
// Note: for some reason it is necessary to pass "--progress ---v",
|
||||||
|
// otherwise QProcess returns an error of 128 = 0x80 for the command.
|
||||||
|
|
||||||
|
QString gitCommand("git clone --progress -vvv --filter=blob:none ");
|
||||||
gitCommand += m_repositoryPath;
|
gitCommand += m_repositoryPath;
|
||||||
Command c(gitCommand);
|
Command c(gitCommand);
|
||||||
|
|
||||||
@ -79,26 +83,32 @@ bool GitClient::gitCloneCustomerRepository() {
|
|||||||
QString const result = c.getCommandResult();
|
QString const result = c.getCommandResult();
|
||||||
if (!result.isEmpty()) {
|
if (!result.isEmpty()) {
|
||||||
// Cloning into 'customer_281'...\n
|
// Cloning into 'customer_281'...\n
|
||||||
static QRegularExpression re("(^\\s*Cloning\\s+into\\s+[']\\s*)(.*)(\\s*['].*$)");
|
int customer = -1;
|
||||||
QRegularExpressionMatch match = re.match(result);
|
int cloning = result.indexOf("Cloning", 0, Qt::CaseInsensitive);
|
||||||
if (match.hasMatch()) {
|
if (cloning != -1) {
|
||||||
if (re.captureCount() == 3) { // start with full match (0), then the other 3 matches
|
customer = result.indexOf("customer_", cloning, Qt::CaseInsensitive);
|
||||||
QString const &customerNr = match.captured(2).trimmed();
|
if (customer != -1) {
|
||||||
if (customerNr == m_customerNr) {
|
QString customerNr = result.mid(customer);
|
||||||
qInfo() << "CLONING" << m_repositoryPath << "OK";
|
static constexpr char const ch = '\'';
|
||||||
return true;
|
int i = customerNr.indexOf(QChar(ch));
|
||||||
|
if (i != -1) {
|
||||||
|
if ((customerNr = customerNr.mid(0, i)) == m_customerNr) {
|
||||||
|
qInfo() << "CLONING" << m_repositoryPath << "OK";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Utils::printCriticalErrorMsg(
|
||||||
|
QString("ERROR CLONE RESULT HAS WRONG CUSTOMER-NR. (%1 != %2) CLONE_RESULT=%3")
|
||||||
|
.arg(customerNr)
|
||||||
|
.arg(m_customerNr)
|
||||||
|
.arg(result));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
Utils::printCriticalErrorMsg(
|
|
||||||
QString("ERROR CLONE RESULT HAS WRONG CUSTOMER-NR. rcc=%1 customer=%2 CLONE_RESULT=%3")
|
|
||||||
.arg(re.captureCount())
|
|
||||||
.arg(customerNr)
|
|
||||||
.arg(result));
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Utils::printCriticalErrorMsg(
|
Utils::printCriticalErrorMsg(
|
||||||
QString("ERROR CLONE RESULT HAS WRONG FORMAT. rcc=%1 CLONE_RESULT=%2")
|
QString("ERROR CLONE RESULT HAS WRONG FORMAT. CLONING=%1 CUSTOMER=%2 CLONE_RESULT=%3")
|
||||||
.arg(re.captureCount())
|
.arg(cloning)
|
||||||
|
.arg(customer)
|
||||||
.arg(result));
|
.arg(result));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user