gitPull(): don't use regex anumore, but just plain
string-matching/searching. Regex seems to be quite error-prone.
This commit is contained in:
		@@ -303,6 +303,9 @@ std::optional<QString> GitClient::gitPull() {
 | 
				
			|||||||
            if (!s.isEmpty()) {
 | 
					            if (!s.isEmpty()) {
 | 
				
			||||||
                QStringList lines = Update::split(s, '\n');
 | 
					                QStringList lines = Update::split(s, '\n');
 | 
				
			||||||
                if (!lines.empty()) {
 | 
					                if (!lines.empty()) {
 | 
				
			||||||
 | 
					                    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");
 | 
					                        int zoneNr = Utils::read1stLineOfFile("/mnt/system_data/zone_nr");
 | 
				
			||||||
                        m_branchName = (zoneNr != 0) ? QString("zg1/zone%1").arg(zoneNr) : "master";
 | 
					                        m_branchName = (zoneNr != 0) ? QString("zg1/zone%1").arg(zoneNr) : "master";
 | 
				
			||||||
                        // lines can look like this:
 | 
					                        // lines can look like this:
 | 
				
			||||||
@@ -321,7 +324,13 @@ std::optional<QString> GitClient::gitPull() {
 | 
				
			|||||||
                                QRegularExpressionMatch match = re.match(lines.at(i));
 | 
					                                QRegularExpressionMatch match = re.match(lines.at(i));
 | 
				
			||||||
                                if (match.hasMatch()) {
 | 
					                                if (match.hasMatch()) {
 | 
				
			||||||
                                    if (re.captureCount() == 3) { // start with full match (0), then the other 3 matches
 | 
					                                    if (re.captureCount() == 3) { // start with full match (0), then the other 3 matches
 | 
				
			||||||
                                    return match.captured(2);
 | 
					                                        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 {
 | 
					                                } else {
 | 
				
			||||||
                                    emit m_worker->showErrorMessage("git pull",
 | 
					                                    emit m_worker->showErrorMessage("git pull",
 | 
				
			||||||
                                        QString("(wrong cap-count (%1)").arg(re.captureCount()));
 | 
					                                        QString("(wrong cap-count (%1)").arg(re.captureCount()));
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user