forked from qt-creator/qt-creator
Git: Add a static method to attach a GitProgressParser to a VcsCommand
Change-Id: Ia7e104665360a254d5f3867b69e11fb7c46ff93e Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -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
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user