forked from qt-creator/qt-creator
Git: Branch View: Add upstream status for untracked branches
Display the local commits (not contained in an upstream branch) in this case. Change-Id: If1b7e4c8c98c9867b1003b6ea0530494a14bc994 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
committed by
André Hartmann
parent
e59e80f74f
commit
960ac1adf4
@@ -312,8 +312,11 @@ QVariant BranchModel::data(const QModelIndex &index, int role) const
|
|||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case ColumnBranch: {
|
case ColumnBranch: {
|
||||||
res = node->name;
|
res = node->name;
|
||||||
if (!node->tracking.isEmpty()) {
|
if (!node->isLocal() || !node->isLeaf())
|
||||||
|
break;
|
||||||
|
|
||||||
res += ' ' + arrowUp + QString::number(node->status.ahead);
|
res += ' ' + arrowUp + QString::number(node->status.ahead);
|
||||||
|
if (!node->tracking.isEmpty()) {
|
||||||
res += ' ' + arrowDown + QString::number(node->status.behind);
|
res += ' ' + arrowDown + QString::number(node->status.behind);
|
||||||
res += " [" + node->tracking + ']';
|
res += " [" + node->tracking + ']';
|
||||||
}
|
}
|
||||||
@@ -908,13 +911,17 @@ void BranchModel::removeNode(const QModelIndex &idx)
|
|||||||
|
|
||||||
void BranchModel::updateUpstreamStatus(BranchNode *node)
|
void BranchModel::updateUpstreamStatus(BranchNode *node)
|
||||||
{
|
{
|
||||||
if (node->tracking.isEmpty())
|
if (!node->isLocal())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Process *process = new Process(node);
|
Process *process = new Process(node);
|
||||||
process->setEnvironment(gitClient().processEnvironment());
|
process->setEnvironment(gitClient().processEnvironment());
|
||||||
process->setCommand({gitClient().vcsBinary(), {"rev-list", "--no-color", "--left-right",
|
QStringList parameters = {"rev-list", "--no-color", "--count"};
|
||||||
"--count", node->fullRef() + "..." + node->tracking}});
|
if (node->tracking.isEmpty())
|
||||||
|
parameters += {"HEAD", "--not", "--remotes"};
|
||||||
|
else
|
||||||
|
parameters += {"--left-right", node->fullRef() + "..." + node->tracking};
|
||||||
|
process->setCommand({gitClient().vcsBinary(), parameters});
|
||||||
process->setWorkingDirectory(d->workingDirectory);
|
process->setWorkingDirectory(d->workingDirectory);
|
||||||
connect(process, &Process::done, this, [this, process, node] {
|
connect(process, &Process::done, this, [this, process, node] {
|
||||||
process->deleteLater();
|
process->deleteLater();
|
||||||
@@ -924,9 +931,13 @@ void BranchModel::updateUpstreamStatus(BranchNode *node)
|
|||||||
if (text.isEmpty())
|
if (text.isEmpty())
|
||||||
return;
|
return;
|
||||||
const QStringList split = text.trimmed().split('\t');
|
const QStringList split = text.trimmed().split('\t');
|
||||||
|
if (node->tracking.isEmpty()) {
|
||||||
|
node->setUpstreamStatus(UpstreamStatus(split.at(0).toInt(), 0));
|
||||||
|
} else {
|
||||||
QTC_ASSERT(split.size() == 2, return);
|
QTC_ASSERT(split.size() == 2, return);
|
||||||
|
|
||||||
node->setUpstreamStatus(UpstreamStatus(split.at(0).toInt(), split.at(1).toInt()));
|
node->setUpstreamStatus(UpstreamStatus(split.at(0).toInt(), split.at(1).toInt()));
|
||||||
|
}
|
||||||
const QModelIndex idx = nodeToIndex(node, ColumnBranch);
|
const QModelIndex idx = nodeToIndex(node, ColumnBranch);
|
||||||
emit dataChanged(idx, idx);
|
emit dataChanged(idx, idx);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user