forked from qt-creator/qt-creator
ShowController: Make showing branches a part of show process
Change-Id: I23d994fd489fc6a6f02419452ad2b07c756a9cd3 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -446,6 +446,7 @@ Tasking::Group ShowController::reloadRecipe()
|
|||||||
|
|
||||||
QString m_header;
|
QString m_header;
|
||||||
QString m_body;
|
QString m_body;
|
||||||
|
QString m_branches;
|
||||||
QString m_precedes;
|
QString m_precedes;
|
||||||
QStringList m_follows;
|
QStringList m_follows;
|
||||||
|
|
||||||
@@ -454,6 +455,8 @@ Tasking::Group ShowController::reloadRecipe()
|
|||||||
|
|
||||||
const auto updateDescription = [this](const ReloadStorage &storage) {
|
const auto updateDescription = [this](const ReloadStorage &storage) {
|
||||||
QString desc = storage.m_header;
|
QString desc = storage.m_header;
|
||||||
|
if (!storage.m_branches.isEmpty())
|
||||||
|
desc.append("Branches: " + storage.m_branches + '\n');
|
||||||
if (!storage.m_precedes.isEmpty())
|
if (!storage.m_precedes.isEmpty())
|
||||||
desc.append("Precedes: " + storage.m_precedes + '\n');
|
desc.append("Precedes: " + storage.m_precedes + '\n');
|
||||||
QStringList follows;
|
QStringList follows;
|
||||||
@@ -486,7 +489,7 @@ Tasking::Group ShowController::reloadRecipe()
|
|||||||
}
|
}
|
||||||
const int lastHeaderLine = output.indexOf("\n\n") + 1;
|
const int lastHeaderLine = output.indexOf("\n\n") + 1;
|
||||||
data->m_commit = output.mid(7, 12);
|
data->m_commit = output.mid(7, 12);
|
||||||
data->m_header = output.left(lastHeaderLine) + Constants::EXPAND_BRANCHES + '\n';
|
data->m_header = output.left(lastHeaderLine);
|
||||||
data->m_body = output.mid(lastHeaderLine + 1);
|
data->m_body = output.mid(lastHeaderLine + 1);
|
||||||
updateDescription(*data);
|
updateDescription(*data);
|
||||||
};
|
};
|
||||||
@@ -497,6 +500,55 @@ Tasking::Group ShowController::reloadRecipe()
|
|||||||
return GroupConfig();
|
return GroupConfig();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const auto setupBranches = [this, storage](QtcProcess &process) {
|
||||||
|
storage->m_branches = busyMessage;
|
||||||
|
setupCommand(process, {"branch", noColorOption, "-a", "--contains", storage->m_commit});
|
||||||
|
VcsOutputWindow::appendCommand(process.workingDirectory(), process.commandLine());
|
||||||
|
};
|
||||||
|
const auto onBranchesDone = [storage, updateDescription](const QtcProcess &process) {
|
||||||
|
ReloadStorage *data = storage.activeStorage();
|
||||||
|
data->m_branches.clear();
|
||||||
|
const QString remotePrefix = "remotes/";
|
||||||
|
const QString localPrefix = "<Local>";
|
||||||
|
const int prefixLength = remotePrefix.length();
|
||||||
|
QStringList branches;
|
||||||
|
QString previousRemote = localPrefix;
|
||||||
|
bool first = true;
|
||||||
|
const QStringList branchList = process.cleanedStdOut().split('\n');
|
||||||
|
for (const QString &branch : branchList) {
|
||||||
|
const QString b = branch.mid(2).trimmed();
|
||||||
|
if (b.isEmpty())
|
||||||
|
continue;
|
||||||
|
if (b.startsWith(remotePrefix)) {
|
||||||
|
const int nextSlash = b.indexOf('/', prefixLength);
|
||||||
|
if (nextSlash < 0)
|
||||||
|
continue;
|
||||||
|
const QString remote = b.mid(prefixLength, nextSlash - prefixLength);
|
||||||
|
if (remote != previousRemote) {
|
||||||
|
data->m_branches += branchesDisplay(previousRemote, &branches, &first) + '\n';
|
||||||
|
branches.clear();
|
||||||
|
previousRemote = remote;
|
||||||
|
}
|
||||||
|
branches << b.mid(nextSlash + 1);
|
||||||
|
} else {
|
||||||
|
branches << b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (branches.isEmpty()) {
|
||||||
|
if (previousRemote == localPrefix)
|
||||||
|
data->m_branches += Tr::tr("<None>");
|
||||||
|
} else {
|
||||||
|
data->m_branches += branchesDisplay(previousRemote, &branches, &first);
|
||||||
|
}
|
||||||
|
data->m_branches = data->m_branches.trimmed();
|
||||||
|
updateDescription(*data);
|
||||||
|
};
|
||||||
|
const auto onBranchesError = [storage, updateDescription](const QtcProcess &) {
|
||||||
|
ReloadStorage *data = storage.activeStorage();
|
||||||
|
data->m_branches.clear();
|
||||||
|
updateDescription(*data);
|
||||||
|
};
|
||||||
|
|
||||||
const auto setupPrecedes = [this, storage](QtcProcess &process) {
|
const auto setupPrecedes = [this, storage](QtcProcess &process) {
|
||||||
storage->m_precedes = busyMessage;
|
storage->m_precedes = busyMessage;
|
||||||
setupCommand(process, {"describe", "--contains", storage->m_commit});
|
setupCommand(process, {"describe", "--contains", storage->m_commit});
|
||||||
@@ -578,6 +630,7 @@ Tasking::Group ShowController::reloadRecipe()
|
|||||||
parallel,
|
parallel,
|
||||||
optional,
|
optional,
|
||||||
DynamicSetup(desciptionDetailsSetup),
|
DynamicSetup(desciptionDetailsSetup),
|
||||||
|
Process(setupBranches, onBranchesDone, onBranchesError),
|
||||||
Process(setupPrecedes, onPrecedesDone, onPrecedesError),
|
Process(setupPrecedes, onPrecedesDone, onPrecedesError),
|
||||||
Tree(setupFollows)
|
Tree(setupFollows)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user