| 140 | } |
| 141 | |
| 142 | KDevelop::VcsEvent BazaarUtils::parseBzrLogPart(const QString& output) |
| 143 | { |
| 144 | const QStringList outputLines = output.split(QLatin1Char('\n')); |
| 145 | KDevelop::VcsEvent commitInfo; |
| 146 | bool atMessage = false; |
| 147 | QString message; |
| 148 | bool afterMessage = false; |
| 149 | QHash<QString, KDevelop::VcsItemEvent::Actions> fileToActionsMapping; |
| 150 | KDevelop::VcsItemEvent::Action currentAction; |
| 151 | for (const QString &line : outputLines) { |
| 152 | if (!atMessage) { |
| 153 | if (line.startsWith(QLatin1String("revno"))) { |
| 154 | QString revno = line.mid(QStringLiteral("revno: ").length()); |
| 155 | revno = revno.left(revno.indexOf(QLatin1Char(' '))); |
| 156 | KDevelop::VcsRevision revision; |
| 157 | revision.setRevisionValue(revno.toLongLong(), KDevelop::VcsRevision::GlobalNumber); |
| 158 | commitInfo.setRevision(revision); |
| 159 | } else if (line.startsWith(QLatin1String("committer: "))) { |
| 160 | QString commiter = line.mid(QStringLiteral("committer: ").length()); |
| 161 | commitInfo.setAuthor(commiter); // Author goes after committer, but only if is different |
| 162 | } else if (line.startsWith(QLatin1String("author"))) { |
| 163 | QString author = line.mid(QStringLiteral("author: ").length()); |
| 164 | commitInfo.setAuthor(author); // It may override committer (In fact committer is not supported by VcsEvent) |
| 165 | } else if (line.startsWith(QLatin1String("timestamp"))) { |
| 166 | const QString formatString = QStringLiteral("yyyy-MM-dd hh:mm:ss"); |
| 167 | QString timestamp = line.mid(QStringLiteral("timestamp: ddd ").length(), formatString.length()); |
| 168 | commitInfo.setDate(QDateTime::fromString(timestamp, formatString)); |
| 169 | } else if (line.startsWith(QLatin1String("message"))) { |
| 170 | atMessage = true; |
| 171 | } |
| 172 | } else if (atMessage && !afterMessage) { |
| 173 | if (!line.isEmpty() && line[0].isSpace()) { |
| 174 | message += line.trimmed() + QLatin1Char('\n'); |
| 175 | } else if (!line.isEmpty()) { |
| 176 | afterMessage = true; |
| 177 | // leave atMessage = true |
| 178 | currentAction = BazaarUtils::parseActionDescription(line); |
| 179 | } // if line is empty - ignore and get next |
| 180 | } else if (afterMessage) { |
| 181 | if (!line.isEmpty() && !line[0].isSpace()) { |
| 182 | currentAction = BazaarUtils::parseActionDescription(line); |
| 183 | } else if (!line.isEmpty()) { |
| 184 | fileToActionsMapping[line.trimmed()] |= currentAction; |
| 185 | } // if line is empty - ignore and get next |
| 186 | } |
| 187 | } |
| 188 | if (atMessage) |
| 189 | commitInfo.setMessage(message.trimmed()); |
| 190 | for (auto i = fileToActionsMapping.begin(); i != fileToActionsMapping.end(); ++i) { |
| 191 | KDevelop::VcsItemEvent itemEvent; |
| 192 | itemEvent.setRepositoryLocation(i.key()); |
| 193 | itemEvent.setActions(i.value()); |
| 194 | commitInfo.addItem(itemEvent); |
| 195 | } |
| 196 | return commitInfo; |
| 197 | } |
| 198 | |
| 199 | KDevelop::VcsItemEvent::Action BazaarUtils::parseActionDescription(const QString& action) |
nothing calls this directly
no test coverage detected