forked from qt-creator/qt-creator
Git: Track external changes to HEAD
Fixes: QTCREATORBUG-21089 Change-Id: Ifcbefd4f57bfdb5c726eced194076503c1dcb497 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
ce43f6fbb4
commit
2a8c48cb15
@@ -30,6 +30,7 @@
|
|||||||
#include <vcsbase/vcsoutputwindow.h>
|
#include <vcsbase/vcsoutputwindow.h>
|
||||||
#include <vcsbase/vcscommand.h>
|
#include <vcsbase/vcscommand.h>
|
||||||
|
|
||||||
|
#include <utils/filesystemwatcher.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
@@ -217,6 +218,7 @@ public:
|
|||||||
QString currentSha;
|
QString currentSha;
|
||||||
QDateTime currentDateTime;
|
QDateTime currentDateTime;
|
||||||
QStringList obsoleteLocalBranches;
|
QStringList obsoleteLocalBranches;
|
||||||
|
Utils::FileSystemWatcher fsWatcher;
|
||||||
bool oldBranchesIncluded = false;
|
bool oldBranchesIncluded = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -233,6 +235,10 @@ BranchModel::BranchModel(GitClient *client, QObject *parent) :
|
|||||||
// Abuse the sha field for ref prefix
|
// Abuse the sha field for ref prefix
|
||||||
d->rootNode->append(new BranchNode(tr("Local Branches"), "refs/heads"));
|
d->rootNode->append(new BranchNode(tr("Local Branches"), "refs/heads"));
|
||||||
d->rootNode->append(new BranchNode(tr("Remote Branches"), "refs/remotes"));
|
d->rootNode->append(new BranchNode(tr("Remote Branches"), "refs/remotes"));
|
||||||
|
connect(&d->fsWatcher, &Utils::FileSystemWatcher::fileChanged, this, [this] {
|
||||||
|
QString errorMessage;
|
||||||
|
refresh(d->workingDirectory, &errorMessage);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
BranchModel::~BranchModel()
|
BranchModel::~BranchModel()
|
||||||
@@ -388,7 +394,13 @@ bool BranchModel::refresh(const QString &workingDirectory, QString *errorMessage
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->workingDirectory = workingDirectory;
|
if (d->workingDirectory != workingDirectory) {
|
||||||
|
d->workingDirectory = workingDirectory;
|
||||||
|
d->fsWatcher.removeFiles(d->fsWatcher.files());
|
||||||
|
const QString gitDir = d->client->findGitDirForRepository(workingDirectory);
|
||||||
|
if (!gitDir.isEmpty())
|
||||||
|
d->fsWatcher.addFile(gitDir + "/HEAD", Utils::FileSystemWatcher::WatchModifiedDate);
|
||||||
|
}
|
||||||
const QStringList lines = output.split('\n');
|
const QStringList lines = output.split('\n');
|
||||||
for (const QString &l : lines)
|
for (const QString &l : lines)
|
||||||
parseOutputLine(l);
|
parseOutputLine(l);
|
||||||
|
Reference in New Issue
Block a user