Skip to content

Commit

Permalink
Fix ParseWorkspaceInfo() to also handle the case where the workspace …
Browse files Browse the repository at this point in the history
…has been switched to a Changeset instead of a Branch
  • Loading branch information
SRombauts committed Apr 13, 2023
1 parent 28ad44b commit 7141f0a
Showing 1 changed file with 36 additions and 18 deletions.
54 changes: 36 additions & 18 deletions Source/PlasticSourceControl/Private/PlasticSourceControlUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ bool GetWorkspaceInformation(int32& OutChangeset, FString& OutRepositoryName, FS
return bResult;
}

static bool ParseWorkspaceInfo(const TArray<FString>& InResults, FString& OutBranchName, FString& OutRepositoryName, FString& OutServerUrl)
static bool ParseWorkspaceInfo(TArray<FString>& InResults, FString& OutBranchName, FString& OutRepositoryName, FString& OutServerUrl)
{
if (InResults.Num() == 0)
{
Expand All @@ -227,34 +227,52 @@ static bool ParseWorkspaceInfo(const TArray<FString>& InResults, FString& OutBra
// Get workspace information, in the form "Branch /main@UE5PlasticPluginDev@localhost:8087"
// or "Branch /main@UE5PlasticPluginDev@test@cloud" (when connected directly to the cloud)
// or "Branch /main@rep:UE5OpenWorldPerfTest@repserver:test@cloud"
// or "Changeset 1234@UE5PlasticPluginDev@test@cloud" (when the workspace is switched on a changeset instead of a branch)
static const FString BranchPrefix(TEXT("Branch "));
if (!InResults[0].StartsWith(BranchPrefix, ESearchCase::CaseSensitive))
static const FString ChangesetPrefix(TEXT("Changeset "));
static const FString RepPrefix(TEXT("rep:"));
static const FString RepserverPrefix(TEXT("repserver:"));
FString& WorkspaceInfo = InResults[0];
if (WorkspaceInfo.StartsWith(BranchPrefix, ESearchCase::CaseSensitive))
{
return false;
WorkspaceInfo.RightChopInline(BranchPrefix.Len());
}
FString Temp = InResults[0].RightChop(BranchPrefix.Len());
int32 SeparatorIndex;
if (!Temp.FindChar(TEXT('@'), SeparatorIndex))
else if (WorkspaceInfo.StartsWith(ChangesetPrefix, ESearchCase::CaseSensitive))
{
return false;
WorkspaceInfo.RightChopInline(ChangesetPrefix.Len());
}
OutBranchName = Temp.Left(SeparatorIndex);
Temp.RightChopInline(SeparatorIndex + 1);
if (!Temp.FindChar(TEXT('@'), SeparatorIndex))
else
{
return false;
}
OutRepositoryName = Temp.Left(SeparatorIndex);
static const FString RepPrefix(TEXT("rep:"));
if (OutRepositoryName.StartsWith(RepPrefix, ESearchCase::CaseSensitive))

TArray<FString> WorkspaceInfos;
WorkspaceInfo.ParseIntoArray(WorkspaceInfos, TEXT("@"), false); // Don't cull empty values
if (WorkspaceInfos.Num() >= 3)
{
OutRepositoryName.RightChopInline(RepPrefix.Len());
OutBranchName = MoveTemp(WorkspaceInfos[0]);
OutRepositoryName = MoveTemp(WorkspaceInfos[1]);
OutServerUrl = MoveTemp(WorkspaceInfos[2]);

if (OutRepositoryName.StartsWith(RepPrefix, ESearchCase::CaseSensitive))
{
OutRepositoryName.RightChopInline(RepPrefix.Len());
}

if (OutServerUrl.StartsWith(RepserverPrefix, ESearchCase::CaseSensitive))
{
OutServerUrl.RightChopInline(RepserverPrefix.Len());
}

if (WorkspaceInfos.Num() >= 3)
{
OutServerUrl.Append(TEXT("@"));
OutServerUrl.Append(MoveTemp(WorkspaceInfos[3]));
}
}
OutServerUrl = Temp.RightChop(SeparatorIndex + 1);
static const FString RepserverPrefix(TEXT("repserver:"));
if (OutServerUrl.StartsWith(RepserverPrefix, ESearchCase::CaseSensitive))
else
{
OutServerUrl.RightChopInline(RepserverPrefix.Len());
return false;
}

return true;
Expand Down

0 comments on commit 7141f0a

Please sign in to comment.