Commit eb0c8bbb authored by Evgeniy Ivanov's avatar Evgeniy Ivanov
Browse files

Some often functions are inline now

parent 98d3fa13
......@@ -22,16 +22,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#include <QFileInfo>
#include <QDir>
#include <QFileInfo>
#include <QString>
#include <QDateTime>
#include <KLocale>
#include <KUrl>
#include <KMessageBox>
#include <kshell.h>
#include <KDebug>
#include <dvcsjob.h>
#include <iplugin.h>
......@@ -47,57 +44,6 @@ GitExecutor::~GitExecutor()
{
}
//TODO: write tests for this method!
//maybe func()const?
bool GitExecutor::isValidDirectory(const KUrl & dirPath)
{
DVCSjob* job = new DVCSjob(vcsplugin);
if (job)
{
job->clear();
*job << "git-rev-parse";
*job << "--is-inside-work-tree";
QString path = dirPath.path();
QFileInfo fsObject(path);
if (fsObject.isFile())
path = fsObject.path();
job->setDirectory(path);
job->exec();
if (job->status() == KDevelop::VcsJob::JobSucceeded)
{
kDebug(9500) << "Dir:" << path << " is is inside work tree of git" ;
return true;
}
}
kDebug(9500) << "Dir:" << dirPath.path() << " is is not inside work tree of git" ;
return false;
}
QString GitExecutor::name() const
{
return QString("Git");
}
bool GitExecutor::prepareJob(DVCSjob* job, const QString& repository, enum RequestedOperation op)
{
// Only do this check if it's a normal operation like diff, log ...
// For other operations like "git clone" isValidDirectory() would fail as the
// directory is not yet under git control
if (op == GitExecutor::NormalOperation &&
!isValidDirectory(repository)) {
kDebug(9500) << repository << " is not a valid git repository";
return false;
}
// clear commands and args from a possible previous run
job->clear();
// setup the working directory for the new job
job->setDirectory(repository);
return true;
}
bool GitExecutor::addFileList(DVCSjob* job, const QString& repository, const KUrl::List& urls)
{
QStringList args;
......
......@@ -25,10 +25,12 @@
#ifndef GIT_EXECUTOR_H
#define GIT_EXECUTOR_H
#include <KDebug>
#include <QFileInfo>
#include <QStringList>
#include <KUrl>
#include <KJob>
#include <QStringList>
#include <idvcsexecutor.h>
#include "vcsrevision.h"
......@@ -101,4 +103,56 @@ class GitExecutor : public QObject, public KDevelop::IDVCSexecutor
};
//Often used methods should be inline
inline QString GitExecutor::name() const
{
return QString("Git");
}
//TODO: write tests for this method!
//maybe func()const?
inline bool GitExecutor::isValidDirectory(const KUrl & dirPath)
{
DVCSjob* job = new DVCSjob(vcsplugin);
if (job)
{
job->clear();
*job << "git-rev-parse";
*job << "--is-inside-work-tree";
QString path = dirPath.path();
QFileInfo fsObject(path);
if (fsObject.isFile())
path = fsObject.path();
job->setDirectory(path);
job->exec();
if (job->status() == KDevelop::VcsJob::JobSucceeded)
{
kDebug(9500) << "Dir:" << path << " is is inside work tree of git" ;
return true;
}
}
kDebug(9500) << "Dir:" << dirPath.path() << " is is not inside work tree of git" ;
return false;
}
inline bool GitExecutor::prepareJob(DVCSjob* job, const QString& repository, enum RequestedOperation op)
{
// Only do this check if it's a normal operation like diff, log ...
// For other operations like "git clone" isValidDirectory() would fail as the
// directory is not yet under git control
if (op == GitExecutor::NormalOperation &&
!isValidDirectory(repository)) {
kDebug(9500) << repository << " is not a valid git repository";
return false;
}
// clear commands and args from a possible previous run
job->clear();
// setup the working directory for the new job
job->setDirectory(repository);
return true;
}
#endif
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