Commit 3a5b6825 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Report termination of git pull/push (which was missing feedback).

parent 3d55c45e
......@@ -503,11 +503,13 @@ GitCommand *GitClient::createCommand(const QString &workingDirectory,
void GitClient::executeGit(const QString &workingDirectory,
const QStringList &arguments,
VCSBase::VCSBaseEditor* editor,
bool outputToWindow)
bool outputToWindow,
GitCommand::TerminationReportMode tm)
{
m_plugin->outputWindow()->append(formatCommand(QLatin1String(Constants::GIT_BINARY), arguments));
GitCommand *command = createCommand(workingDirectory, editor, outputToWindow);
command->addJob(arguments, m_settings.timeout);
command->setTerminationReportMode(tm);
command->execute();
}
......@@ -926,12 +928,12 @@ void GitClient::revert(const QStringList &files)
void GitClient::pull(const QString &workingDirectory)
{
executeGit(workingDirectory, QStringList(QLatin1String("pull")), 0, true);
executeGit(workingDirectory, QStringList(QLatin1String("pull")), 0, true, GitCommand::ReportStderr);
}
void GitClient::push(const QString &workingDirectory)
{
executeGit(workingDirectory, QStringList(QLatin1String("push")), 0, true);
executeGit(workingDirectory, QStringList(QLatin1String("push")), 0, true, GitCommand::ReportStderr);
}
QString GitClient::msgNoChangedFiles()
......
......@@ -31,6 +31,7 @@
#define GITCLIENT_H
#include "gitsettings.h"
#include "gitcommand.h"
#include <coreplugin/iversioncontrol.h>
#include <coreplugin/editormanager/ieditor.h>
......@@ -159,7 +160,8 @@ private:
void executeGit(const QString &workingDirectory,
const QStringList &arguments,
VCSBase::VCSBaseEditor* editor = 0,
bool outputToWindow = false);
bool outputToWindow = false,
GitCommand::TerminationReportMode tm = GitCommand::NoReport);
bool synchronousGit(const QString &workingDirectory,
const QStringList &arguments,
......
......@@ -38,6 +38,8 @@
#include <QtCore/QProcess>
#include <QtCore/QFuture>
#include <QtCore/QtConcurrentRun>
#include <QtCore/QFileInfo>
#include <QtCore/QCoreApplication>
namespace Git {
namespace Internal {
......@@ -51,6 +53,18 @@ static inline QStringList environmentToList(const ProjectExplorer::Environment &
return ProjectExplorer::Environment::systemEnvironment().toStringList();
}
static QString msgTermination(int exitCode, const QString &binaryPath, const QStringList &args)
{
QString cmd = QFileInfo(binaryPath).baseName();
if (!args.empty()) {
cmd += QLatin1Char(' ');
cmd += args.front();
}
return exitCode ?
QCoreApplication::translate("GitCommand", "\n'%1' failed (exit code %2).\n").arg(cmd).arg(exitCode) :
QCoreApplication::translate("GitCommand", "\n'%1' completed (exit code %2).\n").arg(cmd).arg(exitCode);
}
GitCommand::Job::Job(const QStringList &a, int t) :
arguments(a),
timeout(t)
......@@ -62,8 +76,19 @@ GitCommand::GitCommand(const QString &binaryPath,
ProjectExplorer::Environment &environment) :
m_binaryPath(binaryPath),
m_workingDirectory(workingDirectory),
m_environment(environmentToList(environment))
m_environment(environmentToList(environment)),
m_reportTerminationMode(NoReport)
{
}
GitCommand::TerminationReportMode GitCommand::reportTerminationMode() const
{
return m_reportTerminationMode;
}
void GitCommand::setTerminationReportMode(TerminationReportMode m)
{
m_reportTerminationMode = m;
}
void GitCommand::addJob(const QStringList &arguments, int timeout)
......@@ -116,6 +141,16 @@ void GitCommand::run()
output += process.readAllStandardOutput();
error += QString::fromLocal8Bit(process.readAllStandardError());
switch (m_reportTerminationMode) {
case NoReport:
break;
case ReportStdout:
output += msgTermination(process.exitCode(), m_binaryPath, m_jobs.at(j).arguments).toUtf8();
break;
case ReportStderr:
error += msgTermination(process.exitCode(), m_binaryPath, m_jobs.at(j).arguments);
break;
}
}
// Special hack: Always produce output for diff
......
......@@ -42,6 +42,11 @@ class GitCommand : public QObject
Q_DISABLE_COPY(GitCommand)
Q_OBJECT
public:
// Where to report command termination with exit code if desired
enum TerminationReportMode { NoReport,
ReportStdout, // This assumes UTF8
ReportStderr };
explicit GitCommand(const QString &binaryPath,
const QString &workingDirectory,
ProjectExplorer::Environment &environment);
......@@ -54,6 +59,10 @@ public:
// Workaround until all relevant commands support "--no-color".
static void removeColorCodes(QByteArray *data);
// Report command termination with exit code
TerminationReportMode reportTerminationMode() const;
void setTerminationReportMode(TerminationReportMode m);
private:
void run();
......@@ -74,6 +83,7 @@ private:
const QStringList m_environment;
QList<Job> m_jobs;
TerminationReportMode m_reportTerminationMode;
};
} // namespace Internal
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment