mirror of
https://github.com/QRouland/UTPass.git
synced 2026-01-08 10:46:58 +00:00
Foramtting
This commit is contained in:
@@ -22,7 +22,8 @@ enum class GitCloneErrorCode {
|
||||
* @param error A pointer to the git_error structure
|
||||
* @return Corresponding GitCloneErrorCode integer value
|
||||
*/
|
||||
inline GitCloneErrorCode gitErrorToGitCloneErrorCode(const git_error* error) {
|
||||
inline GitCloneErrorCode gitErrorToGitCloneErrorCode(const git_error* error)
|
||||
{
|
||||
if (error == nullptr) {
|
||||
return GitCloneErrorCode::Successful; ///< Default error if null
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ extern "C" {
|
||||
Git::Git():
|
||||
m_sem(std::unique_ptr<QSemaphore>(new QSemaphore(1))),
|
||||
m_ssh_homedir (QStandardPaths::writableLocation(
|
||||
QStandardPaths::AppDataLocation).append("/.ssh"))
|
||||
QStandardPaths::AppDataLocation).append("/.ssh"))
|
||||
{
|
||||
qDebug() << "[Git] SSH Home is " << m_ssh_homedir.absolutePath();
|
||||
QDir m_ssh_homedir(this->m_ssh_homedir);
|
||||
@@ -83,7 +83,8 @@ void Git::cloneResult(const int err_code, const QString message)
|
||||
this->m_sem->release();
|
||||
}
|
||||
|
||||
bool Git::importSshKey(QUrl source_path, bool is_private){
|
||||
bool Git::importSshKey(QUrl source_path, bool is_private)
|
||||
{
|
||||
auto destination_path = is_private ? this->privKeyPath() : this->pubKeyPath();
|
||||
|
||||
QFile source_file(source_path.toLocalFile());
|
||||
|
||||
@@ -62,14 +62,16 @@ bool CloneJob::moveToDestination(QDir tmp_dir, const QString& path)
|
||||
qDebug() << "[CloneJob] Moving cloned content to destination dir";
|
||||
|
||||
if (!QDir().rename(tmp_dir.absolutePath(), destination_dir.absolutePath())) {
|
||||
qWarning() << "[CloneJob] Failed to move directory from" << tmp_dir.absolutePath() << "to" << destination_dir.absolutePath();
|
||||
qWarning() << "[CloneJob] Failed to move directory from" << tmp_dir.absolutePath() << "to" <<
|
||||
destination_dir.absolutePath();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const QPair<GitCloneErrorCode, QString> CloneJob::clone(QString url, QString path, cred_type cred, git_cred_acquire_cb cb)
|
||||
const QPair<GitCloneErrorCode, QString> CloneJob::clone(QString url, QString path, cred_type cred,
|
||||
git_cred_acquire_cb cb)
|
||||
{
|
||||
git_repository *repo = nullptr; // Use nullptr for type safety
|
||||
git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
|
||||
@@ -82,11 +84,11 @@ const QPair<GitCloneErrorCode, QString> CloneJob::clone(QString url, QString pat
|
||||
|
||||
// Map the application specific cb errors if any
|
||||
if (ret == GIT_EUSER) {
|
||||
if(payload.err == ErrorCodeCB::NoUsername)
|
||||
if (payload.err == ErrorCodeCB::NoUsername)
|
||||
return {GitCloneErrorCode::NoUsername, "no username provided in URL"};
|
||||
if(payload.err == ErrorCodeCB::InvalidCreds)
|
||||
if (payload.err == ErrorCodeCB::InvalidCreds)
|
||||
return {GitCloneErrorCode::AuthentificationError, "authentification error"};
|
||||
if(payload.err == ErrorCodeCB::UrlTypeDoNotMatchCreds)
|
||||
if (payload.err == ErrorCodeCB::UrlTypeDoNotMatchCreds)
|
||||
return {GitCloneErrorCode::UrlTypeDoNotMatchCreds, "invalid creds types for provided url"};
|
||||
return {GitCloneErrorCode::UnexpectedError, "unexcepted error occured"};
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ class CloneJob : public GitJob
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when the cloning operation is complete.
|
||||
*
|
||||
* This signal is emitted once the cloning operation finishes.
|
||||
*
|
||||
* @param err A Git error.
|
||||
*/
|
||||
* @brief Signal emitted when the cloning operation is complete.
|
||||
*
|
||||
* This signal is emitted once the cloning operation finishes.
|
||||
*
|
||||
* @param err A Git error.
|
||||
*/
|
||||
void resultReady(const int err_code, const QString message);
|
||||
|
||||
private:
|
||||
|
||||
@@ -57,7 +57,7 @@ int GitJob::credentialsCB(git_cred **out, const char *url, const char *username_
|
||||
}
|
||||
return git_cred_userpass_plaintext_new(out, username_from_url, x.pass.toLocal8Bit().constData());
|
||||
},
|
||||
[allowed_types, &out, &username_from_url , &p](const SSHKey & x)
|
||||
[allowed_types, &out, &username_from_url, &p](const SSHKey & x)
|
||||
{
|
||||
qDebug() << "[GitJob] credentialsCB : SSHKey ";
|
||||
if (!(allowed_types & GIT_CREDTYPE_SSH_KEY)) {
|
||||
|
||||
@@ -39,8 +39,7 @@ enum class ErrorCodeCB {
|
||||
};
|
||||
|
||||
|
||||
struct PayloadCB
|
||||
{
|
||||
struct PayloadCB {
|
||||
bool called;
|
||||
cred_type creds;
|
||||
ErrorCodeCB err;
|
||||
|
||||
Reference in New Issue
Block a user