This repository has been archived on 2021-12-21. You can view files and clone it, but cannot push or open issues or pull requests.
Bookworm/Plugins/UE4GitPlugin-2.17-beta/Source/GitSourceControl/Private/GitSourceControlCommand.cpp

66 lines
2.2 KiB
C++
Raw Normal View History

2021-11-17 11:35:23 +00:00
// Copyright (c) 2014-2020 Sebastien Rombauts (sebastien.rombauts@gmail.com)
//
// Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
// or copy at http://opensource.org/licenses/MIT)
#include "GitSourceControlCommand.h"
#include "Modules/ModuleManager.h"
#include "GitSourceControlModule.h"
FGitSourceControlCommand::FGitSourceControlCommand(const TSharedRef<class ISourceControlOperation, ESPMode::ThreadSafe>& InOperation, const TSharedRef<class IGitSourceControlWorker, ESPMode::ThreadSafe>& InWorker, const FSourceControlOperationComplete& InOperationCompleteDelegate)
: Operation(InOperation)
, Worker(InWorker)
, OperationCompleteDelegate(InOperationCompleteDelegate)
, bExecuteProcessed(0)
, bCommandSuccessful(false)
, bConnectionDropped(false)
, bAutoDelete(true)
, Concurrency(EConcurrency::Synchronous)
{
// grab the providers settings here, so we don't access them once the worker thread is launched
check(IsInGameThread());
const FGitSourceControlModule& GitSourceControl = FModuleManager::GetModuleChecked<FGitSourceControlModule>( "GitSourceControl" );
PathToGitBinary = GitSourceControl.AccessSettings().GetBinaryPath();
bUsingGitLfsLocking = GitSourceControl.AccessSettings().IsUsingGitLfsLocking();
PathToRepositoryRoot = GitSourceControl.GetProvider().GetPathToRepositoryRoot();
}
bool FGitSourceControlCommand::DoWork()
{
bCommandSuccessful = Worker->Execute(*this);
FPlatformAtomics::InterlockedExchange(&bExecuteProcessed, 1);
return bCommandSuccessful;
}
void FGitSourceControlCommand::Abandon()
{
FPlatformAtomics::InterlockedExchange(&bExecuteProcessed, 1);
}
void FGitSourceControlCommand::DoThreadedWork()
{
Concurrency = EConcurrency::Asynchronous;
DoWork();
}
ECommandResult::Type FGitSourceControlCommand::ReturnResults()
{
// Save any messages that have accumulated
for (FString& String : InfoMessages)
{
Operation->AddInfoMessge(FText::FromString(String));
}
for (FString& String : ErrorMessages)
{
Operation->AddErrorMessge(FText::FromString(String));
}
// run the completion delegate if we have one bound
ECommandResult::Type Result = bCommandSuccessful ? ECommandResult::Succeeded : ECommandResult::Failed;
OperationCompleteDelegate.ExecuteIfBound(Operation, Result);
return Result;
}