RedPanda-CPP/RedPandaIDE/vcs/gitrepository.cpp

90 lines
1.7 KiB
C++
Raw Normal View History

#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);
}
bool GitRepository::hasRepository(QString& currentBranch)
{
return mManager->hasRepository(mFolder, currentBranch);
}
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;
}
void GitRepository::setFolder(const QString &newFolder)
{
mFolder = newFolder;
}