Skip to content

Commit

Permalink
Merge pull request #45 from PlasticSCM/1001312-implement-provider-use…
Browse files Browse the repository at this point in the history
…slocalreadonlystate

Implement UsesLocalReadOnlyState() based on Plastic SCM config value for SetFilesAsReadOnly
  • Loading branch information
juliomaqueda authored Oct 25, 2022
2 parents 35bfb71 + f2249a0 commit e6cb421
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ void FPlasticSourceControlProvider::CheckPlasticAvailability()
return;
}

bUsesLocalReadOnlyState = PlasticSourceControlUtils::GetConfigSetFilesAsReadOnly();

// Get user name (from the global Plastic SCM client config)
PlasticSourceControlUtils::GetUserName(UserName);

Expand Down Expand Up @@ -415,7 +417,7 @@ void FPlasticSourceControlProvider::CancelOperation(const FSourceControlOperatio

bool FPlasticSourceControlProvider::UsesLocalReadOnlyState() const
{
return false; // TODO: use configuration
return bUsesLocalReadOnlyState;
}

bool FPlasticSourceControlProvider::UsesChangelists() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ class FPlasticSourceControlProvider : public ISourceControlProvider
/** Indicates if source control integration is available or not. */
bool bServerAvailable = false;

/** Whether Plastic SCM is configure to uses local read-only state to signal whether a file is editable. */
bool bUsesLocalReadOnlyState = false;

/** Critical section for thread safety of error messages that occurred after last Plastic command */
mutable FCriticalSection LastErrorsCriticalSection;

Expand Down
17 changes: 17 additions & 0 deletions Source/PlasticSourceControl/Private/PlasticSourceControlUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@ bool GetPlasticScmVersion(FSoftwareVersion& OutPlasticScmVersion)
return false;
}

bool GetConfigSetFilesAsReadOnly()
{
TArray<FString> InfoMessages;
TArray<FString> ErrorMessages;
TArray<FString> Parameters;
Parameters.Add(TEXT("setfileasreadonly"));
const bool bResult = RunCommand(TEXT("getconfig"), Parameters, TArray<FString>(), EConcurrency::Synchronous, InfoMessages, ErrorMessages);
if (bResult && InfoMessages.Num() > 0)
{
if ((InfoMessages[0].Compare("yes", ESearchCase::IgnoreCase) == 0) || (InfoMessages[0].Compare("true", ESearchCase::IgnoreCase) == 0))
{
return true;
}
}
return false;
}

void GetUserName(FString& OutUserName)
{
TArray<FString> InfoMessages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ bool GetWorkspacePath(const FString& InPathToGameDir, FString& OutWorkspaceRoot)
*/
bool GetPlasticScmVersion(FSoftwareVersion& OutPlasticScmVersion);

/**
* Get Plastic SCM config value for SetFilesAsReadOnly
* @returns true if configure to use read-only flags on file that are not checked-out ("protected").
*/
bool GetConfigSetFilesAsReadOnly();

/**
* Get Plastic SCM current user
* @param OutUserName Name of the Plastic SCM user configured globally
Expand Down

0 comments on commit e6cb421

Please sign in to comment.