From 6a622f907eb9d04b21b601d411f3557d71982492 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sat, 26 Feb 2022 18:50:07 +0800 Subject: [PATCH] git askpass for linux --- RedPandaIDE/vcs/gitmanager.cpp | 4 ++ Red_Panda_CPP.pro | 5 +++ packages/debian/builddeb.sh | 2 +- packages/debian/changelog | 6 +++ redpanda-git-askpass/dialog.cpp | 37 +++++++++++++++++++ redpanda-git-askpass/dialog.h | 30 +++++++++++++++ redpanda-git-askpass/dialog.ui | 31 ++++++++++++++++ redpanda-git-askpass/main.cpp | 18 +++++++++ redpanda-git-askpass/redpanda-git-askpass.pro | 31 ++++++++++++++++ .../redpanda-win-git-askpass.pro | 6 ++- 10 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 redpanda-git-askpass/dialog.cpp create mode 100644 redpanda-git-askpass/dialog.h create mode 100644 redpanda-git-askpass/dialog.ui create mode 100644 redpanda-git-askpass/main.cpp create mode 100644 redpanda-git-askpass/redpanda-git-askpass.pro diff --git a/RedPandaIDE/vcs/gitmanager.cpp b/RedPandaIDE/vcs/gitmanager.cpp index b7792d5a..a559cde8 100644 --- a/RedPandaIDE/vcs/gitmanager.cpp +++ b/RedPandaIDE/vcs/gitmanager.cpp @@ -588,7 +588,11 @@ QString GitManager::runGit(const QString& workingFolder, const QStringList &args // qDebug()<dirs().appDir()); +#ifdef Q_OS_WIN env.insert("GIT_ASKPASS",includeTrailingPathDelimiter(pSettings->dirs().appDir())+"redpanda-win-git-askpass.exe"); +#else + env.insert("GIT_ASKPASS",includeTrailingPathDelimiter(pSettings->dirs().appDir())+"redpanda-git-askpass.exe"); +#endif QString output = runAndGetOutput( fileInfo.absoluteFilePath(), workingFolder, diff --git a/Red_Panda_CPP.pro b/Red_Panda_CPP.pro index 6883dc40..015775a5 100644 --- a/Red_Panda_CPP.pro +++ b/Red_Panda_CPP.pro @@ -10,6 +10,11 @@ SUBDIRS += \ redpanda-win-git-askpass } +linux: { +SUBDIRS += \ + redpanda-git-askpass +} + APP_NAME = RedPandaCPP APP_VERSION = 0.14.4 diff --git a/packages/debian/builddeb.sh b/packages/debian/builddeb.sh index a07dd979..16afb6c7 100755 --- a/packages/debian/builddeb.sh +++ b/packages/debian/builddeb.sh @@ -7,9 +7,9 @@ test -n $TMP_FOLDER | rm -rf $TMP_FOLDER test -z $TMP_FOLDER | mkdir $TMP_FOLDER - cp -r packages/debian $TMP_FOLDER cp -r astyle $TMP_FOLDER +cp -r redpanda-git-askpass $TMP_FOLDER cp -r consolepauser $TMP_FOLDER cp -r RedPandaIDE $TMP_FOLDER cp README.md $TMP_FOLDER diff --git a/packages/debian/changelog b/packages/debian/changelog index 2b2a2e61..3ba6f913 100644 --- a/packages/debian/changelog +++ b/packages/debian/changelog @@ -1,3 +1,9 @@ +redpanda-cpp (0.14.4-1) unstable; urgency=medium + + * Update to 0.14.4 + + -- Roy Qu (瞿华) Sat, 26 Feb 2022 18:48:00 +0800 + redpanda-cpp (0.14.2-1) unstable; urgency=medium * Update to 0.14.2 diff --git a/redpanda-git-askpass/dialog.cpp b/redpanda-git-askpass/dialog.cpp new file mode 100644 index 00000000..26f9d3c5 --- /dev/null +++ b/redpanda-git-askpass/dialog.cpp @@ -0,0 +1,37 @@ +#include "dialog.h" +#include "ui_dialog.h" + +Dialog::Dialog(QWidget *parent) + : QDialog(parent) + , ui(new Ui::Dialog) +{ + ui->setupUi(this); +} + +Dialog::~Dialog() +{ + delete ui; +} + +int Dialog::showPrompt(const QString &prompt) +{ + ui->txtPrompt->setText(prompt); + return exec(); +} + +QString Dialog::getInput() +{ + return ui->txtInput->text(); +} + + +void Dialog::on_txtInput_returnPressed() +{ + if (!ui->txtInput->text().isEmpty()) + accept(); +} + +void Dialog::closeEvent(QCloseEvent *event) +{ + reject(); +} diff --git a/redpanda-git-askpass/dialog.h b/redpanda-git-askpass/dialog.h new file mode 100644 index 00000000..b5a76982 --- /dev/null +++ b/redpanda-git-askpass/dialog.h @@ -0,0 +1,30 @@ +#ifndef DIALOG_H +#define DIALOG_H + +#include + +QT_BEGIN_NAMESPACE +namespace Ui { class Dialog; } +QT_END_NAMESPACE + +class Dialog : public QDialog +{ + Q_OBJECT + +public: + Dialog(QWidget *parent = nullptr); + ~Dialog(); + int showPrompt(const QString& prompt); + QString getInput(); + +private slots: + void on_txtInput_returnPressed(); + +private: + Ui::Dialog *ui; + + // QWidget interface +protected: + void closeEvent(QCloseEvent *event) override; +}; +#endif // DIALOG_H diff --git a/redpanda-git-askpass/dialog.ui b/redpanda-git-askpass/dialog.ui new file mode 100644 index 00000000..f49a194b --- /dev/null +++ b/redpanda-git-askpass/dialog.ui @@ -0,0 +1,31 @@ + + + Dialog + + + + 0 + 0 + 417 + 110 + + + + Git Ask Pass + + + + + + TextLabel + + + + + + + + + + + diff --git a/redpanda-git-askpass/main.cpp b/redpanda-git-askpass/main.cpp new file mode 100644 index 00000000..f67f6ad8 --- /dev/null +++ b/redpanda-git-askpass/main.cpp @@ -0,0 +1,18 @@ +#include "dialog.h" + +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + if (argc>1) { + Dialog w; + if (w.showPrompt(argv[1])==QDialog::Accepted) { + char* input = w.getInput().toLocal8Bit().data(); + printf(input); + } + } + return 0; +} diff --git a/redpanda-git-askpass/redpanda-git-askpass.pro b/redpanda-git-askpass/redpanda-git-askpass.pro new file mode 100644 index 00000000..a81e9b28 --- /dev/null +++ b/redpanda-git-askpass/redpanda-git-askpass.pro @@ -0,0 +1,31 @@ +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +CONFIG += c++11 + +isEmpty(APP_NAME) { + APP_NAME = RedPandaCPP +} +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + main.cpp \ + dialog.cpp + +HEADERS += \ + dialog.h + +FORMS += \ + dialog.ui + +isEmpty(PREFIX) { + PREFIX = /usr/local +} + +# Default rules for deployment. +qnx: target.path = $${PREFIX}/libexec/$${APP_NAME} +else: unix:!android: target.path = $${PREFIX}/libexec/$${APP_NAME} +!isEmpty(target.path): INSTALLS += target diff --git a/redpanda-win-git-askpass/redpanda-win-git-askpass.pro b/redpanda-win-git-askpass/redpanda-win-git-askpass.pro index 009476e6..dca2f6a9 100644 --- a/redpanda-win-git-askpass/redpanda-win-git-askpass.pro +++ b/redpanda-win-git-askpass/redpanda-win-git-askpass.pro @@ -4,6 +4,10 @@ CONFIG -= app_bundle CONFIG -= qt DEFINES -= UNICODE +isEmpty(APP_NAME) { + APP_NAME = RedPandaCPP +} + SOURCES += \ main.c @@ -25,4 +29,4 @@ win32: { # Default rules for deployment. qnx: target.path = $${PREFIX}/libexec/$${APP_NAME} else: unix:!android: target.path = $${PREFIX}/libexec/$${APP_NAME} -!isEmpty(target.path): INSTALLS += target \ No newline at end of file +!isEmpty(target.path): INSTALLS += target