2022-02-10 12:03:56 +08:00
|
|
|
#include "gitrepository.h"
|
|
|
|
#include "gitmanager.h"
|
|
|
|
|
|
|
|
GitRepository::GitRepository(const QString& folder, GitManager *manager, QObject *parent)
|
|
|
|
: QObject{parent},
|
|
|
|
mFolder(folder),
|
|
|
|
mManager(manager)
|
|
|
|
{
|
|
|
|
Q_ASSERT(manager!=nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString &GitRepository::folder() const
|
|
|
|
{
|
|
|
|
return mFolder;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GitRepository::createRepository()
|
|
|
|
{
|
|
|
|
mManager->createRepository(mFolder);
|
|
|
|
}
|
|
|
|
|
2022-02-14 00:13:00 +08:00
|
|
|
bool GitRepository::hasRepository(QString& currentBranch)
|
2022-02-10 12:03:56 +08:00
|
|
|
{
|
2022-02-14 00:13:00 +08:00
|
|
|
return mManager->hasRepository(mFolder, currentBranch);
|
2022-02-10 12:03:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void GitRepository::add(const QString &path)
|
|
|
|
{
|
|
|
|
mManager->add(mFolder,path);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GitRepository::remove(const QString &path)
|
|
|
|
{
|
|
|
|
mManager->remove(mFolder,path);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GitRepository::rename(const QString &oldName, const QString &newName)
|
|
|
|
{
|
|
|
|
mManager->rename(mFolder, oldName, newName);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GitRepository::restore(const QString &path)
|
|
|
|
{
|
|
|
|
mManager->restore(mFolder, path);
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList GitRepository::listFiles(bool refresh)
|
|
|
|
{
|
|
|
|
if (refresh || mFiles.isEmpty()) {
|
|
|
|
mFiles = mManager->listFiles(mFolder);
|
|
|
|
}
|
|
|
|
return mFiles;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GitRepository::clone(const QString &url)
|
|
|
|
{
|
|
|
|
mManager->clone(mFolder,url);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GitRepository::commit(const QString &message)
|
|
|
|
{
|
|
|
|
mManager->commit(mFolder, message);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GitRepository::revert()
|
|
|
|
{
|
|
|
|
mManager->revert(mFolder);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GitRepository::reset(const QString &commit, GitResetStrategy strategy)
|
|
|
|
{
|
|
|
|
mManager->reset(mFolder,commit,strategy);
|
|
|
|
}
|
|
|
|
|
|
|
|
GitManager *GitRepository::manager() const
|
|
|
|
{
|
|
|
|
return mManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GitRepository::setManager(GitManager *newManager)
|
|
|
|
{
|
|
|
|
Q_ASSERT(newManager!=nullptr);
|
|
|
|
mManager = newManager;
|
|
|
|
}
|
2022-02-14 00:13:00 +08:00
|
|
|
|
|
|
|
void GitRepository::setFolder(const QString &newFolder)
|
|
|
|
{
|
|
|
|
mFolder = newFolder;
|
|
|
|
}
|