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

Method allCommits

plugins/git/gitplugin.cpp:1037–1204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1035*/
1036
1037QVector<DVcsEvent> GitPlugin::allCommits(const QString& repo)
1038{
1039 initBranchHash(repo);
1040
1041 const QStringList args{
1042 QStringLiteral("--all"),
1043 QStringLiteral("--pretty"),
1044 QStringLiteral("--parents"),
1045 };
1046 QScopedPointer<DVcsJob> job(gitRevList(repo, args));
1047 bool ret = job->exec();
1048 Q_ASSERT(ret && job->status()==VcsJob::JobSucceeded && "TODO: provide a fall back in case of failing");
1049 Q_UNUSED(ret);
1050 const QStringList commits = job->output().split(QLatin1Char('\n'), Qt::SkipEmptyParts);
1051
1052 static const QRegularExpression rx_com(QStringLiteral("commit [[:alnum:]]{40}"));
1053
1054 QVector<DVcsEvent> commitList;
1055 DVcsEvent item;
1056
1057 //used to keep where we have empty/cross/branch entry
1058 //true if it's an active branch (then cross or branch) and false if not
1059 QVector<bool> additionalFlags(branchesShas.count());
1060 additionalFlags.fill(false);
1061
1062 //parse output
1063 for(int i = 0; i < commits.count(); ++i)
1064 {
1065 if (commits[i].contains(rx_com))
1066 {
1067 qCDebug(PLUGIN_GIT) << "commit found in " << commits[i];
1068 item.setCommit(commits[i].section(QLatin1Char(' '), 1, 1).trimmed());
1069// qCDebug(PLUGIN_GIT) << "commit is: " << commits[i].section(' ', 1);
1070
1071 QStringList parents;
1072 QString parent = commits[i].section(QLatin1Char(' '), 2);
1073 int section = 2;
1074 while (!parent.isEmpty())
1075 {
1076 /* qCDebug(PLUGIN_GIT) << "Parent is: " << parent;*/
1077 parents.append(parent.trimmed());
1078 section++;
1079 parent = commits[i].section(QLatin1Char(' '), section);
1080 }
1081 item.setParents(parents);
1082 ++i;
1083
1084 //Avoid Merge string
1085 while (!commits[i].startsWith(QLatin1String("Author: ")))
1086 ++i;
1087
1088 item.setAuthor(commits[i].section(QStringLiteral("Author: "), 1).trimmed());
1089// qCDebug(PLUGIN_GIT) << "author is: " << commits[i].section("Author: ", 1);
1090
1091 item.setDate(commits[++i].section(QStringLiteral("Date: "), 1).trimmed());
1092// qCDebug(PLUGIN_GIT) << "date is: " << commits[i].section("Date: ", 1);
1093
1094 QString log;

Callers 2

revHistoryMethod · 0.80
testStashMethod · 0.80

Calls 15

execMethod · 0.80
outputMethod · 0.80
setCommitMethod · 0.80
sectionMethod · 0.80
setParentsMethod · 0.80
setLogMethod · 0.80
parentsMethod · 0.80
setPropertyMethod · 0.80
emptyMethod · 0.80
statusMethod · 0.45
splitMethod · 0.45
countMethod · 0.45

Tested by 2

revHistoryMethod · 0.64
testStashMethod · 0.64