From 80a71ecea890edd935b8211e1f1f84bc7de4978c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rombauts?= Date: Wed, 10 Jan 2024 18:49:06 +0100 Subject: [PATCH] Add support for UE5.3 --- .../Private/GitSourceControlOperations.cpp | 4 ++++ .../Private/GitSourceControlProvider.cpp | 22 +++++++++++++++++++ .../Private/GitSourceControlProvider.h | 4 ++++ .../Private/GitSourceControlState.cpp | 11 ++++++++++ .../Private/GitSourceControlState.h | 9 ++++++++ .../Private/GitSourceControlUtils.cpp | 7 ++++++ 6 files changed, 57 insertions(+) diff --git a/Source/GitSourceControl/Private/GitSourceControlOperations.cpp b/Source/GitSourceControl/Private/GitSourceControlOperations.cpp index 5990804..e309e52 100644 --- a/Source/GitSourceControl/Private/GitSourceControlOperations.cpp +++ b/Source/GitSourceControl/Private/GitSourceControlOperations.cpp @@ -221,7 +221,11 @@ bool FGitCheckInWorker::Execute(FGitSourceControlCommand& InCommand) " git pull --rebase --autostash\n\n" "Or run the equivalent in a Git GUI client of your choice")); FText PushFailTitle(LOCTEXT("GitPush_OutOfDate_Title", "Git Pull Required")); +#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MAJOR_VERSION >= 3 + FMessageDialog::Open(EAppMsgType::Ok, PushFailMessage, PushFailTitle); +#else FMessageDialog::Open(EAppMsgType::Ok, PushFailMessage, &PushFailTitle); +#endif UE_LOG(LogSourceControl, Log, TEXT("Push failed because we're out of date, prompting user to resolve manually")); } } diff --git a/Source/GitSourceControl/Private/GitSourceControlProvider.cpp b/Source/GitSourceControl/Private/GitSourceControlProvider.cpp index 4f72170..2ff4de7 100644 --- a/Source/GitSourceControl/Private/GitSourceControlProvider.cpp +++ b/Source/GitSourceControl/Private/GitSourceControlProvider.cpp @@ -152,6 +152,23 @@ FText FGitSourceControlProvider::GetStatusText() const return FText::Format(NSLOCTEXT("Status", "Provider: Git\nEnabledLabel", "Local repository: {RepositoryName}\nRemote origin: {RemoteUrl}\nUser: {UserName}\nE-mail: {UserEmail}\n[{BranchName} {CommitId}] {CommitSummary}"), Args); } +#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MAJOR_VERSION >= 3 + +TMap FGitSourceControlProvider::GetStatus() const +{ + TMap Result; + Result.Add(EStatus::Enabled, IsEnabled() ? TEXT("Yes") : TEXT("No") ); + Result.Add(EStatus::Connected, (IsEnabled() && IsAvailable()) ? TEXT("Yes") : TEXT("No") ); + Result.Add(EStatus::User, UserName); + Result.Add(EStatus::Repository, PathToRepositoryRoot); + Result.Add(EStatus::Remote, RemoteUrl); + Result.Add(EStatus::Branch, BranchName); + Result.Add(EStatus::Email, UserEmail); + return Result; +} + +#endif + /** Quick check if source control is enabled */ bool FGitSourceControlProvider::IsEnabled() const { @@ -289,6 +306,11 @@ ECommandResult::Type FGitSourceControlProvider::Execute(const TSharedRefGetName()) != nullptr; +} + bool FGitSourceControlProvider::CanCancelOperation(const FSourceControlOperationRef& InOperation) const { return false; diff --git a/Source/GitSourceControl/Private/GitSourceControlProvider.h b/Source/GitSourceControl/Private/GitSourceControlProvider.h index 63954ea..c17621b 100644 --- a/Source/GitSourceControl/Private/GitSourceControlProvider.h +++ b/Source/GitSourceControl/Private/GitSourceControlProvider.h @@ -62,6 +62,9 @@ class FGitSourceControlProvider : public ISourceControlProvider virtual void Init(bool bForceConnection = true) override; virtual void Close() override; virtual FText GetStatusText() const override; +#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MAJOR_VERSION >= 3 + virtual TMap GetStatus() const override; +#endif virtual bool IsEnabled() const override; virtual bool IsAvailable() const override; virtual const FName& GetName(void) const override; @@ -80,6 +83,7 @@ class FGitSourceControlProvider : public ISourceControlProvider #else virtual ECommandResult::Type Execute(const FSourceControlOperationRef& InOperation, const TArray& InFiles, EConcurrency::Type InConcurrency = EConcurrency::Synchronous, const FSourceControlOperationComplete& InOperationCompleteDelegate = FSourceControlOperationComplete() ) override; #endif + virtual bool CanExecuteOperation( const FSourceControlOperationRef& InOperation ) const; /* override NOTE: added in UE5.3 */ virtual bool CanCancelOperation(const FSourceControlOperationRef& InOperation) const override; virtual void CancelOperation(const FSourceControlOperationRef& InOperation) override; virtual bool UsesLocalReadOnlyState() const override; diff --git a/Source/GitSourceControl/Private/GitSourceControlState.cpp b/Source/GitSourceControl/Private/GitSourceControlState.cpp index 55fe510..07c7e6c 100644 --- a/Source/GitSourceControl/Private/GitSourceControlState.cpp +++ b/Source/GitSourceControl/Private/GitSourceControlState.cpp @@ -47,6 +47,15 @@ TSharedPtr FGitSourceControlS return nullptr; } +#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MAJOR_VERSION >= 3 + +ISourceControlState::FResolveInfo FGitSourceControlState::GetResolveInfo() const +{ + return PendingResolveInfo; +} + +#else + TSharedPtr FGitSourceControlState::GetBaseRevForMerge() const { for (const auto& Revision : History) @@ -61,6 +70,8 @@ TSharedPtr FGitSourceControlS return nullptr; } +#endif + #if ENGINE_MAJOR_VERSION == 5 FSlateIcon FGitSourceControlState::GetIcon() const diff --git a/Source/GitSourceControl/Private/GitSourceControlState.h b/Source/GitSourceControl/Private/GitSourceControlState.h index 1115b93..500b945 100644 --- a/Source/GitSourceControl/Private/GitSourceControlState.h +++ b/Source/GitSourceControl/Private/GitSourceControlState.h @@ -60,7 +60,11 @@ class FGitSourceControlState : public ISourceControlState virtual TSharedPtr GetHistoryItem(int32 HistoryIndex) const override; virtual TSharedPtr FindHistoryRevision(int32 RevisionNumber) const override; virtual TSharedPtr FindHistoryRevision(const FString& InRevision) const override; +#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MAJOR_VERSION >= 3 + virtual FResolveInfo GetResolveInfo() const override; +#else virtual TSharedPtr GetBaseRevForMerge() const override; +#endif virtual TSharedPtr GetCurrentRevision() const; /* override NOTE: added in UE5.2 */ #if ENGINE_MAJOR_VERSION == 5 virtual FSlateIcon GetIcon() const override; @@ -102,8 +106,13 @@ class FGitSourceControlState : public ISourceControlState /** Filename on disk */ FString LocalFilename; +#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MAJOR_VERSION >= 3 + /** Pending rev info with which a file must be resolved, invalid if no resolve pending */ + FResolveInfo PendingResolveInfo; +#else /** File Id with which our local revision diverged from the remote revision */ FString PendingMergeBaseFileHash; +#endif /** State of the working copy */ EWorkingCopyState::Type WorkingCopyState; diff --git a/Source/GitSourceControl/Private/GitSourceControlUtils.cpp b/Source/GitSourceControl/Private/GitSourceControlUtils.cpp index 6bd7fe8..0d52719 100644 --- a/Source/GitSourceControl/Private/GitSourceControlUtils.cpp +++ b/Source/GitSourceControl/Private/GitSourceControlUtils.cpp @@ -823,7 +823,14 @@ static void RunGetConflictStatus(const FString& InPathToGitBinary, const FString { // Parse the unmerge status: extract the base revision (or the other branch?) FGitConflictStatusParser ConflictStatus(Results); +#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MAJOR_VERSION >= 3 + InOutFileState.PendingResolveInfo.BaseFile = ConflictStatus.CommonAncestorFilename; + InOutFileState.PendingResolveInfo.BaseRevision = ConflictStatus.CommonAncestorFileId; + InOutFileState.PendingResolveInfo.RemoteFile = ConflictStatus.RemoteFilename; + InOutFileState.PendingResolveInfo.RemoteRevision = ConflictStatus.RemoteFileId; +#else InOutFileState.PendingMergeBaseFileHash = ConflictStatus.CommonAncestorFileId; +#endif } }