1
0
mirror of https://github.com/QRouland/UTPass.git synced 2025-01-27 17:06:39 +00:00
UTPass/plugins/Git/libgit.h

47 lines
915 B
C
Raw Normal View History

2025-01-10 13:48:38 +01:00
#ifndef LIBGIT_H
#define LIBGIT_H
#include <QObject>
#include <QUrl>
#include <git2/clone.h>
2025-01-10 13:48:38 +01:00
extern "C" {
#include <git2/transport.h>
}
#include <memory>
#include <variant>
struct Unset { };
struct HTTP { };
2025-01-13 18:11:16 +01:00
struct HTTPAuth {
QString pass;
};
struct SSHAuth { };
struct SSHKey { };
typedef std::variant<Unset, HTTP, HTTPAuth, SSHAuth, SSHKey> mode_type;
2025-01-10 13:48:38 +01:00
class LibGit
{
private:
LibGit();
mode_type mode;
2025-01-10 13:48:38 +01:00
static int credentials_cb(git_cred **out, const char *url, const char *username_from_url,
2025-01-10 15:28:42 +01:00
unsigned int allowed_types, void *payload);
2025-01-10 13:48:38 +01:00
public:
~LibGit();
static std::shared_ptr<LibGit> instance()
{
static std::shared_ptr<LibGit> s{new LibGit};
return s;
}
LibGit(LibGit const &) = delete;
void operator=(LibGit const &) = delete;
bool clone(QString url, QString path);
void set_mode(mode_type type);
2025-01-10 13:48:38 +01:00
};
#endif