RedPanda-CPP/RedPandaIDE/vcs/gitrepository.h

74 lines
1.9 KiB
C
Raw Normal View History

#ifndef GITREPOSITORY_H
#define GITREPOSITORY_H
#include <QFileInfo>
#include <QObject>
#include <QSet>
#include <memory>
2022-02-15 21:39:17 +08:00
#include "gitutils.h"
class GitManager;
class GitRepository : public QObject
{
Q_OBJECT
public:
explicit GitRepository(const QString& folder, QObject *parent = nullptr);
~GitRepository();
const QString &folder() const;
void createRepository();
bool hasRepository(QString& currentBranch);
bool isFileInRepository(const QFileInfo& fileInfo) {
return isFileInRepository(fileInfo.absoluteFilePath());
}
bool isFileInRepository(const QString& filePath) {
return mFilesInRepositories.contains(filePath);
}
bool isFileStaged(const QFileInfo& fileInfo) {
return isFileStaged(fileInfo.absoluteFilePath());
}
bool isFileStaged(const QString& filePath) {
return mStagedFiles.contains(filePath);
}
bool isFileChanged(const QFileInfo& fileInfo) {
return isFileChanged(fileInfo.absoluteFilePath());
}
bool isFileChanged(const QString& filePath) {
return mChangedFiles.contains(filePath);
}
void add(const QString& path);
void remove(const QString& path);
void rename(const QString& oldName, const QString& newName);
void restore(const QString& path);
QSet<QString> listFiles(bool refresh);
void clone(const QString& url);
2022-02-15 21:39:17 +08:00
void commit(const QString& message, bool autoStage=true);
void revert();
void reset(const QString& commit, GitResetStrategy strategy);
void setFolder(const QString &newFolder);
void update();
2022-02-15 17:22:44 +08:00
const QString &realFolder() const;
signals:
private:
2022-02-15 17:22:44 +08:00
QString mRealFolder;
QString mFolder;
bool mInRepository;
QString mBranch;
GitManager* mManager;
QSet<QString> mFilesInRepositories;
QSet<QString> mChangedFiles;
QSet<QString> mStagedFiles;
private:
void convertFilesListToSet(const QStringList& filesList,QSet<QString>& set);
};
#endif // GITREPOSITORY_H