2025-01-10 13:48:38 +01:00
|
|
|
#include <QUrl>
|
|
|
|
#include <QtCore/QDir>
|
|
|
|
#include <QDebug>
|
2025-01-10 14:41:04 +01:00
|
|
|
#include <QStandardPaths>
|
2025-01-10 13:48:38 +01:00
|
|
|
|
|
|
|
#include "git.h"
|
|
|
|
#include "libgit.h"
|
|
|
|
|
|
|
|
|
2025-01-10 14:41:04 +01:00
|
|
|
bool Git::clone(QString url, QString destination_dir_path)
|
2025-01-10 13:48:38 +01:00
|
|
|
{
|
2025-01-10 14:41:04 +01:00
|
|
|
qInfo() << "Cloning " << url << " to destination " << destination_dir_path;
|
|
|
|
QDir tmp_dir(QStandardPaths::writableLocation(
|
|
|
|
QStandardPaths::CacheLocation).append("/clone"));
|
|
|
|
tmp_dir.removeRecursively();
|
|
|
|
qDebug() << "Temp dir path is " << tmp_dir.absolutePath();
|
|
|
|
|
|
|
|
qDebug() << "Cloning " << url << " to tmp dir " << tmp_dir.absolutePath();
|
|
|
|
auto ret = LibGit::instance()->clone(url, tmp_dir.absolutePath()); // TODO Better error handling
|
|
|
|
|
2025-01-10 15:28:42 +01:00
|
|
|
if (ret) {
|
2025-01-10 14:41:04 +01:00
|
|
|
qDebug() << "Removing password_store " << destination_dir_path;
|
|
|
|
QDir destination_dir(destination_dir_path);
|
|
|
|
destination_dir.removeRecursively();
|
|
|
|
|
|
|
|
qDebug() << "Moving cloned content to destination dir";
|
|
|
|
QDir dir;
|
|
|
|
qDebug() << tmp_dir.absolutePath() << " to " << destination_dir.absolutePath();
|
|
|
|
ret = dir.rename(tmp_dir.absolutePath(), destination_dir.absolutePath()); // TODO Better error handling
|
|
|
|
}
|
|
|
|
//tmp_dir.removeRecursively();
|
|
|
|
return ret ;
|
2025-01-10 13:48:38 +01:00
|
|
|
}
|