1 | #include "GitCloneProcess.h" |
2 | |
3 | GitCloneProcess::GitCloneProcess(const QString &workingDir) |
4 | : AGitProcess(workingDir) |
5 | { |
6 | connect(this, &AGitProcess::readyReadStandardError, this, &GitCloneProcess::onReadyStandardError, |
7 | Qt::DirectConnection); |
8 | } |
9 | |
10 | GitExecResult GitCloneProcess::run(const QString &command) |
11 | { |
12 | return { execute(command), "" }; |
13 | } |
14 | |
15 | void GitCloneProcess::onReadyStandardError() |
16 | { |
17 | if (!mCanceling) |
18 | { |
19 | const auto err = readAllStandardError(); |
20 | const auto errStr = QString::fromUtf8(err); |
21 | mErrorOutput += errStr; |
22 | |
23 | if (errStr.contains("fatal:" )) |
24 | { |
25 | mCanceling = true; |
26 | emit signalCloningFailure(-1, errStr); |
27 | } |
28 | else if (!errStr.startsWith("remote: " )) |
29 | { |
30 | #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) |
31 | auto infoList = errStr.split("," , Qt::SkipEmptyParts).first().split(":" ); |
32 | #else |
33 | auto infoList = errStr.split("," , QString::SkipEmptyParts).first().split(":" ); |
34 | #endif |
35 | const auto stepDesc = infoList.takeFirst(); |
36 | auto value = -1; |
37 | |
38 | if (!infoList.isEmpty()) |
39 | value = infoList.takeFirst().split("% " ).first().trimmed().toInt(); |
40 | |
41 | emit signalProgress(stepDesc, value); |
42 | } |
43 | } |
44 | } |
45 | |
46 | void GitCloneProcess::onFinished(int code, QProcess::ExitStatus exitStatus) |
47 | { |
48 | AGitProcess::onFinished(code, exitStatus); |
49 | |
50 | if (!mCanceling) |
51 | emit signalProgress("Done!" , 100); |
52 | |
53 | deleteLater(); |
54 | } |
55 | |