Use defined codes and strings.
This commit is contained in:
		@@ -50,12 +50,17 @@ GitCommand::GitCommand()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool GitCommand::exec(QStringList const &options, int start_timeout, int finish_timeout) {
 | 
			
		||||
    bool ret = false;
 | 
			
		||||
    if (GitCommand::initEnv) {
 | 
			
		||||
        Command cmd(QString("git"), options, m_workingDirectory,
 | 
			
		||||
                    start_timeout, finish_timeout);
 | 
			
		||||
        return cmd.exec();
 | 
			
		||||
        ret = cmd.exec();
 | 
			
		||||
        //qCritical() << __func__ << ":" << __LINE__ << cmd.command()
 | 
			
		||||
        //            << "," << cmd.args()
 | 
			
		||||
        //            << ", result" << cmd.commandResult();
 | 
			
		||||
        m_commandResult = cmd.commandResult();
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool GitCommand::check(int start_timeout, int finish_timeout) {
 | 
			
		||||
 
 | 
			
		||||
@@ -11,9 +11,14 @@ class GitCommand {
 | 
			
		||||
 | 
			
		||||
    bool exec(QStringList const &options, int start_timeout = 100000,
 | 
			
		||||
              int finish_timeout = 100000);
 | 
			
		||||
 | 
			
		||||
    QString m_commandResult{};
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    GitCommand();
 | 
			
		||||
 | 
			
		||||
    void resetCommandResult() { m_commandResult.clear(); }
 | 
			
		||||
    QString const &commandResult() const { return m_commandResult; }
 | 
			
		||||
 | 
			
		||||
    bool status(int start_timeout = 100000, int finish_timeout = 100000);
 | 
			
		||||
    bool check(int start_timeout = 100000, int finish_timeout = 100000);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										14
									
								
								Git/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								Git/main.cpp
									
									
									
									
									
								
							@@ -15,6 +15,7 @@
 | 
			
		||||
#include <QRegularExpression>
 | 
			
		||||
#include <QFile>
 | 
			
		||||
#include <QTextStream>
 | 
			
		||||
#include <QRegularExpression>
 | 
			
		||||
 | 
			
		||||
#include <optional>
 | 
			
		||||
 | 
			
		||||
@@ -90,6 +91,19 @@ int main(int argc, char **argv) {
 | 
			
		||||
            if (!gitCmd.pull()) {
 | 
			
		||||
                return -4;
 | 
			
		||||
            }
 | 
			
		||||
            QString const result = gitCmd.commandResult().trimmed();
 | 
			
		||||
            if (result.contains("Already", Qt::CaseInsensitive)
 | 
			
		||||
             && result.contains("up", Qt::CaseInsensitive)
 | 
			
		||||
             && result.contains("to", Qt::CaseInsensitive)
 | 
			
		||||
             && result.contains("date", Qt::CaseInsensitive)) {
 | 
			
		||||
                qCritical() << internal::GIT_CUSTOMER_REPO_NO_UPDATE_NECESSARY;
 | 
			
		||||
                return internal::GIT_NOT_NECESSARY_CODE;
 | 
			
		||||
            } else
 | 
			
		||||
            if (result.contains(QRegularExpression("[Uu]pdating\\s+[a-z0-9]{6,}\\.\\.[a-z0-9]{6,}"))) {
 | 
			
		||||
                // Updating 49a97f5..13a0321
 | 
			
		||||
                qCritical() << internal::GIT_CUSTOMER_REPO_UPDATED;
 | 
			
		||||
                return internal::GIT_UPDATED_CODE;
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            if (!gitCmd.clone()) {
 | 
			
		||||
                return -3;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user