| 713 | } |
| 714 | |
| 715 | void GitPlugin::parseGitBlameOutput(DVcsJob *job) |
| 716 | { |
| 717 | QVariantList results; |
| 718 | VcsAnnotationLine* annotation = nullptr; |
| 719 | const auto output = job->output(); |
| 720 | const auto lines = QStringView{output}.split(QLatin1Char('\n')); |
| 721 | |
| 722 | bool skipNext=false; |
| 723 | QHash<QString, VcsAnnotationLine> definedRevisions; |
| 724 | for (const auto line : lines) { |
| 725 | if(skipNext) { |
| 726 | skipNext=false; |
| 727 | results += QVariant::fromValue(*annotation); |
| 728 | |
| 729 | continue; |
| 730 | } |
| 731 | |
| 732 | if (line.isEmpty()) |
| 733 | continue; |
| 734 | |
| 735 | constexpr QLatin1Char space{' '}; |
| 736 | |
| 737 | auto name = line; |
| 738 | QStringView value; |
| 739 | if (const auto spaceIndex = line.indexOf(space); spaceIndex != -1) { |
| 740 | name = line.first(spaceIndex); |
| 741 | value = line.sliced(spaceIndex + 1); |
| 742 | } |
| 743 | |
| 744 | if(name==QLatin1String("author")) |
| 745 | annotation->setAuthor(value.toString()); |
| 746 | else if(name==QLatin1String("author-mail")) {} //TODO: do smth with the e-mail? |
| 747 | else if(name==QLatin1String("author-tz")) {} //TODO: does it really matter? |
| 748 | else if(name==QLatin1String("author-time")) |
| 749 | annotation->setDate(QDateTime::fromSecsSinceEpoch(value.toUInt(), QTimeZone::LocalTime)); |
| 750 | else if(name==QLatin1String("summary")) |
| 751 | annotation->setCommitMessage(value.toString()); |
| 752 | else if(name.startsWith(QLatin1String("committer"))) {} //We will just store the authors |
| 753 | else if(name==QLatin1String("previous")) {} //We don't need that either |
| 754 | else if(name==QLatin1String("filename")) { skipNext=true; } |
| 755 | else if (name == QLatin1String("boundary")) { |
| 756 | // We never limit the annotation with revision range specifiers, so the initial commit |
| 757 | // in the git repository is always denoted as the boundary revision => not interesting. |
| 758 | } else { |
| 759 | constexpr auto revisionValueSize = 8; |
| 760 | if (name.size() < revisionValueSize) { |
| 761 | qCWarning(PLUGIN_GIT) << "first git-blame header line does not start with a long enough SHA-1 hash:" |
| 762 | << line; |
| 763 | continue; |
| 764 | } |
| 765 | |
| 766 | const auto valueSpaceIndex = value.indexOf(space); |
| 767 | if (valueSpaceIndex == -1) { |
| 768 | qCWarning(PLUGIN_GIT) |
| 769 | << "first git-blame header line does not contain two line numbers separated with a space:" << line; |
| 770 | continue; |
| 771 | } |
| 772 | value = value.sliced(valueSpaceIndex + 1); // skip the line number of the line in the original file |
nothing calls this directly
no test coverage detected