1
0
mirror of https://github.com/QRouland/UTPass.git synced 2025-07-04 03:02:28 +00:00

Initial git clone feature

This commit is contained in:
2025-01-10 13:48:38 +01:00
parent d33932be6d
commit 5e5a092da1
22 changed files with 334 additions and 91 deletions

View File

@ -4,7 +4,6 @@ set(PLUGIN "Pass")
set(
SRC
plugin.cpp
git.cpp
pass.cpp
gpg.cpp
passkeymodel.h
@ -43,10 +42,8 @@ set_property(TARGET libgpgmepp PROPERTY IMPORTED_LOCATION "/usr/lib/${ARCH_TRIPL
add_library(libqgpgme SHARED IMPORTED)
set_property(TARGET libqgpgme PROPERTY IMPORTED_LOCATION "/usr/lib/${ARCH_TRIPLET}/libqgpgme.so")
add_library(libgit2 SHARED IMPORTED)
set_property(TARGET libgit2 PROPERTY IMPORTED_LOCATION "/usr/lib/${ARCH_TRIPLET}/libgit2.so")
target_link_libraries(${PLUGIN} gpgerror libassuan libgpgme libgpgmepp libqgpgme libgit2)
target_link_libraries(${PLUGIN} gpgerror libassuan libgpgme libgpgmepp libqgpgme)
set(QT_IMPORTS_DIR "/lib/${ARCH_TRIPLET}")

View File

@ -1,32 +0,0 @@
#include <QDebug>
#include <QUrl>
extern "C" {
#include <git2.h>
}
#include "git.h"
Git::Git()
{
git_libgit2_init();
}
Git::~Git() {
git_libgit2_shutdown();
}
bool Git::clone(QString url, QString path) {
git_repository *repo = NULL;
git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
int ret = git_clone(&repo, url.toLocal8Bit().data(), path.toLocal8Bit().data(), &opts);
if (repo) {
git_repository_free(repo);
}
return ret == 0; // TODO better error handling to return specifics errors for the ui
}

View File

@ -1,27 +0,0 @@
#ifndef GIT_H
#define GIT_H
#include <QObject>
#include <QUrl>
#include <memory>
class Git
{
private:
Git();
public:
~Git();
static std::shared_ptr<Git> instance()
{
static std::shared_ptr<Git> s{new Git};
return s;
}
Git(Git const &) = delete;
void operator=(Git const &) = delete;
bool clone(QString url, QString path);
};
#endif

View File

@ -13,6 +13,7 @@ class Gpg
{
private:
Gpg();
QObject *m_window;
QString findCommandPath(const QString &command);
@ -42,7 +43,7 @@ public:
};
QPair< Error, std::vector< Key > > getAllKeys(bool remote = false, bool include_sigs = {}, bool
QPair<Error, std::vector<Key >> getAllKeys(bool remote = false, bool include_sigs = {}, bool
validate = false);
QPair<Error, std::vector<Key>> getKeys( QString pattern_uid, bool remote = false,
bool include_sigs = false,

View File

@ -3,7 +3,6 @@
#include <QtCore/QDir>
#include "pass.h"
#include "git.h"
#include "gpg.h"
#include "passkeymodel.h"
@ -22,8 +21,9 @@ void Pass::init(QObject *window)
Gpg::instance()->setWindow(window);
QDir dir(m_password_store);
if (!dir.exists())
if (!dir.exists()) {
dir.mkpath(".");
}
qInfo() << "Password Store is :" << m_password_store;
}
@ -62,13 +62,3 @@ QVariant Pass::gpgGetAllKeysModel()
Gpg::instance()->getAllKeys().second));
}
QString Pass::getPasswordStore()
{
return m_password_store;
}
bool Pass::gitClone(QString url)
{
qInfo() << "Cloning . password_store from " << url;
return Git::instance()->clone(url, m_password_store);
}

View File

@ -9,6 +9,9 @@
class Pass : public QObject
{
Q_OBJECT
Q_PROPERTY(QString password_store READ password_store)
private:
QString m_password_store;
signals:
@ -16,18 +19,17 @@ signals:
void decryptCanceled();
void decryptFailed();
public:
Pass();
~Pass() override = default;
QString password_store() const { return m_password_store; }
Q_INVOKABLE void init(QObject *window);
Q_INVOKABLE QString getPasswordStore();
Q_INVOKABLE void decrypt(QUrl url);
Q_INVOKABLE bool gpgDeleteKeyId(QString id);
Q_INVOKABLE bool gpgImportKeyFromFile(QUrl url);
Q_INVOKABLE QVariant gpgGetAllKeysModel();
Q_INVOKABLE bool gitClone(QString url);
};
#endif