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 "commandclean.h"
0008 
0009 namespace Git
0010 {
0011 
0012 CommandClean::CommandClean() = default;
0013 
0014 QStringList CommandClean::generateArgs() const
0015 {
0016     QStringList cmd{QStringLiteral("clean")};
0017 
0018     switch (type) {
0019     case AllUntrackedFiles:
0020         cmd << QStringLiteral("-fx");
0021         break;
0022     case NonIgnoredUntrackedFiles:
0023         cmd << QStringLiteral("-f");
0024         break;
0025     case IgnoredFiles:
0026         cmd << QStringLiteral("-fX");
0027         break;
0028     }
0029 
0030     if (mDryRun)
0031         cmd << QStringLiteral("--dry-run");
0032 
0033     if (mRemoveUntrackedDirectories)
0034         cmd << QStringLiteral("-d");
0035 
0036     return cmd;
0037 }
0038 
0039 bool CommandClean::dryRun() const
0040 {
0041     return mDryRun;
0042 }
0043 
0044 void CommandClean::setDryRun(bool newDryRun)
0045 {
0046     mDryRun = newDryRun;
0047 }
0048 
0049 CommandClean::CleanupType CommandClean::getType() const
0050 {
0051     return type;
0052 }
0053 
0054 void CommandClean::setType(CleanupType newType)
0055 {
0056     type = newType;
0057 }
0058 
0059 bool CommandClean::removeUntrackedDirectories() const
0060 {
0061     return mRemoveUntrackedDirectories;
0062 }
0063 
0064 void CommandClean::setRemoveUntrackedDirectories(bool newRemoveUntrackedDirectories)
0065 {
0066     mRemoveUntrackedDirectories = newRemoveUntrackedDirectories;
0067 }
0068 
0069 }