From 72cb738af5d0105856b5fe01f01765eb9a707ce1 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 9 Aug 2023 16:12:56 +0200 Subject: [PATCH] Removed handling of pipe symbol (if available in git output). --- git/git_client.cpp | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/git/git_client.cpp b/git/git_client.cpp index e428056..d28c798 100644 --- a/git/git_client.cpp +++ b/git/git_client.cpp @@ -135,23 +135,41 @@ std::optional GitClient::gitDiff(QString const &commits) { if (c.execute(m_customerRepository)) { // execute command in local customerRepo QString s = c.getCommandResult().trimmed(); QStringList lines = Update::split(s, '\n'); + + qInfo() << QString(80, '*'); + qInfo() << "GIT DIFF RESULT" << lines; + qInfo() << QString(80, '*'); + QStringList fileNames; // each line has the format "etc/psa_config/DC2C_print01.json | 1 + // or the format "etc/psa_config/DC2C_print01.json (new) | 1 + // the filenames are relativ to the repository for (int i = 0; i < lines.size(); ++i) { - // TODO: koennte auch (delete) kommen ? - int newIndex = lines.at(i).indexOf("(new)"); // for new files - // int goneIndex = lines.at(i).indexOf("(gone)"); // for removed files + QString const &line = lines.at(i); + int newIndex = line.indexOf("(new"); // for new files + int goneIndex = line.indexOf("(gone"); // for removed files + int modeIndex = line.indexOf("(mode"); + // int pipeIndex = line.indexOf('|'); if (newIndex != -1) { - QString fileName = lines.at(i).mid(0, newIndex).trimmed(); - fileNames << fileName; - } else { - int pipeIndex = lines.at(i).indexOf('|'); - if (pipeIndex != -1) { - QString fileName = lines.at(i).mid(0, pipeIndex).trimmed(); - fileNames << fileName; - } + QString file = line.left(newIndex).trimmed(); + qInfo() << "FILE (NEW)" << file; + fileNames << file; + } else + if (modeIndex != -1) { + QString const file = line.left(modeIndex).trimmed(); + qInfo() << "FILE (MODE)" << file; + fileNames << file; + } else + //if (pipeIndex != -1) { + // QString const file = line.left(pipeIndex).trimmed(); + // qInfo() << "FILE (PIPE)" << file; + // fileNames << file; + //} else + if (goneIndex != -1) { + QString const file = line.left(goneIndex).trimmed(); + qCritical() << QString(80, '*'); + qCritical() << "FILE (GONE)" << file; + qCritical() << QString(80, '*'); } } if (!fileNames.isEmpty()) {