Skip to content

Commit

Permalink
Add support for UE5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
SRombauts committed Jan 10, 2024
1 parent e82226b commit a1df476
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}
Expand Down
22 changes: 22 additions & 0 deletions Source/GitSourceControl/Private/GitSourceControlProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ISourceControlProvider::EStatus, FString> FGitSourceControlProvider::GetStatus() const
{
TMap<EStatus, FString> 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
{
Expand Down Expand Up @@ -289,6 +306,11 @@ ECommandResult::Type FGitSourceControlProvider::Execute(const TSharedRef<ISource
}
}

bool FGitSourceControlProvider::CanExecuteOperation( const FSourceControlOperationRef& InOperation ) const
{
return WorkersMap.Find(InOperation->GetName()) != nullptr;
}

bool FGitSourceControlProvider::CanCancelOperation(const FSourceControlOperationRef& InOperation) const
{
return false;
Expand Down
4 changes: 4 additions & 0 deletions Source/GitSourceControl/Private/GitSourceControlProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<EStatus, FString> GetStatus() const override;
#endif
virtual bool IsEnabled() const override;
virtual bool IsAvailable() const override;
virtual const FName& GetName(void) const override;
Expand All @@ -80,6 +83,7 @@ class FGitSourceControlProvider : public ISourceControlProvider
#else
virtual ECommandResult::Type Execute(const FSourceControlOperationRef& InOperation, const TArray<FString>& 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;
Expand Down
11 changes: 11 additions & 0 deletions Source/GitSourceControl/Private/GitSourceControlState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ TSharedPtr<class ISourceControlRevision, ESPMode::ThreadSafe> FGitSourceControlS
return nullptr;
}

#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MAJOR_VERSION >= 3

ISourceControlState::FResolveInfo FGitSourceControlState::GetResolveInfo() const
{
return PendingResolveInfo;
}

#else

TSharedPtr<class ISourceControlRevision, ESPMode::ThreadSafe> FGitSourceControlState::GetBaseRevForMerge() const
{
for (const auto& Revision : History)
Expand All @@ -61,6 +70,8 @@ TSharedPtr<class ISourceControlRevision, ESPMode::ThreadSafe> FGitSourceControlS
return nullptr;
}

#endif

#if ENGINE_MAJOR_VERSION == 5

FSlateIcon FGitSourceControlState::GetIcon() const
Expand Down
9 changes: 9 additions & 0 deletions Source/GitSourceControl/Private/GitSourceControlState.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ class FGitSourceControlState : public ISourceControlState
virtual TSharedPtr<class ISourceControlRevision, ESPMode::ThreadSafe> GetHistoryItem(int32 HistoryIndex) const override;
virtual TSharedPtr<class ISourceControlRevision, ESPMode::ThreadSafe> FindHistoryRevision(int32 RevisionNumber) const override;
virtual TSharedPtr<class ISourceControlRevision, ESPMode::ThreadSafe> FindHistoryRevision(const FString& InRevision) const override;
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MAJOR_VERSION >= 3
virtual FResolveInfo GetResolveInfo() const override;
#else
virtual TSharedPtr<class ISourceControlRevision, ESPMode::ThreadSafe> GetBaseRevForMerge() const override;
#endif
virtual TSharedPtr<class ISourceControlRevision, ESPMode::ThreadSafe> GetCurrentRevision() const; /* override NOTE: added in UE5.2 */
#if ENGINE_MAJOR_VERSION == 5
virtual FSlateIcon GetIcon() const override;
Expand Down Expand Up @@ -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;
Expand Down
26 changes: 26 additions & 0 deletions Source/GitSourceControl/Private/GitSourceControlUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,11 +802,30 @@ class FGitConflictStatusParser
/** Parse the unmerge status: extract the base SHA1 identifier of the file */
FGitConflictStatusParser(const TArray<FString>& InResults)
{
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MAJOR_VERSION >= 3
const FString& CommonAncestor = InResults[0]; // 1: The common ancestor of merged branches
CommonAncestorFileId = CommonAncestor.Mid(7, 40);
CommonAncestorFilename = CommonAncestor.Right(50);

if (ensure(InResults.IsValidIndex(2)))
{
const FString& RemoteBranch = InResults[2]; // 1: The common ancestor of merged branches
RemoteFileId = RemoteBranch.Mid(7, 40);
RemoteFilename = RemoteBranch.Right(50);
}
#else
const FString& FirstResult = InResults[0]; // 1: The common ancestor of merged branches
CommonAncestorFileId = FirstResult.Mid(7, 40);
#endif
}

FString CommonAncestorFileId; ///< SHA1 Id of the file (warning: not the commit Id)
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MAJOR_VERSION >= 3
FString RemoteFileId; ///< SHA1 Id of the file (warning: not the commit Id)

FString CommonAncestorFilename;
FString RemoteFilename;
#endif
};

/** Execute a command to get the details of a conflict */
Expand All @@ -823,7 +842,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
}
}

Expand Down

0 comments on commit a1df476

Please sign in to comment.