forked from qt-creator/qt-creator
Move Git-specific logic from DiffEditor to Git
Change-Id: I29466c26a51844bb975ac3ecb68adf708021aa67 Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
committed by
Orgad Shaneh
parent
744285c3fc
commit
a4a146b3cb
@@ -1425,8 +1425,31 @@ void GitClient::branchesForCommit(const QString &revision)
|
||||
VcsCommand *command = vcsExec(
|
||||
workingDirectory, {"branch", noColorOption, "-a", "--contains", revision}, nullptr,
|
||||
false, 0, workingDirectory);
|
||||
connect(command, &VcsCommand::stdOutText, controller,
|
||||
&DiffEditorController::informationForCommitReceived);
|
||||
connect(command, &VcsCommand::stdOutText, controller, [controller](const QString &text) {
|
||||
QString moreBranches;
|
||||
QStringList res;
|
||||
for (const QString &branch : text.split('\n')) {
|
||||
const QString b = branch.mid(2).trimmed();
|
||||
if (!b.isEmpty())
|
||||
res << b;
|
||||
}
|
||||
const int branchCount = res.count();
|
||||
// If there are more than 20 branches, list first 10 followed by a hint
|
||||
if (branchCount > 20) {
|
||||
const int leave = 10;
|
||||
//: Displayed after the untranslated message "Branches: branch1, branch2 'and %n more'"
|
||||
// in git show.
|
||||
moreBranches = ' ' + tr("and %n more", 0, branchCount - leave);
|
||||
res.erase(res.begin() + leave, res.end());
|
||||
}
|
||||
QString branches = "Branches: ";
|
||||
if (res.isEmpty())
|
||||
branches += tr("<None>");
|
||||
else
|
||||
branches += res.join(", ") + moreBranches;
|
||||
|
||||
controller->branchesReceived(branches);
|
||||
});
|
||||
}
|
||||
|
||||
bool GitClient::isRemoteCommit(const QString &workingDirectory, const QString &commit)
|
||||
|
||||
Reference in New Issue
Block a user