2022-02-08 23:38:29 +08:00
|
|
|
#ifndef GITMANAGER_H
|
|
|
|
#define GITMANAGER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2022-02-14 00:13:00 +08:00
|
|
|
#include <QFileInfo>
|
2022-02-15 00:01:50 +08:00
|
|
|
#include <QSet>
|
2022-02-09 14:58:39 +08:00
|
|
|
#include "utils.h"
|
2022-02-10 12:03:56 +08:00
|
|
|
#include "gitrepository.h"
|
2022-02-09 14:58:39 +08:00
|
|
|
|
|
|
|
class GitError: public BaseError {
|
|
|
|
public:
|
|
|
|
explicit GitError(const QString& reason);
|
|
|
|
};
|
|
|
|
|
2022-02-08 23:38:29 +08:00
|
|
|
class GitManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2022-02-09 14:58:39 +08:00
|
|
|
|
2022-02-08 23:38:29 +08:00
|
|
|
explicit GitManager(QObject *parent = nullptr);
|
|
|
|
|
2022-02-09 14:58:39 +08:00
|
|
|
void createRepository(const QString& folder);
|
2022-02-14 00:13:00 +08:00
|
|
|
bool hasRepository(const QString& folder, QString& currentBranch);
|
|
|
|
|
|
|
|
bool isFileInRepository(const QFileInfo& fileInfo);
|
2022-02-15 00:01:50 +08:00
|
|
|
bool isFileStaged(const QFileInfo& fileInfo);
|
2022-02-14 00:13:00 +08:00
|
|
|
bool isFileChanged(const QFileInfo& fileInfo);
|
2022-02-08 23:38:29 +08:00
|
|
|
|
2022-02-09 14:58:39 +08:00
|
|
|
void add(const QString& folder, const QString& path);
|
|
|
|
void remove(const QString& folder, const QString& path);
|
|
|
|
void rename(const QString& folder, const QString& oldName, const QString& newName);
|
|
|
|
void restore(const QString& folder, const QString& path);
|
|
|
|
QStringList listFiles(const QString& folder);
|
2022-02-15 00:01:50 +08:00
|
|
|
QStringList listStagedFiles(const QString& folder);
|
|
|
|
QStringList listChangedFiles(const QString& folder);
|
2022-02-09 14:58:39 +08:00
|
|
|
|
|
|
|
void clone(const QString& folder, const QString& url);
|
|
|
|
void commit(const QString& folder, const QString& message);
|
|
|
|
void revert(const QString& folder);
|
2022-02-10 12:03:56 +08:00
|
|
|
void reset(const QString& folder, const QString& commit, GitResetStrategy strategy);
|
2022-02-08 23:38:29 +08:00
|
|
|
|
2022-02-15 00:01:50 +08:00
|
|
|
bool isValid();
|
|
|
|
|
2022-02-08 23:38:29 +08:00
|
|
|
signals:
|
2022-02-09 14:58:39 +08:00
|
|
|
void gitCmdRunning(const QString& gitCmd);
|
|
|
|
void gitCmdFinished(const QString& message);
|
2022-02-08 23:38:29 +08:00
|
|
|
private:
|
2022-02-09 14:58:39 +08:00
|
|
|
QString runGit(const QString& workingFolder, const QStringList& args);
|
2022-02-15 00:01:50 +08:00
|
|
|
|
|
|
|
QString escapeUTF8String(const QByteArray& rawString);
|
2022-02-08 23:38:29 +08:00
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GITMANAGER_H
|