forked from qt-creator/qt-creator
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:
committed by
Orgad Shaneh
parent
bd63402fb8
commit
3d63136836
@@ -470,6 +470,14 @@ QString BranchModel::sha(const QModelIndex &idx) const
|
|||||||
return node->sha;
|
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
|
bool BranchModel::hasTags() const
|
||||||
{
|
{
|
||||||
return m_rootNode->children.count() > Tags;
|
return m_rootNode->children.count() > Tags;
|
||||||
@@ -590,6 +598,7 @@ QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModel
|
|||||||
QString startSha;
|
QString startSha;
|
||||||
QString output;
|
QString output;
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
|
QDateTime branchDateTime;
|
||||||
|
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << (track ? QLatin1String("--track") : QLatin1String("--no-track"));
|
args << (track ? QLatin1String("--track") : QLatin1String("--no-track"));
|
||||||
@@ -597,8 +606,17 @@ QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModel
|
|||||||
if (!fullTrackedBranch.isEmpty()) {
|
if (!fullTrackedBranch.isEmpty()) {
|
||||||
args << fullTrackedBranch;
|
args << fullTrackedBranch;
|
||||||
startSha = sha(startPoint);
|
startSha = sha(startPoint);
|
||||||
|
branchDateTime = dateTime(startPoint);
|
||||||
} else {
|
} 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)) {
|
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;
|
local = child;
|
||||||
}
|
}
|
||||||
int pos = positionForName(local, leafName);
|
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)
|
if (!added)
|
||||||
beginInsertRows(nodeToIndex(local, 0), pos, pos);
|
beginInsertRows(nodeToIndex(local, 0), pos, pos);
|
||||||
newNode->parent = local;
|
newNode->parent = local;
|
||||||
|
@@ -68,6 +68,7 @@ public:
|
|||||||
QString fullName(const QModelIndex &idx, bool includePrefix = false) const;
|
QString fullName(const QModelIndex &idx, bool includePrefix = false) const;
|
||||||
QStringList localBranchNames() const;
|
QStringList localBranchNames() const;
|
||||||
QString sha(const QModelIndex &idx) const;
|
QString sha(const QModelIndex &idx) const;
|
||||||
|
QDateTime dateTime(const QModelIndex &idx) const;
|
||||||
bool hasTags() const;
|
bool hasTags() const;
|
||||||
bool isLocal(const QModelIndex &idx) const;
|
bool isLocal(const QModelIndex &idx) const;
|
||||||
bool isLeaf(const QModelIndex &idx) const;
|
bool isLeaf(const QModelIndex &idx) const;
|
||||||
|
Reference in New Issue
Block a user