File indexing completed on 2025-01-19 04:22:43
0001 /* 0002 SPDX-FileCopyrightText: 2021 Hamed Masafi <hamed.masfi@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #include "commandclone.h" 0008 0009 namespace Git 0010 { 0011 0012 CloneCommand::CloneCommand(QObject *parent) 0013 : AbstractCommand(parent) 0014 { 0015 } 0016 0017 const QString &CloneCommand::repoUrl() const 0018 { 0019 return mRepoUrl; 0020 } 0021 0022 void CloneCommand::setRepoUrl(const QString &newRepoUrl) 0023 { 0024 mRepoUrl = newRepoUrl; 0025 } 0026 0027 const QString &CloneCommand::localPath() const 0028 { 0029 return mLocalPath; 0030 } 0031 0032 void CloneCommand::setLocalPath(const QString &newLocalPath) 0033 { 0034 mLocalPath = newLocalPath; 0035 } 0036 0037 const QString &CloneCommand::branch() const 0038 { 0039 return mBranch; 0040 } 0041 0042 void CloneCommand::setBranch(const QString &newBranch) 0043 { 0044 mBranch = newBranch; 0045 } 0046 0047 int CloneCommand::depth() const 0048 { 0049 return mDepth; 0050 } 0051 0052 void CloneCommand::setDepth(int newDepth) 0053 { 0054 mDepth = newDepth; 0055 } 0056 0057 const QString &CloneCommand::origin() const 0058 { 0059 return mOrigin; 0060 } 0061 0062 void CloneCommand::setOrigin(const QString &newOrigin) 0063 { 0064 mOrigin = newOrigin; 0065 } 0066 0067 bool CloneCommand::recursive() const 0068 { 0069 return mRecursive; 0070 } 0071 0072 void CloneCommand::setRecursive(bool newRecursive) 0073 { 0074 mRecursive = newRecursive; 0075 } 0076 0077 QStringList CloneCommand::generateArgs() const 0078 { 0079 QStringList args{QStringLiteral("clone"), QStringLiteral("--progress"), mRepoUrl, mLocalPath}; 0080 0081 if (!mBranch.isEmpty()) 0082 args << QStringLiteral("--branch=") + mBranch; 0083 0084 if (mDepth != -1) 0085 args << QStringLiteral("--depth") << QString::number(mDepth); 0086 0087 if (!mOrigin.isEmpty()) 0088 args << QStringLiteral("--origin=") << mOrigin; 0089 0090 if (mRecursive) 0091 args << QStringLiteral("--recursive"); 0092 0093 return args; 0094 } 0095 0096 void CloneCommand::parseOutputSection(const QByteArray &output, const QByteArray &errorOutput) 0097 { 0098 Q_UNUSED(output) 0099 auto p = errorOutput.mid(0, errorOutput.lastIndexOf("%")); 0100 p = p.mid(p.lastIndexOf(" ") + 1); 0101 setProgress(p.toDouble()); 0102 } 0103 0104 bool CloneCommand::supportProgress() const 0105 { 0106 return true; 0107 } 0108 0109 } // namespace Git