diff --git a/git/git_client.cpp b/git/git_client.cpp index 0a31bd8..20b5c32 100644 --- a/git/git_client.cpp +++ b/git/git_client.cpp @@ -303,25 +303,34 @@ std::optional GitClient::gitPull() { if (!s.isEmpty()) { QStringList lines = Update::split(s, '\n'); if (!lines.empty()) { - int zoneNr = Utils::read1stLineOfFile("/mnt/system_data/zone_nr"); - m_branchName = (zoneNr != 0) ? QString("zg1/zone%1").arg(zoneNr) : "master"; - // lines can look like this: - // From https://git.mimbach49.de/GerhardHoffmann/customer_281 - // 41ec581..5d25ac3 master -> origin/master - // ff10f57..43530a1 zg1/zone1 -> origin/zg1/zone1 - // 6ed893f..5d9882c zg1/zone2 -> origin/zg1/zone2 - // 4384d17..77045d8 zg1/zone3 -> origin/zg1/zone3 - // 89d2812..36a0d74 zg1/zone5 -> origin/zg1/zone5 - bool found = false; - for (int i=0; i < lines.size(); ++i) { - if (lines.at(i).contains(m_branchName)) { - found = true; - // 409f198..6c22726 zg1/zone1 -> origin/zg1/zone1 - static QRegularExpression re("(^\\s*)([0-9A-Fa-f]+..[0-9A-Fa-f]+)(.*$)"); - QRegularExpressionMatch match = re.match(lines.at(i)); - if (match.hasMatch()) { - if (re.captureCount() == 3) { // start with full match (0), then the other 3 matches - return match.captured(2); + static const QRegularExpression alreadyUpToDate("^\\s*Already\\s+up\\s+to\\s+date.*$"); + if (std::none_of(lines.cbegin(), lines.cend(), + [](QString const &s) { return s.contains(alreadyUpToDate); })) { + int zoneNr = Utils::read1stLineOfFile("/mnt/system_data/zone_nr"); + m_branchName = (zoneNr != 0) ? QString("zg1/zone%1").arg(zoneNr) : "master"; + // lines can look like this: + // From https://git.mimbach49.de/GerhardHoffmann/customer_281 + // 41ec581..5d25ac3 master -> origin/master + // ff10f57..43530a1 zg1/zone1 -> origin/zg1/zone1 + // 6ed893f..5d9882c zg1/zone2 -> origin/zg1/zone2 + // 4384d17..77045d8 zg1/zone3 -> origin/zg1/zone3 + // 89d2812..36a0d74 zg1/zone5 -> origin/zg1/zone5 + bool found = false; + for (int i=0; i < lines.size(); ++i) { + if (lines.at(i).contains(m_branchName)) { + found = true; + // 409f198..6c22726 zg1/zone1 -> origin/zg1/zone1 + static QRegularExpression re("(^\\s*)([0-9A-Fa-f]+..[0-9A-Fa-f]+)(.*$)"); + QRegularExpressionMatch match = re.match(lines.at(i)); + if (match.hasMatch()) { + if (re.captureCount() == 3) { // start with full match (0), then the other 3 matches + QString const matchCaptured = match.captured(2); + worker()->CONSOLE(QStringList(matchCaptured)) << Worker::UPDATE_STEP::UPDATE_REPOSITORY; + return matchCaptured; + } else { + QStringList lst(QString("(wrong capture count (%1)").arg(re.captureCount())); + worker()->GUI(lst) << (worker()->CONSOLE(lst) << Worker::UPDATE_STEP::UPDATE_REPOSITORY_FAILURE); + } } else { emit m_worker->showErrorMessage("git pull", QString("(wrong cap-count (%1)").arg(re.captureCount()));