forked from qt-creator/qt-creator
Git: Require 1.7.2
Remove legacy code Change-Id: I0ce03f7a34c92b48ceb705a0feec43e0ba89ef5c Reviewed-by: Tobias Hunger <tobias.hunger@digia.com> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
0b7f80de21
commit
cdcc8256a0
@@ -365,31 +365,25 @@ const char *GitClient::decorateOption = "--decorate";
|
||||
|
||||
QString GitClient::findRepositoryForDirectory(const QString &dir)
|
||||
{
|
||||
if (gitVersion() >= 0x010700) {
|
||||
// Find a directory to run git in:
|
||||
const QString root = QDir::rootPath();
|
||||
const QString home = QDir::homePath();
|
||||
// Find a directory to run git in:
|
||||
const QString root = QDir::rootPath();
|
||||
const QString home = QDir::homePath();
|
||||
|
||||
QDir directory(dir);
|
||||
do {
|
||||
const QString absDirPath = directory.absolutePath();
|
||||
if (absDirPath == root || absDirPath == home)
|
||||
break;
|
||||
QDir directory(dir);
|
||||
do {
|
||||
const QString absDirPath = directory.absolutePath();
|
||||
if (absDirPath == root || absDirPath == home)
|
||||
break;
|
||||
|
||||
if (directory.exists())
|
||||
break;
|
||||
} while (directory.cdUp());
|
||||
if (directory.exists())
|
||||
break;
|
||||
} while (directory.cdUp());
|
||||
|
||||
QByteArray outputText;
|
||||
QStringList arguments;
|
||||
arguments << QLatin1String("rev-parse") << QLatin1String("--show-toplevel");
|
||||
fullySynchronousGit(directory.absolutePath(), arguments, &outputText, 0, false);
|
||||
return QString::fromLocal8Bit(outputText.trimmed());
|
||||
} else {
|
||||
// Check for ".git/config"
|
||||
const QString checkFile = QLatin1String(GIT_DIRECTORY) + QLatin1String("/config");
|
||||
return VcsBase::VcsBasePlugin::findRepositoryForDirectory(dir, checkFile);
|
||||
}
|
||||
QByteArray outputText;
|
||||
QStringList arguments;
|
||||
arguments << QLatin1String("rev-parse") << QLatin1String("--show-toplevel");
|
||||
fullySynchronousGit(directory.absolutePath(), arguments, &outputText, 0, false);
|
||||
return QString::fromLocal8Bit(outputText.trimmed());
|
||||
}
|
||||
|
||||
QString GitClient::findGitDirForRepository(const QString &repositoryDir)
|
||||
@@ -1841,9 +1835,7 @@ bool GitClient::getCommitData(const QString &workingDirectory,
|
||||
if (amend) {
|
||||
// Amend: get last commit data as "SHA1<tab>author<tab>email<tab>message".
|
||||
QStringList args(QLatin1String("log"));
|
||||
const QString msgFormat = QLatin1String((gitVersion() > 0x010701) ? "%B" : "%s%n%n%b");
|
||||
const QString format = QLatin1String("%h\t%an\t%ae\t") + msgFormat;
|
||||
args << QLatin1String("--max-count=1") << QLatin1String("--pretty=format:") + format;
|
||||
args << QLatin1String("--max-count=1") << QLatin1String("--pretty=format:%h\t%an\t%ae\t%B");
|
||||
QTextCodec *codec = QTextCodec::codecForName(commitData->commitEncoding.toLocal8Bit());
|
||||
const Utils::SynchronousProcessResponse sp = synchronousGit(repoDirectory, args, 0, codec);
|
||||
if (sp.result != Utils::SynchronousProcessResponse::Finished) {
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "settingspage.h"
|
||||
#include "resetdialog.h"
|
||||
#include "mergetool.h"
|
||||
#include "gitutils.h"
|
||||
|
||||
#include "gerrit/gerritplugin.h"
|
||||
|
||||
@@ -55,6 +56,7 @@
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/id.h>
|
||||
#include <coreplugin/infobar.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
@@ -81,6 +83,8 @@
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
|
||||
static const unsigned minimumRequiredVersion = 0x010702;
|
||||
|
||||
static const VcsBase::VcsBaseEditorParameters editorParameters[] = {
|
||||
{
|
||||
VcsBase::RegularCommandOutput,
|
||||
@@ -848,6 +852,26 @@ void GitPlugin::startCommit(bool amend)
|
||||
openSubmitEditor(m_commitMessageFileName, data, amend);
|
||||
}
|
||||
|
||||
void GitPlugin::updateVersionWarning()
|
||||
{
|
||||
if (m_gitClient->gitVersion() >= minimumRequiredVersion)
|
||||
return;
|
||||
Core::IEditor *curEditor = Core::EditorManager::currentEditor();
|
||||
if (!curEditor)
|
||||
return;
|
||||
Core::IDocument *curDocument = curEditor->document();
|
||||
if (!curDocument)
|
||||
return;
|
||||
Core::InfoBar *infoBar = curDocument->infoBar();
|
||||
Core::Id gitVersionWarning("GitVersionWarning");
|
||||
if (!infoBar->canInfoBeAdded(gitVersionWarning))
|
||||
return;
|
||||
infoBar->addInfo(Core::InfoBarEntry(gitVersionWarning,
|
||||
tr("Unsupported version of Git found. Git %1 or later required.")
|
||||
.arg(versionString(minimumRequiredVersion)),
|
||||
Core::InfoBarEntry::GlobalSuppressionEnabled));
|
||||
}
|
||||
|
||||
Core::IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const CommitData &cd, bool amend)
|
||||
{
|
||||
Core::IEditor *editor = Core::EditorManager::openEditor(fileName, Constants::GITSUBMITEDITOR_ID,
|
||||
@@ -1157,6 +1181,8 @@ void GitPlugin::updateActions(VcsBase::VcsBasePlugin::ActionState as)
|
||||
m_commandLocator->setEnabled(repositoryEnabled);
|
||||
if (!enableMenuAction(as, m_menuAction))
|
||||
return;
|
||||
if (repositoryEnabled)
|
||||
updateVersionWarning();
|
||||
// Note: This menu is visible if there is no repository. Only
|
||||
// 'Create Repository'/'Show' actions should be available.
|
||||
const QString fileName = currentState().currentFileName();
|
||||
|
||||
@@ -194,6 +194,7 @@ private:
|
||||
void cleanRepository(const QString &directory);
|
||||
void applyPatch(const QString &workingDirectory, QString file = QString());
|
||||
void startCommit(bool amend);
|
||||
void updateVersionWarning();
|
||||
|
||||
static GitPlugin *m_instance;
|
||||
Locator::CommandLocator *m_commandLocator;
|
||||
|
||||
@@ -94,5 +94,19 @@ bool inputText(QWidget *parent, const QString &title, const QString &prompt, QSt
|
||||
*s = dialog.textValue();
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline QString versionPart(unsigned part)
|
||||
{
|
||||
return QString::number(part & 0xff, 16);
|
||||
}
|
||||
|
||||
QString versionString(unsigned ver)
|
||||
{
|
||||
return QString::fromLatin1("%1.%2.%3")
|
||||
.arg(versionPart(ver >> 16))
|
||||
.arg(versionPart(ver >> 8))
|
||||
.arg(versionPart(ver));
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Git
|
||||
|
||||
@@ -61,6 +61,8 @@ inline unsigned version(unsigned major, unsigned minor, unsigned patch)
|
||||
return (major << 16) + (minor << 8) + patch;
|
||||
}
|
||||
|
||||
QString versionString(unsigned ver);
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Git
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <utils/qtcassert.h>
|
||||
#include <vcsbase/vcsbaseconstants.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
|
||||
static const char stashMessageKeywordC[] = "IVersionControl@";
|
||||
@@ -71,32 +70,20 @@ bool GitVersionControl::supportsOperation(Operation operation) const
|
||||
if (!isConfigured())
|
||||
return false;
|
||||
|
||||
bool rc = false;
|
||||
switch (operation) {
|
||||
case AddOperation:
|
||||
rc = m_client->gitVersion() >= version(1, 6, 1);;
|
||||
break;
|
||||
case DeleteOperation:
|
||||
rc = true;
|
||||
break;
|
||||
case MoveOperation:
|
||||
rc = true;
|
||||
break;
|
||||
case OpenOperation:
|
||||
break;
|
||||
case CreateRepositoryOperation:
|
||||
case SnapshotOperations:
|
||||
rc = true;
|
||||
break;
|
||||
case AnnotateOperation:
|
||||
rc = true;
|
||||
break;
|
||||
case CheckoutOperation:
|
||||
case GetRepositoryRootOperation:
|
||||
rc = true;
|
||||
return true;
|
||||
case OpenOperation:
|
||||
break;
|
||||
}
|
||||
return rc;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GitVersionControl::vcsOpen(const QString & /*fileName*/)
|
||||
@@ -107,7 +94,6 @@ bool GitVersionControl::vcsOpen(const QString & /*fileName*/)
|
||||
bool GitVersionControl::vcsAdd(const QString & fileName)
|
||||
{
|
||||
// Implement in terms of using "--intent-to-add"
|
||||
QTC_ASSERT(m_client->gitVersion() >= version(1, 6, 1), return false);
|
||||
const QFileInfo fi(fileName);
|
||||
return m_client->synchronousAdd(fi.absolutePath(), true, QStringList(fi.fileName()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user