Commit 37aa02a3 authored by Martin Koller's avatar Martin Koller

make it work with with git-lfs

Fixed 2 issues:
- git-lfs uses yet another syntax for the prompt
- KWallet writes an error to stderr when a 0-winId is given to
  openWallet() which is received by git-lfs and aborts the operation.

Differential Revision: https://phabricator.kde.org/D9072
parent 959b9699
......@@ -32,6 +32,7 @@
#include <QPointer>
#include <QRegularExpression>
#include <QLoggingCategory>
#include <QDesktopWidget>
Q_LOGGING_CATEGORY(LOG_KSSHASKPASS, "ksshaskpass")
......@@ -68,6 +69,15 @@ static void parsePrompt(const QString &prompt, QString& keyFile, bool& wrongPass
return;
}
// Case 3a: password extraction from git-lfs
QRegularExpression re3a("^(Password|Username) for \"(.*?)\"$");
QRegularExpressionMatch match3a = re3a.match(prompt);
if (match3a.hasMatch()) {
keyFile = match3a.captured(2);
wrongPassphrase = false;
return;
}
// Case 4: password extraction from mercurial, see bug 380085
QRegularExpression re4("^(.*?)'s password: $");
QRegularExpressionMatch match4 = re4.match(prompt);
......@@ -124,7 +134,8 @@ int main(int argc, char **argv)
}
// Open KWallet to see if a password was previously stored
std::auto_ptr<KWallet::Wallet> wallet(KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), 0));
WId winId = QApplication::desktop()->winId();
std::auto_ptr<KWallet::Wallet> wallet(KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), winId));
if ((!wrongPassphrase) && (!keyFile.isNull()) && wallet.get() && wallet->hasFolder(walletFolder)) {
wallet->setFolder(walletFolder);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment