Newer
Older
GitSettings GitClient::settings() const
{
return m_settings;
}
void GitClient::setSettings(const GitSettings &s)
{
if (s != m_settings) {
m_settings = s;
if (QSettings *s = m_core->settings())
m_settings.toSettings(s);
}
}
// ------------------------ GitCommand
GitCommand::GitCommand()
{
}
GitCommand::~GitCommand()
{
}
void GitCommand::execute(const QStringList &arguments,
const QString &workingDirectory,
const ProjectExplorer::Environment &environment)
{
if (Git::Constants::debug)
qDebug() << "GitCommand::execute" << workingDirectory << arguments;
// For some reason QtConcurrent::run() only works on this
QFuture<void> task = QtConcurrent::run(this, &GitCommand::run
, arguments
, workingDirectory
, environment);
QString taskName = QLatin1String("Git ") + arguments[0];
Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>();
core->progressManager()->addTask(task, taskName
, QLatin1String("Git.action")
, Core::ProgressManagerInterface::CloseOnSuccess);
}
void GitCommand::run(const QStringList &arguments,
const QString &workingDirectory,
const ProjectExplorer::Environment &environment)
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
{
if (Git::Constants::debug)
qDebug() << "GitCommand::run" << workingDirectory << arguments;
QProcess process;
if (!workingDirectory.isEmpty())
process.setWorkingDirectory(workingDirectory);
ProjectExplorer::Environment env = environment;
if (env.toStringList().isEmpty())
env = ProjectExplorer::Environment::systemEnvironment();
process.setEnvironment(env.toStringList());
process.start(QLatin1String(kGitCommand), arguments);
if (!process.waitForFinished()) {
emit errorText(QLatin1String("Error: Git timed out"));
return;
}
const QByteArray output = process.readAllStandardOutput();
if (output.isEmpty()) {
if (arguments.at(0) == QLatin1String("diff"))
emit outputText(tr("The file does not differ from HEAD"));
} else {
emit outputData(output);
}
const QByteArray error = process.readAllStandardError();
if (!error.isEmpty())
emit errorText(QString::fromLocal8Bit(error));
// As it is used asynchronously, we need to delete ourselves
this->deleteLater();
}