Use head -n 1 in gitLastCommit().

This commit is contained in:
Gerhard Hoffmann 2023-08-11 11:12:59 +02:00
parent 0e97ce7dc2
commit 769626581f

View File

@ -268,13 +268,15 @@ QString GitClient::gitLastCommit(QString fileName) {
if (QDir(m_customerRepository).exists()) { if (QDir(m_customerRepository).exists()) {
QString const filePath QString const filePath
= QDir::cleanPath(m_customerRepository + QDir::separator() + fileName); = QDir::cleanPath(m_customerRepository + QDir::separator() + fileName);
QString const gitCommand = QString("git log %1 | head -n 1").arg(fileName); if (QFile(filePath).exists()) {
Command c("bash"); QString const gitCommand = QString("git log %1 | head -n 1").arg(fileName);
if (c.execute(m_customerRepository, QStringList() << "-c" << gitCommand)) { Command c("bash");
QString const r = c.getCommandResult(); if (c.execute(m_customerRepository, QStringList() << "-c" << gitCommand)) {
int const idx = r.indexOf("commit "); QString const r = c.getCommandResult();
if (idx != -1) { int const idx = r.indexOf("commit ");
return r.mid(idx + 8).trimmed(); if (idx != -1) {
return r.mid(idx + 8).trimmed();
}
} }
} }
} }