| 838 | } |
| 839 | |
| 840 | void 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 | |
| 887 | VcsJob* GitPlugin::tag(const QUrl& repository, const QString& commitMessage, const VcsRevision& rev, const QString& tagName) |
| 888 | { |
nothing calls this directly
no test coverage detected