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 "commandpush.h" 0008 0009 namespace Git 0010 { 0011 0012 CommandPush::CommandPush() 0013 : AbstractCommand() 0014 { 0015 } 0016 0017 const QString &CommandPush::remote() const 0018 { 0019 return mRemote; 0020 } 0021 0022 void CommandPush::setRemote(const QString &newRemote) 0023 { 0024 mRemote = newRemote; 0025 } 0026 0027 const QString &CommandPush::localBranch() const 0028 { 0029 return mLocalBranch; 0030 } 0031 0032 void CommandPush::setLocalBranch(const QString &newBranch) 0033 { 0034 mLocalBranch = newBranch; 0035 } 0036 0037 const QString &CommandPush::remoteBranch() const 0038 { 0039 return mRemoteBranch; 0040 } 0041 0042 void CommandPush::setRemoteBranch(const QString &newRemoteBranch) 0043 { 0044 mRemoteBranch = newRemoteBranch; 0045 } 0046 0047 bool CommandPush::force() const 0048 { 0049 return mForce; 0050 } 0051 0052 void CommandPush::setForce(bool newForce) 0053 { 0054 mForce = newForce; 0055 } 0056 0057 QStringList CommandPush::generateArgs() const 0058 { 0059 QStringList args{QStringLiteral("push"), mRemote}; 0060 0061 if (mRemoteBranch.isEmpty()) 0062 args.append(mLocalBranch); 0063 else 0064 args.append(mLocalBranch + QLatin1Char(':') + mRemoteBranch); 0065 0066 if (mForce) 0067 args.append(QStringLiteral("--force")); 0068 0069 return args; 0070 } 0071 0072 } // namespace Git