diff options
author | Weblate <noreply@weblate.org> | 2016-09-16 19:38:14 +0000 |
---|---|---|
committer | Weblate <noreply@weblate.org> | 2016-09-16 19:38:14 +0000 |
commit | 8be77a80c4430b85dae569923c3efc6ed2384472 (patch) | |
tree | a972234c061667fcd01fb2d76220567af1abe34f /src-qt5/desktop-utils/lumina-fm/gitCompat.h | |
parent | Translated using Weblate (lumina_DESKTOP@fa (generated)) (diff) | |
parent | Add syntax highlighting for "shell" files (.sh) (diff) | |
download | lumina-8be77a80c4430b85dae569923c3efc6ed2384472.tar.gz lumina-8be77a80c4430b85dae569923c3efc6ed2384472.tar.bz2 lumina-8be77a80c4430b85dae569923c3efc6ed2384472.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src-qt5/desktop-utils/lumina-fm/gitCompat.h')
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/gitCompat.h | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/gitCompat.h b/src-qt5/desktop-utils/lumina-fm/gitCompat.h index 6578bd5b..3e6cb15e 100644 --- a/src-qt5/desktop-utils/lumina-fm/gitCompat.h +++ b/src-qt5/desktop-utils/lumina-fm/gitCompat.h @@ -4,23 +4,49 @@ // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== -// This is the backend classe for interacting with the "git" utility +// This is the backend class for interacting with the "git" utility //=========================================== -#ifdef _LUMINA_FM_GIT_COMPAT_H +#ifndef _LUMINA_FM_GIT_COMPAT_H #define _LUMINA_FM_GIT_COMPAT_H #include <QProcess> #include <QString> #include <QProcessEnvironment> - +#include <QDebug> +#include <QTemporaryFile> #include <LuminaUtils.h> +#include <unistd.h> + +class GitProcess : public QProcess{ + Q_OBJECT +private: + QString log; + QFile tmpfile; +public: + GitProcess(); + ~GitProcess(); + + //Optional Inputs + void setSSHPassword(QString pass); //This is only used for SSH access + +private slots: + void cleanup(); + //void printoutput(){ qDebug() << "Proc Output:" << this->readAllStandardOutput(); } + +protected: + virtual void setupChildProcess(){ + //Need to disable the controlling terminal within this process + setsid(); //Make current process new session leader - resulting in no controlling terminal for this session + } +}; + class GIT{ public: //Check if the git utility is installed and available static bool isAvailable(){ - QString bin = "git" - return isValidBinary(bin); + QString bin = "git"; + return LUtils::isValidBinary(bin); } //Return if the current directory is a git repository @@ -28,7 +54,8 @@ public: QProcess P; P.setProcessEnvironment(QProcessEnvironment::systemEnvironment()); P.setWorkingDirectory(dir); - P.exec("git",QStringList() <<"status" << "--porcelain" ); + P.start("git",QStringList() <<"status" << "--porcelain" ); + P.waitForFinished(); return (0==P.exitCode()); } @@ -38,22 +65,23 @@ public: P.setProcessEnvironment(QProcessEnvironment::systemEnvironment()); P.setWorkingDirectory(dir); P.setProcessChannelMode(QProcess::MergedChannels); - P.exec("git",QStringList() <<"status" ); + P.start("git",QStringList() <<"status" ); + P.waitForFinished(); return P.readAllStandardOutput(); } //Setup a process for running the clone operation (so the calling process can hook up any watchers and start it when ready) - static QProcess setupClone(QString indir, QString url, QString branch = "", int depth = -1){ - QProcess P; - P.setProcessEnvironment( QProcessEnvironment::systemEnvironment() ); - P.setWorkingDirectory(indir); - P.setProgram("git"); + static GitProcess* setupClone(QString indir, QString url, QString branch = "", int depth = -1){ + //NOTE: The returned QProcess needs to be cleaned up when finished + GitProcess *P = new GitProcess(); + P->setWorkingDirectory(indir); + P->setProgram("git"); QStringList args; - args << "clone"; + args << "clone" << "--progress"; if(!branch.isEmpty()){ args << "-b" << branch; } if(depth>0){ args << "--depth" << QString::number(depth); } args << url; - P.setArguments(args); + P->setArguments(args); return P; } }; |