1 /*
2     SPDX-FileCopyrightText: 2010 Aleix Pol Gonzalez <aleixpol@kde.org>
3 
4     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
5 */
6 
7 #include "gitclonejob.h"
8 
GitCloneJob(const QDir & d,KDevelop::IPlugin * parent,OutputJobVerbosity verbosity)9 GitCloneJob::GitCloneJob(const QDir& d, KDevelop::IPlugin* parent, OutputJobVerbosity verbosity)
10     : GitJob(d, parent, verbosity)
11     , m_steps(0)
12 {
13     connect(this, &GitCloneJob::resultsReady, this, &GitCloneJob::processResult);
14 }
processResult()15 void GitCloneJob::processResult()
16 {
17     if (error()) {
18         QByteArray out = errorOutput();
19         if (out.contains('\n')) {
20             m_steps+=out.count('\n');
21             emitPercent(m_steps, 6); //I'm counting 6 lines so it's a way to provide some progress, probably not the best
22         }
23 
24         int end = qMax(out.lastIndexOf('\n'), out.lastIndexOf('\r'));
25         int start = qMax(qMax(out.lastIndexOf('\n', end-1), out.lastIndexOf('\r', end-1)), 0);
26 
27         const QString info = QString::fromUtf8(out.mid(start+1, end-start-1));
28         emit infoMessage(this, info);
29     }
30 }
31