Commit d7ecf7df authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Git: Add a static method to attach a GitProgressParser to a VcsCommand



Change-Id: Ia7e104665360a254d5f3867b69e11fb7c46ff93e
Reviewed-by: default avatarOrgad Shaneh <orgads@gmail.com>
parent 9364f64f
...@@ -523,19 +523,21 @@ private: ...@@ -523,19 +523,21 @@ private:
class GitProgressParser : public ProgressParser class GitProgressParser : public ProgressParser
{ {
public: public:
GitProgressParser() : static void attachToCommand(VcsCommand *command)
m_progressExp(QLatin1String("\\((\\d+)/(\\d+)\\)")) // e.g. Rebasing (7/42)
{ {
command->setProgressParser(new GitProgressParser);
} }
protected: private:
GitProgressParser() : m_progressExp(QLatin1String("\\((\\d+)/(\\d+)\\)")) // e.g. Rebasing (7/42)
{ }
void parseProgress(const QString &text) override void parseProgress(const QString &text) override
{ {
if (m_progressExp.lastIndexIn(text) != -1) if (m_progressExp.lastIndexIn(text) != -1)
setProgressAndMaximum(m_progressExp.cap(1).toInt(), m_progressExp.cap(2).toInt()); setProgressAndMaximum(m_progressExp.cap(1).toInt(), m_progressExp.cap(2).toInt());
} }
private:
QRegExp m_progressExp; QRegExp m_progressExp;
}; };
...@@ -2973,7 +2975,7 @@ void GitClient::asyncCommand(const QString &workingDirectory, const QStringList ...@@ -2973,7 +2975,7 @@ void GitClient::asyncCommand(const QString &workingDirectory, const QStringList
VcsCommand *command = createCommand(workingDirectory, 0, VcsWindowOutputBind); VcsCommand *command = createCommand(workingDirectory, 0, VcsWindowOutputBind);
ConflictHandler::attachToCommand(command, gitCommand); ConflictHandler::attachToCommand(command, gitCommand);
if (hasProgress) if (hasProgress)
command->setProgressParser(new GitProgressParser); GitProgressParser::attachToCommand(command);
command->setCookie(workingDirectory); command->setCookie(workingDirectory);
enqueueJob(command, arguments); enqueueJob(command, arguments);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment