RedPanda-CPP/RedPandaIDE/vcs/gitmanager.h

69 lines
2.3 KiB
C
Raw Normal View History

#ifndef GITMANAGER_H
#define GITMANAGER_H
#include <QObject>
#include <QFileInfo>
#include <QSet>
2022-02-09 14:58:39 +08:00
#include "utils.h"
2022-02-15 21:39:17 +08:00
#include "gitutils.h"
2022-02-09 14:58:39 +08:00
class GitError: public BaseError {
public:
explicit GitError(const QString& reason);
};
class GitManager : public QObject
{
Q_OBJECT
public:
2022-02-09 14:58:39 +08:00
explicit GitManager(QObject *parent = nullptr);
2022-02-09 14:58:39 +08:00
void createRepository(const QString& folder);
bool hasRepository(const QString& folder, QString& currentBranch);
2022-02-15 17:22:44 +08:00
QString rootFolder(const QString& folder);
bool isFileInRepository(const QFileInfo& fileInfo);
bool isFileStaged(const QFileInfo& fileInfo);
bool isFileChanged(const QFileInfo& fileInfo);
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);
2022-02-15 21:39:17 +08:00
2022-02-09 14:58:39 +08:00
QStringList listFiles(const QString& folder);
QStringList listStagedFiles(const QString& folder);
QStringList listChangedFiles(const QString& folder);
2022-02-19 20:38:08 +08:00
QStringList listBranches(const QString& folder, int& current);
bool switchToBranch(const QString& folder, const QString& branch, bool create,
2022-02-20 13:26:15 +08:00
bool force, bool merge, bool track, bool noTrack, bool forceCreation,
QString& output);
bool merge(const QString& folder, const QString& commit, bool squash, bool fastForwardOnly,
bool noFastForward, bool noCommit,
QString& output,
const QString& commitMessage=QString()
);
bool continueMerge(const QString& folder);
void abortMerge(const QString& folder);
2022-02-09 14:58:39 +08:00
void clone(const QString& folder, const QString& url);
2022-02-15 21:39:17 +08:00
void commit(const QString& folder, const QString& message, bool autoStage);
2022-02-09 14:58:39 +08:00
void revert(const QString& folder);
void reset(const QString& folder, const QString& commit, GitResetStrategy strategy);
bool isValid();
signals:
2022-02-09 14:58:39 +08:00
void gitCmdRunning(const QString& gitCmd);
void gitCmdFinished(const QString& message);
private:
2022-02-09 14:58:39 +08:00
QString runGit(const QString& workingFolder, const QStringList& args);
QString escapeUTF8String(const QByteArray& rawString);
private:
};
#endif // GITMANAGER_H