2023-07-10 15:57:17 +02:00
|
|
|
#ifndef GIT_CLIENT_H_INCLUDED
|
|
|
|
#define GIT_CLIENT_H_INCLUDED
|
|
|
|
|
2023-07-14 13:10:55 +02:00
|
|
|
#include <QObject>
|
2023-08-02 15:17:10 +02:00
|
|
|
#include <QStringList>
|
2023-07-10 15:57:17 +02:00
|
|
|
#include <optional>
|
2024-12-20 13:01:34 +01:00
|
|
|
#include <QCoreApplication>
|
2023-07-10 15:57:17 +02:00
|
|
|
|
2023-08-02 15:17:10 +02:00
|
|
|
#include "ismas/ismas_client.h"
|
2023-07-10 15:57:17 +02:00
|
|
|
|
2023-07-14 13:10:55 +02:00
|
|
|
class Worker;
|
|
|
|
class GitClient : public QObject {
|
|
|
|
Q_OBJECT
|
2023-07-10 15:57:17 +02:00
|
|
|
|
2023-07-14 13:10:55 +02:00
|
|
|
Worker *m_worker;
|
|
|
|
QString const m_repositoryPath;
|
2023-07-17 16:51:40 +02:00
|
|
|
QString const m_customerNr;
|
2023-07-14 13:10:55 +02:00
|
|
|
QString const m_workingDirectory;
|
2023-08-02 15:17:10 +02:00
|
|
|
QString m_branchName;
|
2023-07-14 13:10:55 +02:00
|
|
|
QString const m_customerRepository;
|
2023-07-10 15:57:17 +02:00
|
|
|
|
2023-07-14 13:12:37 +02:00
|
|
|
bool copyGitConfigFromMaster();
|
2023-07-10 15:57:17 +02:00
|
|
|
|
|
|
|
public:
|
2024-06-28 10:03:10 +02:00
|
|
|
explicit GitClient(QString const &customerRepositoryUrl,
|
|
|
|
QString const &customerNrStr,
|
2023-07-17 16:51:40 +02:00
|
|
|
QString const &repositoryPath,
|
2023-07-14 13:12:37 +02:00
|
|
|
QString const &workingDirectory = QCoreApplication::applicationDirPath(),
|
|
|
|
QString const &branchName = "master",
|
|
|
|
QObject *parent = 0);
|
2023-07-10 15:57:17 +02:00
|
|
|
|
2023-07-14 13:12:37 +02:00
|
|
|
bool gitCloneCustomerRepository();
|
|
|
|
bool gitCheckoutBranch();
|
2023-08-02 15:17:10 +02:00
|
|
|
QStringList gitBranchNames();
|
2023-07-10 15:57:17 +02:00
|
|
|
|
2023-07-14 13:12:37 +02:00
|
|
|
QString const workingDirectory() const { return m_workingDirectory; }
|
|
|
|
QString workingDirectory() { return m_workingDirectory; }
|
|
|
|
|
|
|
|
QString const branchName() const { return m_branchName; }
|
|
|
|
QString branchName() { return m_branchName; }
|
|
|
|
|
|
|
|
QString repositoryPath() { return m_repositoryPath; }
|
|
|
|
QString const repositoryPath() const { return m_repositoryPath; }
|
|
|
|
|
|
|
|
bool gitCloneAndCheckoutBranch();
|
2023-07-10 15:57:17 +02:00
|
|
|
|
2023-10-30 14:56:19 +01:00
|
|
|
Worker *worker() { return m_worker; }
|
|
|
|
Worker const *worker() const { return m_worker; }
|
|
|
|
|
2023-10-18 11:35:23 +02:00
|
|
|
std::optional<QString> gitPull();
|
2023-07-10 15:57:17 +02:00
|
|
|
std::optional<QStringList> gitDiff(QString const &commit);
|
|
|
|
std::optional<QStringList> gitMerge();
|
2023-07-14 13:13:03 +02:00
|
|
|
|
2023-10-20 13:55:18 +02:00
|
|
|
bool gitFsck();
|
|
|
|
|
2023-07-14 13:13:03 +02:00
|
|
|
QString gitLastCommit(QString fileName);
|
2023-10-09 15:53:35 +02:00
|
|
|
QStringList gitShowReason(QString branchName);
|
2023-08-22 12:19:25 +02:00
|
|
|
static QString gitBlob(QString fileName);
|
2023-07-14 13:13:03 +02:00
|
|
|
QString gitCommitForBlob(QString blob);
|
|
|
|
bool gitIsFileTracked(QString file2name);
|
2024-04-11 16:24:33 +02:00
|
|
|
|
|
|
|
bool branchExistsRemotely();
|
|
|
|
bool branchExistsLocally();
|
|
|
|
bool gitPullNewBranches();
|
2023-07-10 15:57:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GIT_CLIENT_H_INCLUDED
|