aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-fm-dev/gitCompat.h
diff options
context:
space:
mode:
authorWeblate <noreply@weblate.org>2017-08-19 14:59:53 +0000
committerWeblate <noreply@weblate.org>2017-08-19 14:59:53 +0000
commit7d3372ae81249c3f69f886df99fa7eb885d0757d (patch)
treeecad7dc336a43d4e2fcc61f7a58635c6455b6cc2 /src-qt5/desktop-utils/lumina-fm-dev/gitCompat.h
parentTranslated using Weblate (Danish) (diff)
parentTranslated using Weblate (Danish) (diff)
downloadlumina-7d3372ae81249c3f69f886df99fa7eb885d0757d.tar.gz
lumina-7d3372ae81249c3f69f886df99fa7eb885d0757d.tar.bz2
lumina-7d3372ae81249c3f69f886df99fa7eb885d0757d.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src-qt5/desktop-utils/lumina-fm-dev/gitCompat.h')
-rw-r--r--src-qt5/desktop-utils/lumina-fm-dev/gitCompat.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm-dev/gitCompat.h b/src-qt5/desktop-utils/lumina-fm-dev/gitCompat.h
new file mode 100644
index 00000000..4e63e780
--- /dev/null
+++ b/src-qt5/desktop-utils/lumina-fm-dev/gitCompat.h
@@ -0,0 +1,88 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2016, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// This is the backend class for interacting with the "git" utility
+//===========================================
+#ifndef _LUMINA_FM_GIT_COMPAT_H
+#define _LUMINA_FM_GIT_COMPAT_H
+
+#include <QProcess>
+#include <QString>
+#include <QProcessEnvironment>
+#include <QDebug>
+#include <QTemporaryFile>
+#include <LUtils.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 LUtils::isValidBinary(bin);
+ }
+
+ //Return if the current directory is a git repository
+ static bool isRepo(QString dir){
+ QProcess P;
+ P.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
+ P.setWorkingDirectory(dir);
+ P.start("git",QStringList() <<"status" << "--porcelain" );
+ P.waitForFinished();
+ return (0==P.exitCode());
+ }
+
+ //Return the current status of the repository
+ static QString status(QString dir){
+ QProcess P;
+ P.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
+ P.setWorkingDirectory(dir);
+ P.setProcessChannelMode(QProcess::MergedChannels);
+ 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 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" << "--progress";
+ if(!branch.isEmpty()){ args << "-b" << branch; }
+ if(depth>0){ args << "--depth" << QString::number(depth); }
+ args << url;
+ P->setArguments(args);
+ return P;
+ }
+};
+#endif
bgstack15