Git: Show date and time for newly created branches

Task-number: QTCREATORBUG-16484
Change-Id: I18b262d2d03f6a793123cc655f415a1d46d1a4e3
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Orgad Shaneh
2016-06-23 15:46:18 +03:00
committed by Orgad Shaneh
parent bd63402fb8
commit 3d63136836
2 changed files with 22 additions and 2 deletions

View File

@@ -470,6 +470,14 @@ QString BranchModel::sha(const QModelIndex &idx) const
return node->sha;
}
QDateTime BranchModel::dateTime(const QModelIndex &idx) const
{
if (!idx.isValid())
return QDateTime();
BranchNode *node = indexToNode(idx);
return node->dateTime;
}
bool BranchModel::hasTags() const
{
return m_rootNode->children.count() > Tags;
@@ -590,6 +598,7 @@ QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModel
QString startSha;
QString output;
QString errorMessage;
QDateTime branchDateTime;
QStringList args;
args << (track ? QLatin1String("--track") : QLatin1String("--no-track"));
@@ -597,8 +606,17 @@ QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModel
if (!fullTrackedBranch.isEmpty()) {
args << fullTrackedBranch;
startSha = sha(startPoint);
branchDateTime = dateTime(startPoint);
} else {
startSha = m_client->synchronousTopRevision(m_workingDirectory);
QString output;
QString errorMessage;
const QStringList arguments({"-n1", "--format=%H %ct"});
if (m_client->synchronousLog(m_workingDirectory, arguments, &output, &errorMessage,
VcsCommand::SuppressCommandLogging)) {
const QStringList values = output.split(' ');
startSha = values[0];
branchDateTime = QDateTime::fromTime_t(values[1].toInt());
}
}
if (!m_client->synchronousBranchCmd(m_workingDirectory, args, &output, &errorMessage)) {
@@ -624,7 +642,8 @@ QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModel
local = child;
}
int pos = positionForName(local, leafName);
auto newNode = new BranchNode(leafName, startSha, track ? trackedBranch : QString());
auto newNode = new BranchNode(leafName, startSha, track ? trackedBranch : QString(),
branchDateTime);
if (!added)
beginInsertRows(nodeToIndex(local, 0), pos, pos);
newNode->parent = local;

View File

@@ -68,6 +68,7 @@ public:
QString fullName(const QModelIndex &idx, bool includePrefix = false) const;
QStringList localBranchNames() const;
QString sha(const QModelIndex &idx) const;
QDateTime dateTime(const QModelIndex &idx) const;
bool hasTags() const;
bool isLocal(const QModelIndex &idx) const;
bool isLeaf(const QModelIndex &idx) const;