Git: Do not run 'git --version' synchronously at startup

We can easily delay this, and if git acts up for some reason, we don't
have to block startup.

Task-number: QTCREATORBUG-27765
Change-Id: I25aa6f8d04d1fd4b9d87f8ccf7ffd591f7bbe519
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Eike Ziller
2022-06-29 10:21:12 +02:00
parent 70fb66f9ee
commit f4c60fdf58
4 changed files with 62 additions and 48 deletions

View File

@@ -66,6 +66,7 @@
#include <utils/parameteraction.h>
#include <utils/pathchooser.h>
#include <utils/qtcassert.h>
#include <utils/runextensions.h>
#include <utils/stringutils.h>
#include <utils/utilsicons.h>
@@ -1367,20 +1368,22 @@ void GitPluginPrivate::startCommit(CommitType commitType)
void GitPluginPrivate::updateVersionWarning()
{
unsigned version = m_gitClient.gitVersion();
if (!version || version >= minimumRequiredVersion)
return;
IDocument *curDocument = EditorManager::currentDocument();
QPointer<IDocument> curDocument = EditorManager::currentDocument();
if (!curDocument)
return;
InfoBar *infoBar = curDocument->infoBar();
Id gitVersionWarning("GitVersionWarning");
if (!infoBar->canInfoBeAdded(gitVersionWarning))
return;
infoBar->addInfo(InfoBarEntry(gitVersionWarning,
tr("Unsupported version of Git found. Git %1 or later required.")
.arg(versionString(minimumRequiredVersion)),
InfoBarEntry::GlobalSuppression::Enabled));
Utils::onResultReady(m_gitClient.gitVersion(), this, [curDocument](unsigned version) {
if (!curDocument || !version || version >= minimumRequiredVersion)
return;
InfoBar *infoBar = curDocument->infoBar();
Id gitVersionWarning("GitVersionWarning");
if (!infoBar->canInfoBeAdded(gitVersionWarning))
return;
infoBar->addInfo(
InfoBarEntry(gitVersionWarning,
tr("Unsupported version of Git found. Git %1 or later required.")
.arg(versionString(minimumRequiredVersion)),
InfoBarEntry::GlobalSuppression::Enabled));
});
}
IEditor *GitPluginPrivate::openSubmitEditor(const QString &fileName, const CommitData &cd)