forked from qt-creator/qt-creator
Git: Some more cleanup
* Remove some more QLatin1String/QStringLiteral * Use algorithms Change-Id: Iaa1042684c58be5ff0a42b9126b63ec681053fdc Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
2c5095c94d
commit
7c910e8b16
@@ -44,6 +44,7 @@
|
|||||||
#include <coreplugin/iversioncontrol.h>
|
#include <coreplugin/iversioncontrol.h>
|
||||||
#include <coreplugin/vcsmanager.h>
|
#include <coreplugin/vcsmanager.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/checkablemessagebox.h>
|
#include <utils/checkablemessagebox.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
@@ -1301,17 +1302,11 @@ bool GitClient::synchronousHeadRefs(const QString &workingDirectory, QStringList
|
|||||||
|
|
||||||
const QString stdOut = resp.stdOut();
|
const QString stdOut = resp.stdOut();
|
||||||
const QString headSha = stdOut.left(10);
|
const QString headSha = stdOut.left(10);
|
||||||
const QChar newLine('\n');
|
QString rest = stdOut.mid(15);
|
||||||
|
|
||||||
int currentIndex = 15;
|
const QStringList headShaLines = Utils::filtered(
|
||||||
|
rest.split('\n'), [&headSha](const QString &s) { return s.startsWith(headSha); });
|
||||||
while (true) {
|
*output = Utils::transform(headShaLines, [](const QString &s) { return s.mid(11); }); // sha + space
|
||||||
currentIndex = stdOut.indexOf(headSha, currentIndex);
|
|
||||||
if (currentIndex < 0)
|
|
||||||
break;
|
|
||||||
currentIndex += 11;
|
|
||||||
output->append(stdOut.mid(currentIndex, stdOut.indexOf(newLine, currentIndex) - currentIndex));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1756,10 +1751,13 @@ bool GitClient::cleanList(const QString &workingDirectory, const QString &module
|
|||||||
// Filter files that git would remove
|
// Filter files that git would remove
|
||||||
const QString relativeBase = modulePath.isEmpty() ? QString() : modulePath + '/';
|
const QString relativeBase = modulePath.isEmpty() ? QString() : modulePath + '/';
|
||||||
const QString prefix = "Would remove ";
|
const QString prefix = "Would remove ";
|
||||||
foreach (const QString &line, resp.stdOut()) {
|
const QStringList removeLines = Utils::filtered(
|
||||||
if (line.startsWith(prefix))
|
splitLines(resp.stdOut()), [&prefix](const QString &s) {
|
||||||
files->push_back(relativeBase + line.mid(prefix.size()));
|
return s.startsWith("Would remove ");
|
||||||
}
|
});
|
||||||
|
*files = Utils::transform(removeLines, [&relativeBase, &prefix](const QString &s) -> QString {
|
||||||
|
return relativeBase + s.mid(prefix.size());
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1941,12 +1939,10 @@ GitClient::StatusResult GitClient::gitStatus(const QString &workingDirectory, St
|
|||||||
return StatusFailed;
|
return StatusFailed;
|
||||||
}
|
}
|
||||||
// Unchanged (output text depending on whether -u was passed)
|
// Unchanged (output text depending on whether -u was passed)
|
||||||
QList<QString> lines = resp.stdOut().split('\n');
|
const bool hasChanges = Utils::contains(stdOut.split('\n'), [](const QString &s) {
|
||||||
foreach (const QString &line, lines) {
|
return !s.isEmpty() && !s.startsWith('#');
|
||||||
if (!line.isEmpty() && !line.startsWith('#'))
|
});
|
||||||
return StatusChanged;
|
return hasChanges ? StatusChanged : StatusUnchanged;
|
||||||
}
|
|
||||||
return StatusUnchanged;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GitClient::commandInProgressDescription(const QString &workingDirectory) const
|
QString GitClient::commandInProgressDescription(const QString &workingDirectory) const
|
||||||
@@ -2248,9 +2244,9 @@ FileName GitClient::vcsBinary() const
|
|||||||
return binary;
|
return binary;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextCodec *GitClient::encoding(const QString &workingDirectory, const QByteArray &configVar) const
|
QTextCodec *GitClient::encoding(const QString &workingDirectory, const QString &configVar) const
|
||||||
{
|
{
|
||||||
QString codecName = readConfigValue(workingDirectory, QLatin1String(configVar)).trimmed();
|
QString codecName = readConfigValue(workingDirectory, configVar).trimmed();
|
||||||
// Set default commit encoding to 'UTF-8', when it's not set,
|
// Set default commit encoding to 'UTF-8', when it's not set,
|
||||||
// to solve displaying error of commit log with non-latin characters.
|
// to solve displaying error of commit log with non-latin characters.
|
||||||
if (codecName.isEmpty())
|
if (codecName.isEmpty())
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ public:
|
|||||||
QString readGitVar(const QString &workingDirectory, const QString &configVar) const;
|
QString readGitVar(const QString &workingDirectory, const QString &configVar) const;
|
||||||
QString readConfigValue(const QString &workingDirectory, const QString &configVar) const;
|
QString readConfigValue(const QString &workingDirectory, const QString &configVar) const;
|
||||||
|
|
||||||
QTextCodec *encoding(const QString &workingDirectory, const QByteArray &configVar) const;
|
QTextCodec *encoding(const QString &workingDirectory, const QString &configVar) const;
|
||||||
bool readDataFromCommit(const QString &repoDirectory, const QString &commit,
|
bool readDataFromCommit(const QString &repoDirectory, const QString &commit,
|
||||||
CommitData &commitData, QString *errorMessage = nullptr,
|
CommitData &commitData, QString *errorMessage = nullptr,
|
||||||
QString *commitTemplate = nullptr);
|
QString *commitTemplate = nullptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user