forked from qt-creator/qt-creator
Git: Add CommandHandler into vcsExecAbortable
Don't return VcsCommand anymore. Change-Id: I895951e8bd8d380d7b946380628e41b928c9b743 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -3110,11 +3110,11 @@ void GitClient::pull(const FilePath &workingDirectory, bool rebase)
|
|||||||
abortCommand = "merge";
|
abortCommand = "merge";
|
||||||
}
|
}
|
||||||
|
|
||||||
VcsCommand *command = vcsExecAbortable(workingDirectory, arguments, rebase, abortCommand);
|
const auto commandHandler = [this, workingDirectory](const CommandResult &result) {
|
||||||
connect(command, &VcsCommand::done, this, [this, workingDirectory, command] {
|
if (result.result() == ProcessResult::FinishedWithSuccess)
|
||||||
if (command->result() == ProcessResult::FinishedWithSuccess)
|
|
||||||
updateSubmodulesIfNeeded(workingDirectory, true);
|
updateSubmodulesIfNeeded(workingDirectory, true);
|
||||||
});
|
};
|
||||||
|
vcsExecAbortable(workingDirectory, arguments, rebase, abortCommand, this, commandHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitClient::synchronousAbortCommand(const FilePath &workingDir, const QString &abortCommand)
|
void GitClient::synchronousAbortCommand(const FilePath &workingDir, const QString &abortCommand)
|
||||||
@@ -3363,26 +3363,27 @@ void GitClient::revert(const FilePath &workingDirectory, const QString &argument
|
|||||||
|
|
||||||
// Executes a command asynchronously. Work tree is expected to be clean.
|
// Executes a command asynchronously. Work tree is expected to be clean.
|
||||||
// Stashing is handled prior to this call.
|
// Stashing is handled prior to this call.
|
||||||
VcsCommand *GitClient::vcsExecAbortable(const FilePath &workingDirectory,
|
void GitClient::vcsExecAbortable(const FilePath &workingDirectory, const QStringList &arguments,
|
||||||
const QStringList &arguments,
|
bool isRebase, const QString &abortCommand,
|
||||||
bool isRebase,
|
const QObject *context, const CommandHandler &handler)
|
||||||
QString abortCommand)
|
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!arguments.isEmpty(), return nullptr);
|
QTC_ASSERT(!arguments.isEmpty(), return);
|
||||||
|
const QString abortString = abortCommand.isEmpty() ? arguments.at(0) : abortCommand;
|
||||||
if (abortCommand.isEmpty())
|
|
||||||
abortCommand = arguments.at(0);
|
|
||||||
VcsCommand *command = createCommand(workingDirectory);
|
VcsCommand *command = createCommand(workingDirectory);
|
||||||
command->addFlags(RunFlags::ShowStdOut | RunFlags::ShowSuccessMessage);
|
command->addFlags(RunFlags::ShowStdOut | RunFlags::ShowSuccessMessage);
|
||||||
// For rebase, Git might request an editor (which means the process keeps running until the
|
// For rebase, Git might request an editor (which means the process keeps running until the
|
||||||
// user closes it), so run without timeout.
|
// user closes it), so run without timeout.
|
||||||
command->addJob({vcsBinary(), arguments}, isRebase ? 0 : vcsTimeoutS());
|
command->addJob({vcsBinary(), arguments}, isRebase ? 0 : vcsTimeoutS());
|
||||||
ConflictHandler::attachToCommand(command, workingDirectory, abortCommand);
|
ConflictHandler::attachToCommand(command, workingDirectory, abortString);
|
||||||
|
if (handler) {
|
||||||
|
const QObject *actualContext = context ? context : this;
|
||||||
|
connect(command, &VcsCommand::done, actualContext, [command, handler] {
|
||||||
|
handler(CommandResult(*command));
|
||||||
|
});
|
||||||
|
}
|
||||||
if (isRebase)
|
if (isRebase)
|
||||||
command->setProgressParser(GitProgressParser());
|
command->setProgressParser(GitProgressParser());
|
||||||
command->start();
|
command->start();
|
||||||
// TODO: Don't return command, take handler arg
|
|
||||||
return command;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitClient::synchronousRevert(const FilePath &workingDirectory, const QString &commit)
|
bool GitClient::synchronousRevert(const FilePath &workingDirectory, const QString &commit)
|
||||||
|
|||||||
@@ -121,10 +121,10 @@ public:
|
|||||||
Utils::FilePath vcsBinary() const override;
|
Utils::FilePath vcsBinary() const override;
|
||||||
QFuture<unsigned> gitVersion() const;
|
QFuture<unsigned> gitVersion() const;
|
||||||
|
|
||||||
VcsBase::VcsCommand *vcsExecAbortable(const Utils::FilePath &workingDirectory,
|
void vcsExecAbortable(const Utils::FilePath &workingDirectory, const QStringList &arguments,
|
||||||
const QStringList &arguments,
|
bool isRebase = false, const QString &abortCommand = {},
|
||||||
bool isRebase = false,
|
const QObject *context = nullptr,
|
||||||
QString abortCommand = {});
|
const VcsBase::CommandHandler &handler = {});
|
||||||
|
|
||||||
Utils::FilePath findRepositoryForDirectory(const Utils::FilePath &directory) const;
|
Utils::FilePath findRepositoryForDirectory(const Utils::FilePath &directory) const;
|
||||||
QString findGitDirForRepository(const Utils::FilePath &repositoryDir) const;
|
QString findGitDirForRepository(const Utils::FilePath &repositoryDir) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user