MCPcopy Create free account
hub / github.com/KDE/kdevelop / parseGitStashList

Method parseGitStashList

plugins/git/gitplugin.cpp:840–885  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

838}
839
840void GitPlugin::parseGitStashList(KDevelop::VcsJob* _job)
841{
842 auto* job = qobject_cast<DVcsJob*>(_job);
843 const QList<QByteArray> output = job->rawOutput().split('\n');
844 QList<StashItem> results;
845
846 for (const QByteArray& line : output) {
847 if (line.isEmpty()) continue;
848
849 const QList<QByteArray> fields = line.split('\x00');
850
851 /* Extract the fields */
852 Q_ASSERT(fields.length() >= 4);
853 const auto message = QString::fromUtf8(fields[2]);
854 const auto parentHash = QString::fromUtf8(fields[1].split(' ')[0]);
855 const auto creationTime = QDateTime::fromSecsSinceEpoch(fields[3].toInt());
856 const auto shortRef = QString::fromUtf8(fields[0]);
857 const auto stackDepth = fields[0].mid(7, fields[0].indexOf('}')-7).toInt();
858
859 QStringView branch;
860 QStringView parentCommitDesc;
861 constexpr QLatin1String wipPrefix("WIP on ", 7);
862 if (message.startsWith(wipPrefix)) {
863 const QStringView messageView = message;
864 const auto colonIndex = message.indexOf(QLatin1Char{':'}, wipPrefix.size());
865 if (colonIndex == -1) {
866 branch = messageView.sliced(wipPrefix.size());
867 qCWarning(PLUGIN_GIT) << "missing ':' in a git stash message:" << message;
868 } else {
869 branch = messageView.sliced(wipPrefix.size(), colonIndex - wipPrefix.size());
870 parentCommitDesc = slicedOrEmptyView(messageView, colonIndex + 2);
871 }
872 }
873
874 results << StashItem {
875 stackDepth,
876 shortRef,
877 parentHash,
878 parentCommitDesc.toString(),
879 branch.toString(),
880 message,
881 creationTime,
882 };
883 }
884 job->setResults(QVariant::fromValue(results));
885}
886
887VcsJob* GitPlugin::tag(const QUrl& repository, const QString& commitMessage, const VcsRevision& rev, const QString& tagName)
888{

Callers

nothing calls this directly

Calls 11

slicedOrEmptyViewFunction · 0.85
rawOutputMethod · 0.80
toIntMethod · 0.80
midMethod · 0.80
setResultsMethod · 0.80
splitMethod · 0.45
isEmptyMethod · 0.45
lengthMethod · 0.45
indexOfMethod · 0.45
sizeMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected