2022-02-08 23:38:29 +08:00
|
|
|
#ifndef GITMANAGER_H
|
|
|
|
#define GITMANAGER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
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);
|
|
|
|
|
|
|
|
bool gitPathValid() const;
|
2022-02-09 14:58:39 +08:00
|
|
|
void createRepository(const QString& folder);
|
2022-02-08 23:38:29 +08:00
|
|
|
bool hasRepository(const QString& folder);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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:
|
|
|
|
void validate();
|
2022-02-09 14:58:39 +08:00
|
|
|
QString runGit(const QString& workingFolder, const QStringList& args);
|
2022-02-08 23:38:29 +08:00
|
|
|
private:
|
|
|
|
QString mGitPath;
|
|
|
|
bool mGitPathValid;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GITMANAGER_H
|