diff options
author | Ken Moore <ken@pcbsd.org> | 2016-09-07 12:26:57 -0400 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2016-09-07 12:26:57 -0400 |
commit | 3ca41de3333f47071289b6398a3f8c677dbdab89 (patch) | |
tree | ad209920734f6057eb4a3179f6689e843785c028 /src-qt5/desktop-utils | |
parent | Fix up the bracket matching routine when going backwards exactly one space "(... (diff) | |
download | lumina-3ca41de3333f47071289b6398a3f8c677dbdab89.tar.gz lumina-3ca41de3333f47071289b6398a3f8c677dbdab89.tar.bz2 lumina-3ca41de3333f47071289b6398a3f8c677dbdab89.zip |
Add the backend class/functions for using GIT within lumina-fm.
Diffstat (limited to 'src-qt5/desktop-utils')
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/gitCompat.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/gitCompat.h b/src-qt5/desktop-utils/lumina-fm/gitCompat.h new file mode 100644 index 00000000..6578bd5b --- /dev/null +++ b/src-qt5/desktop-utils/lumina-fm/gitCompat.h @@ -0,0 +1,60 @@ +//=========================================== +// 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 classe for interacting with the "git" utility +//=========================================== +#ifdef _LUMINA_FM_GIT_COMPAT_H +#define _LUMINA_FM_GIT_COMPAT_H + +#include <QProcess> +#include <QString> +#include <QProcessEnvironment> + +#include <LuminaUtils.h> + +class GIT{ +public: + //Check if the git utility is installed and available + static bool isAvailable(){ + QString bin = "git" + return 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.exec("git",QStringList() <<"status" << "--porcelain" ); + 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.exec("git",QStringList() <<"status" ); + 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"); + QStringList args; + args << "clone"; + if(!branch.isEmpty()){ args << "-b" << branch; } + if(depth>0){ args << "--depth" << QString::number(depth); } + args << url; + P.setArguments(args); + return P; + } +}; +#endif |