mirror of
https://github.com/QRouland/UTPass.git
synced 2025-01-24 07:36:39 +00:00
Some cleanup
This commit is contained in:
parent
6ac11e2da7
commit
063f66e99a
@ -4,7 +4,7 @@ kill: UTPass
|
||||
|
||||
scripts:
|
||||
style: >-
|
||||
echo 'Running Astyle :' && astyle --options=.astylerc main.cpp && astyle --options=.astylerc --recursive 'plugins/*.cpp,*.h' && echo 'Running QmlFormat' && find . -name "*.qml" -exec qmlformat -i {} \; && echo 'Success'
|
||||
echo 'Running Astyle :' && astyle --options=.astylerc --recursive '*.cpp,*.h' --exclude=build && echo 'Running QmlFormat' && find . -name "*.qml" -exec qmlformat -i {} \; && echo 'Success'
|
||||
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@ set(
|
||||
plugin.cpp
|
||||
libgit.cpp
|
||||
git.cpp
|
||||
|
||||
templates.h
|
||||
)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
@ -6,14 +6,7 @@
|
||||
|
||||
#include "git.h"
|
||||
#include "libgit.h"
|
||||
|
||||
|
||||
template<class... Ts>
|
||||
struct overload : Ts... {
|
||||
using Ts::operator()...;
|
||||
};
|
||||
template<class... Ts>
|
||||
overload(Ts...) -> overload<Ts...>;
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
QDir Git::clone_setup()
|
||||
@ -29,7 +22,7 @@ QDir Git::clone_setup()
|
||||
|
||||
bool Git::clone_tear_down(QDir tmp_dir)
|
||||
{
|
||||
tmp_dir.removeRecursively();
|
||||
return tmp_dir.removeRecursively();
|
||||
}
|
||||
|
||||
bool Git::move_to_destination(QString path, QDir tmp_dir)
|
||||
@ -63,9 +56,11 @@ bool Git::clone(QString url, QString path, mode_type mode) //, GitPlugin::RepoTy
|
||||
qDebug() << "Cloning " << url << " to tmp dir " << tmp_dir.absolutePath();
|
||||
auto ret = LibGit::instance()->clone(url, tmp_dir.absolutePath()); // TODO Better error handling
|
||||
|
||||
if (ret) { this->move_to_destination(path, tmp_dir);}
|
||||
if (ret) {
|
||||
this->move_to_destination(path, tmp_dir);
|
||||
}
|
||||
|
||||
tmp_dir.removeRecursively();
|
||||
this->clone_tear_down(tmp_dir);
|
||||
LibGit::instance()->set_mode(Unset());
|
||||
|
||||
return ret ;
|
||||
@ -77,7 +72,8 @@ bool Git::clone_http(QString url, QString path) //, GitPlugin::RepoType type, QS
|
||||
return this->clone(url, path, mode);
|
||||
}
|
||||
|
||||
bool Git::clone_http_pass(QString url, QString path, QString pass) {
|
||||
bool Git::clone_http_pass(QString url, QString path, QString pass)
|
||||
{
|
||||
HTTPAuth mode = { pass };
|
||||
return this->clone(url, path, mode);
|
||||
}
|
||||
|
@ -7,14 +7,9 @@ extern "C" {
|
||||
}
|
||||
|
||||
#include "libgit.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
template<class... Ts>
|
||||
struct overload : Ts... {
|
||||
using Ts::operator()...;
|
||||
};
|
||||
template<class... Ts>
|
||||
overload(Ts...) -> overload<Ts...>;
|
||||
|
||||
LibGit::LibGit()
|
||||
{
|
||||
@ -26,7 +21,8 @@ LibGit::~LibGit()
|
||||
git_libgit2_shutdown();
|
||||
}
|
||||
|
||||
void LibGit::set_mode(mode_type type) {
|
||||
void LibGit::set_mode(mode_type type)
|
||||
{
|
||||
this->mode = type;
|
||||
}
|
||||
|
||||
@ -36,17 +32,20 @@ int LibGit::credentials_cb(git_cred **out, const char *url, const char *username
|
||||
// TODO : More precise Error Handling for UI
|
||||
auto instance = LibGit::instance();
|
||||
auto v = overload {
|
||||
[](const Unset& x) {
|
||||
[](const Unset & x)
|
||||
{
|
||||
qDebug() << "credentials_cb : Unset ";
|
||||
qWarning() << "credentials_cb : callback should never be call for Unset ";
|
||||
return (int) GIT_EUSER;
|
||||
},
|
||||
[](const HTTP& x) {
|
||||
[](const HTTP & x)
|
||||
{
|
||||
qDebug() << "credentials_cb : HTTP ";
|
||||
qWarning() << "credentials_cb : callback should never be call for HTTP ";
|
||||
return (int) GIT_EUSER;
|
||||
},
|
||||
[&out, &username_from_url](const HTTPAuth& x) {
|
||||
[&out, &username_from_url](const HTTPAuth & x)
|
||||
{
|
||||
qDebug() << "credentials_cb : HTTPAuth ";
|
||||
if (!username_from_url) {
|
||||
qWarning() << "credentials_cb : no username provided ";
|
||||
@ -54,11 +53,13 @@ int LibGit::credentials_cb(git_cred **out, const char *url, const char *username
|
||||
}
|
||||
return git_cred_userpass_plaintext_new(out, username_from_url, x.pass.toLocal8Bit().constData());
|
||||
},
|
||||
[&](const SSHAuth& x) {
|
||||
[&](const SSHAuth & x)
|
||||
{
|
||||
qWarning() << "credentials_cb : SSHAuth to be implemented ";
|
||||
return (int) GIT_EUSER;
|
||||
}, // TODO
|
||||
[&](const SSHKey& x) {
|
||||
[&](const SSHKey & x)
|
||||
{
|
||||
qWarning() << "credentials_cb : SSHKey to be implemented ";
|
||||
return (int) GIT_EUSER;
|
||||
} // TODO
|
||||
|
@ -12,7 +12,9 @@ extern "C" {
|
||||
|
||||
struct Unset { };
|
||||
struct HTTP { };
|
||||
struct HTTPAuth { QString pass; };
|
||||
struct HTTPAuth {
|
||||
QString pass;
|
||||
};
|
||||
struct SSHAuth { };
|
||||
struct SSHKey { };
|
||||
typedef std::variant<Unset, HTTP, HTTPAuth, SSHAuth, SSHKey> mode_type;
|
||||
|
11
plugins/Git/utils.h
Normal file
11
plugins/Git/utils.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
template<class... Ts>
|
||||
struct overload : Ts... {
|
||||
using Ts::operator()...;
|
||||
};
|
||||
template<class... Ts>
|
||||
overload(Ts...) -> overload<Ts...>;
|
||||
|
||||
#endif // UTILS_H
|
@ -19,10 +19,10 @@ MainView {
|
||||
//TODO use parameters to impove passphrase dialog
|
||||
var passphraseDialog = PopupUtils.open(Qt.resolvedUrl("dialogs/PassphraseDialog.qml"));
|
||||
passphraseDialog.activateFocus();
|
||||
var validated = function (passphrase) {
|
||||
var validated = function validated(passphrase) {
|
||||
responsePassphraseDialog(false, passphrase);
|
||||
};
|
||||
var canceled = function () {
|
||||
var canceled = function canceled() {
|
||||
responsePassphraseDialog(true, "");
|
||||
};
|
||||
passphraseDialog.validated.connect(validated);
|
||||
|
@ -69,12 +69,10 @@ Page {
|
||||
text: i18n.tr('Clone')
|
||||
onClicked: {
|
||||
var ret = false;
|
||||
if(repoPasswordInput.text === "") {
|
||||
if (repoPasswordInput.text === "")
|
||||
ret = Git.clone_http(repoUrlInput.text, Pass.password_store);
|
||||
} else {
|
||||
else
|
||||
ret = Git.clone_http_pass(repoUrlInput.text, Pass.password_store, repoPasswordInput.text);
|
||||
}
|
||||
|
||||
if (ret)
|
||||
PopupUtils.open(dialogImportGitCloneSuccess);
|
||||
else
|
||||
|
@ -8,7 +8,8 @@
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
QString TestsUtils::getTempPath() {
|
||||
QString TestsUtils::getTempPath()
|
||||
{
|
||||
qFatal("yp");
|
||||
// Get the system's temporary directory
|
||||
QString tempDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
|
||||
|
@ -1,12 +1,11 @@
|
||||
import Git 1.0
|
||||
import QtQuick 2.9
|
||||
import QtTest 1.2
|
||||
import Git 1.0
|
||||
|
||||
TestCase {
|
||||
name: "git"
|
||||
|
||||
function test_git_clone() {
|
||||
|
||||
verify(Git.clone("", ""));
|
||||
}
|
||||
|
||||
name: "git"
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
import Git 1.0
|
||||
import QtQuick 2.9
|
||||
import QtTest 1.2
|
||||
import Git 1.0
|
||||
|
||||
TestCase {
|
||||
name: "git"
|
||||
|
||||
function test_git_clone() {
|
||||
|
||||
verify(Git.clone("", ""));
|
||||
}
|
||||
|
||||
name: "git"
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ import TestUtils 1.0
|
||||
import Utils 1.0
|
||||
|
||||
TestCase {
|
||||
name: "utils"
|
||||
|
||||
function test_unzip() {
|
||||
var tempPath = TestUtils.getTempPath() + "/password-store";
|
||||
var zipUrl = Qt.resolvedUrl("../assets/archive.zip");
|
||||
var r = Utils.unzip(zipUrl, tempPath)
|
||||
verify(r, "Unzip return an error %1".arg(zipUrl))
|
||||
var r = Utils.unzip(zipUrl, tempPath);
|
||||
verify(r, "Unzip return an error %1".arg(zipUrl));
|
||||
}
|
||||
|
||||
name: "utils"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user