Documentation for OpenFLUID 2.2.0
GitUIProxy.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30  */
31 
32 
33 /**
34  @file GitUIProxy.hpp
35 
36  @author Aline LIBRES <aline.libres@gmail.com>
37  @author Jean-Christophe Fabre <jean-christophe.fabre@inra.fr>
38 */
39 
40 
41 #ifndef __OPENFLUID_UIWARESDEV_GITUIPROXY_HPP__
42 #define __OPENFLUID_UIWARESDEV_GITUIPROXY_HPP__
43 
44 
45 #include <QString>
46 #include <QObject>
47 #include <QProcess>
48 #include <QMap>
49 
51 #include <openfluid/dllexport.hpp>
53 
54 
55 namespace openfluid { namespace ui { namespace waresdev {
56 
57 bool OPENFLUID_API forceRemove(const QString& Path);
58 
59 // removal of submodule directory in .git via explicit rm operation
60 bool cleanModuleDir(QString RootPath, openfluid::tools::FilesystemPath DestSubPath);
61 
62 
63 class OPENFLUID_API GitUIProxy : public QObject, public openfluid::utils::GitProxy
64 {
65  Q_OBJECT
66 
67  public:
68 
69  enum class FileStatus
70  {
71  TRACKED, UNTRACKED, IGNORED, CONFLICT, ADDED, DELETED, MODIFIED
72  };
73 
75  {
76  bool m_IsDirty = false;
77 
78  FileStatus m_IndexStatus = FileStatus::TRACKED;
79  };
80 
82  {
83  bool m_IsGitTracked = false;
84 
85  QString m_BranchName = "";
86 
87  QMap<QString, FileStatusInfo> m_FileStatusByTreePath;
88  };
89 
90 
91  private:
92 
93  QProcess* mp_Process = nullptr;
94 
95  QString m_TmpPath;
96 
97  static void findGitProgram();
98 
99 
100  private slots:
101 
102  void processStandardOutput();
103 
104  void processErrorOutput();
105 
106  void processErrorOutputAsInfo();
107 
108 
109  signals:
110 
111  void info(const QString& Message);
112 
113  void error(const QString& Message);
114 
115 
116  public:
117 
119 
121 
123 
124  bool launchAuthCommand(QStringList Args, const QString& FromUrl, const QString& ToPath,
125  const QString& Username = "", const QString& Password = "",
126  bool SslNoVerify = false, const QString& WorkingDirectory = "", bool UsernameViaEnv = false);
127 
128  bool addSubmodule(const QString& FromUrl, const QString& ToPath, const QString& LocalGitRepoPath,
129  const QString& Username = "", const QString& Password = "",
130  bool SslNoVerify = false);
131 
132  std::pair<bool, QString> removeSubmodule(const QString& Path, const QString& SubmodulePath);
133 
134  bool clone(const QString& FromUrl, const QString& ToPath,
135  const QString& Username = "", const QString& Password = "",
136  bool SslNoVerify = false, const QString& LocalGitRepoPath = "", bool WithoutVersioning = false);
137 
138  bool checkout(const QString& Path, const QString& BranchName, bool New=false);
139 
140  TreeStatusInfo status(const QString& Path);
141 
142  std::pair<int, QString> launchLocalCommand(const QString& Path, QStringList Args, bool RequiringDotGit = true);
143 
144  QString statusHtml(const QString& Path, bool WithColorCodes);
145 
146  QString logHtml(const QString& Path, bool WithColorCodes);
147 
148  QString init(const QString& WorkingDirectory);
149 
150 };
151 
152 
153 } } } // namespaces
154 
155 
156 #endif /* __OPENFLUID_UIWARESDEV_GITUIPROXY_HPP__ */
Definition: FilesystemPath.hpp:62
Definition: GitUIProxy.hpp:64
bool addSubmodule(const QString &FromUrl, const QString &ToPath, const QString &LocalGitRepoPath, const QString &Username="", const QString &Password="", bool SslNoVerify=false)
QString init(const QString &WorkingDirectory)
void error(const QString &Message)
bool launchAuthCommand(QStringList Args, const QString &FromUrl, const QString &ToPath, const QString &Username="", const QString &Password="", bool SslNoVerify=false, const QString &WorkingDirectory="", bool UsernameViaEnv=false)
QString logHtml(const QString &Path, bool WithColorCodes)
void info(const QString &Message)
std::pair< int, QString > launchLocalCommand(const QString &Path, QStringList Args, bool RequiringDotGit=true)
bool checkout(const QString &Path, const QString &BranchName, bool New=false)
static QString getCurrentOpenFLUIDBranchName()
QString statusHtml(const QString &Path, bool WithColorCodes)
TreeStatusInfo status(const QString &Path)
FileStatus
Definition: GitUIProxy.hpp:70
bool clone(const QString &FromUrl, const QString &ToPath, const QString &Username="", const QString &Password="", bool SslNoVerify=false, const QString &LocalGitRepoPath="", bool WithoutVersioning=false)
std::pair< bool, QString > removeSubmodule(const QString &Path, const QString &SubmodulePath)
Definition: GitProxy.hpp:56
#define OPENFLUID_API
Definition: dllexport.hpp:86
FilesystemPath Path
Definition: FilesystemPath.hpp:308
bool OPENFLUID_API forceRemove(const QString &Path)
bool cleanModuleDir(QString RootPath, openfluid::tools::FilesystemPath DestSubPath)
Definition: ApplicationException.hpp:47
QMap< QString, FileStatusInfo > m_FileStatusByTreePath
Definition: GitUIProxy.hpp:87