summaryrefslogtreecommitdiff
path: root/src/plugins/git/branchmodel.cpp
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2016-03-09 23:21:57 +0200
committerOrgad Shaneh <orgads@gmail.com>2016-03-10 10:24:50 +0000
commit5834769cbf83ef6a43511de59bf26bfb3e3e9380 (patch)
tree958abd326b5ec285e250d555f9a640ee21f24b02 /src/plugins/git/branchmodel.cpp
parentde127b1f5cfa60521f68c318ec98e9e3951db85f (diff)
downloadqt-creator-5834769cbf83ef6a43511de59bf26bfb3e3e9380.tar.gz
Git: Hide obsolete branches by default in branches dialog
Task-number: QTCREATORBUG-15544 Change-Id: I411c7eacd2c154cad08234c0bd22e16dfecb961c Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com> Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Diffstat (limited to 'src/plugins/git/branchmodel.cpp')
-rw-r--r--src/plugins/git/branchmodel.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/plugins/git/branchmodel.cpp b/src/plugins/git/branchmodel.cpp
index d321d57f44..a6aa90fcfc 100644
--- a/src/plugins/git/branchmodel.cpp
+++ b/src/plugins/git/branchmodel.cpp
@@ -25,11 +25,13 @@
#include "branchmodel.h"
#include "gitclient.h"
+#include "gitconstants.h"
#include <utils/qtcassert.h>
#include <vcsbase/vcsoutputwindow.h>
#include <vcsbase/vcscommand.h>
+#include <QDateTime>
#include <QFont>
using namespace VcsBase;
@@ -348,7 +350,8 @@ bool BranchModel::refresh(const QString &workingDirectory, QString *errorMessage
m_currentSha = m_client->synchronousTopRevision(workingDirectory);
QStringList args;
- args << QLatin1String("--format=%(objectname)\t%(refname)\t%(upstream:short)\t%(*objectname)");
+ args << QLatin1String("--format=%(objectname)\t%(refname)\t%(upstream:short)\t"
+ "%(*objectname)\t%(committerdate:raw)\t%(*committerdate:raw)");
QString output;
if (!m_client->synchronousForEachRefCmd(workingDirectory, args, &output, errorMessage))
VcsOutputWindow::appendError(*errorMessage);
@@ -629,18 +632,34 @@ void BranchModel::setRemoteTracking(const QModelIndex &trackingIndex)
emit dataChanged(current, current);
}
+void BranchModel::setOldBranchesIncluded(bool value)
+{
+ m_oldBranchesIncluded = value;
+}
+
void BranchModel::parseOutputLine(const QString &line)
{
if (line.size() < 3)
return;
- // objectname, refname, upstream:short, *objectname
+ // objectname, refname, upstream:short, *objectname, committerdate:raw, *committerdate:raw
QStringList lineParts = line.split(QLatin1Char('\t'));
const QString shaDeref = lineParts.at(3);
const QString sha = shaDeref.isEmpty() ? lineParts.at(0) : shaDeref;
const QString fullName = lineParts.at(1);
const QString upstream = lineParts.at(2);
+ if (!m_oldBranchesIncluded) {
+ QString strDateTime = lineParts.at(5);
+ if (strDateTime.isEmpty())
+ strDateTime = lineParts.at(4);
+ if (!strDateTime.isEmpty()) {
+ const uint timeT = strDateTime.leftRef(strDateTime.indexOf(QLatin1Char(' '))).toUInt();
+ const int age = QDateTime::fromTime_t(timeT).daysTo(QDateTime::currentDateTime());
+ if (age > Constants::OBSOLETE_COMMIT_AGE_IN_DAYS)
+ return;
+ }
+ }
bool current = (sha == m_currentSha);
bool showTags = m_client->settings().boolValue(GitSettings::showTagsKey);