Simplified interface.
When doing a clone of the repository, do not execute any other commands.
This commit is contained in:
		@@ -7,20 +7,18 @@
 | 
				
			|||||||
#include <QDir>
 | 
					#include <QDir>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
GitClient::GitClient(QString const &repositoryPath,
 | 
					GitClient::GitClient(QString const &customerNrStr,
 | 
				
			||||||
                     QString const &customerId,
 | 
					                     QString const &customerRepository,
 | 
				
			||||||
                     QString const &workingDirectory,
 | 
					                     QString const &workingDirectory,
 | 
				
			||||||
                     QString const &branchName,
 | 
					                     QString const &branchName,
 | 
				
			||||||
                     QObject *parent)
 | 
					                     QObject *parent)
 | 
				
			||||||
  : QObject(parent)
 | 
					  : QObject(parent)
 | 
				
			||||||
  , m_worker(qobject_cast<Worker *>(parent))
 | 
					  , m_worker(qobject_cast<Worker *>(parent))
 | 
				
			||||||
  , m_repositoryPath(repositoryPath)
 | 
					  , m_repositoryPath(QString("https://git.mimbach49.de/GerhardHoffmann/%1.git").arg(customerNrStr))
 | 
				
			||||||
  , m_customerId(customerId)
 | 
					  , m_customerNr(customerNrStr)
 | 
				
			||||||
  , m_workingDirectory(workingDirectory)
 | 
					  , m_workingDirectory(workingDirectory)
 | 
				
			||||||
  , m_branchName(branchName)
 | 
					  , m_branchName(branchName)
 | 
				
			||||||
  , m_customerRepository(QDir::cleanPath(m_workingDirectory
 | 
					  , m_customerRepository(customerRepository) {
 | 
				
			||||||
                                       + QDir::separator()
 | 
					 | 
				
			||||||
                                       + m_customerId)) {
 | 
					 | 
				
			||||||
    if (!m_worker) {
 | 
					    if (!m_worker) {
 | 
				
			||||||
        qCritical() << "ERROR CASTING PARENT TO WORKER FAILED";
 | 
					        qCritical() << "ERROR CASTING PARENT TO WORKER FAILED";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -63,18 +61,6 @@ void GitClient::onIsmasUpdatesAvailable() {
 | 
				
			|||||||
        if (gitCloneAndCheckoutBranch()) {
 | 
					        if (gitCloneAndCheckoutBranch()) {
 | 
				
			||||||
            qInfo() << "CLONED" << m_repositoryPath
 | 
					            qInfo() << "CLONED" << m_repositoryPath
 | 
				
			||||||
                    << "AND CHECKED OUT INTO" << m_customerRepository;
 | 
					                    << "AND CHECKED OUT INTO" << m_customerRepository;
 | 
				
			||||||
            if (m_worker) {
 | 
					 | 
				
			||||||
                qDebug() << "WORKER EXECUTE OPKG COMMANDS";
 | 
					 | 
				
			||||||
                QStringList opkgCommands;
 | 
					 | 
				
			||||||
                // To make sure that opkg upgrade does not break your system
 | 
					 | 
				
			||||||
                // because of an unstable connection
 | 
					 | 
				
			||||||
                // Add a line "option cache cachedir" to /etc/opkg/opkg.conf to
 | 
					 | 
				
			||||||
                // avoid the --cache option on command line.
 | 
					 | 
				
			||||||
                opkgCommands << "opkg update";
 | 
					 | 
				
			||||||
                //opkgCommands << "opkg --cache cachedir --download-only upgrade";
 | 
					 | 
				
			||||||
                //opkgCommands << "opkg --cache cachedir upgrade";
 | 
					 | 
				
			||||||
                emit m_worker->executeOpkgCommands(opkgCommands);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            qCritical() << "ERROR CLONING " << m_repositoryPath
 | 
					            qCritical() << "ERROR CLONING " << m_repositoryPath
 | 
				
			||||||
                        << "AND/OR CHECKING OUT INTO" << m_customerRepository;
 | 
					                        << "AND/OR CHECKING OUT INTO" << m_customerRepository;
 | 
				
			||||||
@@ -99,7 +85,7 @@ bool GitClient::gitCloneCustomerRepository() {
 | 
				
			|||||||
            QRegularExpressionMatch match = re.match(result);
 | 
					            QRegularExpressionMatch match = re.match(result);
 | 
				
			||||||
            if (match.hasMatch()) {
 | 
					            if (match.hasMatch()) {
 | 
				
			||||||
                if (re.captureCount() == 3) { // start with full match (0), then the other 3 matches
 | 
					                if (re.captureCount() == 3) { // start with full match (0), then the other 3 matches
 | 
				
			||||||
                    if (match.captured(2).trimmed() == m_customerId) {
 | 
					                    if (match.captured(2).trimmed() == m_customerNr) {
 | 
				
			||||||
                        qInfo() << "CLONING" << m_repositoryPath << "OK";
 | 
					                        qInfo() << "CLONING" << m_repositoryPath << "OK";
 | 
				
			||||||
                        return true;
 | 
					                        return true;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
@@ -112,7 +98,7 @@ bool GitClient::gitCloneCustomerRepository() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool GitClient::copyGitConfigFromMaster() { // only allowed when called in
 | 
					bool GitClient::copyGitConfigFromMaster() { // only allowed when called in
 | 
				
			||||||
                                            // master branch
 | 
					                                            // master branch (???)
 | 
				
			||||||
    if (QDir(m_customerRepository).exists()) {
 | 
					    if (QDir(m_customerRepository).exists()) {
 | 
				
			||||||
        QString const cp = QString("cp .gitconfig .git/config");
 | 
					        QString const cp = QString("cp .gitconfig .git/config");
 | 
				
			||||||
        Command c("bash");
 | 
					        Command c("bash");
 | 
				
			||||||
@@ -139,9 +125,9 @@ bool GitClient::gitCheckoutBranch() {
 | 
				
			|||||||
bool GitClient::gitCloneAndCheckoutBranch() {
 | 
					bool GitClient::gitCloneAndCheckoutBranch() {
 | 
				
			||||||
    qInfo() << "CLONE" << m_repositoryPath << "AND CHECKOUT" << m_branchName;
 | 
					    qInfo() << "CLONE" << m_repositoryPath << "AND CHECKOUT" << m_branchName;
 | 
				
			||||||
    if (gitCloneCustomerRepository()) {
 | 
					    if (gitCloneCustomerRepository()) {
 | 
				
			||||||
        if (copyGitConfigFromMaster()) {
 | 
					        //if (copyGitConfigFromMaster()) {
 | 
				
			||||||
            return gitCheckoutBranch();
 | 
					            return gitCheckoutBranch();
 | 
				
			||||||
        }
 | 
					        //}
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -191,11 +177,9 @@ std::optional<QStringList> GitClient::gitDiff(QString const &commits) {
 | 
				
			|||||||
 Hat sich nichts geaendert, so werden auch keine Commits <>..<> angezeigt
 | 
					 Hat sich nichts geaendert, so werden auch keine Commits <>..<> angezeigt
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
std::optional<QString> GitClient::gitFetch() {
 | 
					std::optional<QString> GitClient::gitFetch() {
 | 
				
			||||||
    QString const &customerRepository
 | 
					    if (QDir(m_customerRepository).exists()) {
 | 
				
			||||||
        = QDir::cleanPath(m_workingDirectory + QDir::separator() + m_customerId);
 | 
					 | 
				
			||||||
    if (QDir(customerRepository).exists()) {
 | 
					 | 
				
			||||||
        Command c("git fetch");
 | 
					        Command c("git fetch");
 | 
				
			||||||
        if (c.execute(customerRepository)) {
 | 
					        if (c.execute(m_customerRepository)) {
 | 
				
			||||||
            QString const s = c.getCommandResult().trimmed();
 | 
					            QString const s = c.getCommandResult().trimmed();
 | 
				
			||||||
            if (!s.isEmpty()) {
 | 
					            if (!s.isEmpty()) {
 | 
				
			||||||
                QStringList lines = Update::split(s, '\n');
 | 
					                QStringList lines = Update::split(s, '\n');
 | 
				
			||||||
@@ -220,7 +204,7 @@ std::optional<QString> GitClient::gitFetch() {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        qCritical() << "ERROR" << customerRepository << "DOES NOT EXIST";
 | 
					        qCritical() << "ERROR" << m_customerRepository << "DOES NOT EXIST";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return std::nullopt;
 | 
					    return std::nullopt;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user