Commit 80f5551b authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Make the clone job more verbose reporting status and progress.

parent 4c1a5e0d
......@@ -21,6 +21,8 @@ add_subdirectory(tests)
add_subdirectory(icons)
set(kdevgit_PART_SRCS
gitclonejob.cpp
gitplugin.cpp
)
......
/***************************************************************************
* Copyright 2010 Aleix Pol Gonzalez <aleixpol@kde.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License or (at your option) version 3 or any later version *
* accepted by the membership of KDE e.V. (or its successor approved *
* by the membership of KDE e.V.), which shall act as a proxy *
* defined in Section 14 of version 3 of the license. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#include "gitclonejob.h"
#include <QDebug>
GitCloneJob::GitCloneJob(KDevelop::IPlugin* parent, OutputJobVerbosity verbosity)
: DVcsJob(parent, verbosity)
, m_steps(0)
{
connect(getChildproc(), SIGNAL(readyReadStandardError()), SLOT(receivedStderr()));
}
void GitCloneJob::receivedStderr()
{
QByteArray out=getChildproc()->readAllStandardError();
if (out.contains('\n')) {
m_steps+=out.count('\n');
emitPercent(m_steps, 6); //I'm counting 6 lines so it's a way to provide some progress, probably not the best
}
int end = qMax(out.lastIndexOf('\n'), out.lastIndexOf('\r'));
int start = qMax(qMax(out.lastIndexOf('\n', end-1), out.lastIndexOf('\r', end-1)), 0);
QByteArray info=out.mid(start, end-start-1);
emit infoMessage(this, info);
}
/***************************************************************************
* Copyright 2010 Aleix Pol Gonzalez <aleixpol@kde.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License or (at your option) version 3 or any later version *
* accepted by the membership of KDE e.V. (or its successor approved *
* by the membership of KDE e.V.), which shall act as a proxy *
* defined in Section 14 of version 3 of the license. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifndef GITCLONEJOB_H
#define GITCLONEJOB_H
#include <vcs/dvcs/dvcsjob.h>
class GitCloneJob : public DVcsJob
{
Q_OBJECT
public:
GitCloneJob(KDevelop::IPlugin* parent, KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose);
public slots:
void receivedStderr();
private:
uint m_steps;
};
#endif // GITCLONEJOB_H
......@@ -28,6 +28,7 @@
#include <KDebug>
#include <QFileInfo>
#include <QDir>
#include <QDateTime>
#include <interfaces/icore.h>
#include <interfaces/iprojectcontroller.h>
......@@ -39,8 +40,8 @@
#include <vcs/dvcs/dvcsjob.h>
#include <vcs/vcsannotation.h>
#include <vcs/widgets/standardvcslocationwidget.h>
#include <QDateTime>
#include <KIO/CopyJob>
#include "gitclonejob.h"
K_PLUGIN_FACTORY(KDevGitFactory, registerPlugin<GitPlugin>(); )
K_EXPORT_PLUGIN(KDevGitFactory(KAboutData("kdevgit","kdevgit",ki18n("Git"),"0.1",ki18n("A plugin to support git version control systems"), KAboutData::License_GPL)))
......@@ -163,9 +164,11 @@ VcsJob* GitPlugin::init(const KUrl &directory)
VcsJob* GitPlugin::createWorkingCopy(const KDevelop::VcsLocation & source, const KUrl& dest, KDevelop::IBasicVersionControl::RecursionMode)
{
DVcsJob* job = new DVcsJob(this);
DVcsJob* job = new GitCloneJob(this);
if (prepareJob(job, dest.toLocalFile(), GitPlugin::Init) ) {
*job << "git" << "clone" << "--" << source.localUrl().prettyUrl() << dest.toLocalFile();
*job << "git" << "clone"
<< "--progress"
<< "--" << source.localUrl().prettyUrl() << dest.toLocalFile();
return job;
}
delete job;
......
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