From 9f2110f8a187a69e8aacc274e9372ce9b1cd7ce6 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Tue, 27 Aug 2013 22:21:15 +0300 Subject: Git: Extend show output on diff editor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I51d3d0af96b28ec56bedaac163f9ce72158d8dc2 Reviewed-by: André Hartmann Reviewed-by: Tobias Hunger --- src/plugins/git/gitclient.cpp | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/plugins/git/gitclient.cpp') diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index dcd85653d8..ba38cc6e61 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -273,8 +273,10 @@ void GitDiffHandler::slotShowDescriptionReceived(const QString &description) if (m_editor.isNull()) return; DiffEditor::DiffShowEditor *editor = qobject_cast(m_editor); - if (editor) - editor->setDescription(description); + if (editor) { + editor->setDescription(GitPlugin::instance()->gitClient()-> + extendedShowDescription(m_workingDirectory, description)); + } collectFilesList(QStringList() << m_requestedRevisionRange.begin.id @@ -2554,6 +2556,34 @@ void GitClient::continuePreviousGitCommand(const QString &workingDirectory, } } +QString GitClient::extendedShowDescription(const QString &workingDirectory, const QString &text) +{ + if (!text.startsWith(QLatin1String("commit "))) + return text; + QString modText = text; + QString precedes, follows; + int lastHeaderLine = modText.indexOf(QLatin1String("\n\n")) + 1; + const QString commit = modText.mid(7, 8); + synchronousTagsForCommit(workingDirectory, commit, precedes, follows); + if (!precedes.isEmpty()) + modText.insert(lastHeaderLine, QLatin1String("Precedes: ") + precedes + QLatin1Char('\n')); + if (!follows.isEmpty()) + modText.insert(lastHeaderLine, QLatin1String("Follows: ") + follows + QLatin1Char('\n')); + QString moreBranches; + QStringList branches = synchronousBranchesForCommit(workingDirectory, commit); + const int branchCount = branches.count(); + // If there are more than 20 branches, list first 10 followed by a hint + if (branchCount > 20) { + const int leave = 10; + moreBranches = tr(" and %1 more").arg(branchCount - leave); + branches.erase(branches.begin() + leave, branches.end()); + } + modText.insert(lastHeaderLine, QLatin1String("Branches: ") + + branches.join(QLatin1String(", ")) + moreBranches + + QLatin1Char('\n')); + return modText; +} + // Quietly retrieve branch list of remote repository URL // // The branch HEAD is pointing to is always returned first. -- cgit v1.2.1