File indexing completed on 2025-03-09 05:11:41
0001 /* 0002 SPDX-FileCopyrightText: 2021 Hamed Masafi <hamed.masfi@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #pragma once 0008 #include "libkommit_export.h" 0009 #include <QList> 0010 #include <QString> 0011 0012 #include <git2/remote.h> 0013 0014 namespace Git 0015 { 0016 0017 class Branch; 0018 class LIBKOMMIT_EXPORT RemoteBranch 0019 { 0020 public: 0021 bool configuredPull{false}; 0022 bool configuredPush{false}; 0023 0024 QString name; 0025 QString remotePushBranch; 0026 QString remotePullBranch; 0027 enum class Status { Unknown, UpToDate, FastForwardable, LocalOutOfDate }; 0028 Status status{Status::Unknown}; 0029 0030 Q_REQUIRED_RESULT QString statusText() const; 0031 }; 0032 0033 class LIBKOMMIT_EXPORT RefSpec 0034 { 0035 public: 0036 enum class Direction { DirectionFetch = 0, DirectionPush = 1 }; 0037 0038 RefSpec(const git_refspec *refspecs); 0039 ~RefSpec(); 0040 0041 Q_REQUIRED_RESULT QString name() const; 0042 Q_REQUIRED_RESULT Direction direction() const; 0043 Q_REQUIRED_RESULT QString destionation() const; 0044 Q_REQUIRED_RESULT QString source() const; 0045 0046 private: 0047 QString mName; 0048 Direction mDirection; 0049 QString mDestionation; 0050 QString mSource; 0051 }; 0052 0053 class LIBKOMMIT_EXPORT Remote 0054 { 0055 public: 0056 Remote(); 0057 Remote(git_remote *remote); 0058 0059 void parse(const QString &output); 0060 // QString headBranch; 0061 // QList<RemoteBranch> branches; 0062 0063 Q_REQUIRED_RESULT QString name() const; 0064 Q_REQUIRED_RESULT QList<RefSpec *> refSpecList() const; 0065 Q_REQUIRED_RESULT QString pushUrl() const; 0066 Q_REQUIRED_RESULT QString fetchUrl() const; 0067 Q_REQUIRED_RESULT QString defaultBranch() const; 0068 0069 Q_REQUIRED_RESULT QList<Branch *> branches() const; 0070 0071 Q_REQUIRED_RESULT bool connected() const; 0072 0073 private: 0074 QList<RefSpec *> mRefSpecList; 0075 bool mConnected{false}; 0076 QString mName; 0077 QString mPushUrl; 0078 QString mFetchUrl; 0079 QString mDefaultBranch; 0080 QList<Branch *> mBranches; 0081 0082 friend class RemotesModel; 0083 }; 0084 0085 } // namespace Git