Commit 7c84f786 authored by Evgeniy Ivanov's avatar Evgeniy Ivanov
Browse files

No inline methods now

parent 6ce597f1
......@@ -44,6 +44,57 @@ GitExecutor::~GitExecutor()
{
}
QString GitExecutor::name() const
{
return QLatin1String("Git");
}
//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;
}
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;
......
......@@ -103,56 +103,4 @@ class GitExecutor : public QObject, public KDevelop::IDVCSexecutor
};
//Often used methods should be inline
inline QString GitExecutor::name() const
{
return QLatin1String("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