Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for check in a tree of multiple private files and folders from the View Changes window in version 1.10.0 #113

Merged
merged 2 commits into from
Apr 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 67 additions & 47 deletions Source/PlasticSourceControl/Private/PlasticSourceControlOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,67 +442,87 @@ bool FPlasticCheckInWorker::Execute(FPlasticSourceControlCommand& InCommand)

const TArray<FString> Files = GetFilesFromCommand(GetProvider(), InCommand);

if (Files.Num() > 0)
if (Files.Num() == 0)
{
#if ENGINE_MAJOR_VERSION == 5
if (InCommand.Changelist.IsInitialized())
UE_LOG(LogSourceControl, Warning, TEXT("Checkin: No files provided"));
return false;
}

// Add Private files to source control to be able to check them in
TArray<FString> FilesToAdd;
for (const FString& File : Files)
{
TSharedRef<FPlasticSourceControlState, ESPMode::ThreadSafe> State = GetProvider().GetStateInternal(File);
if (!State->IsSourceControlled())
{
TSharedRef<FPlasticSourceControlChangelistState, ESPMode::ThreadSafe> ChangelistState = GetProvider().GetStateInternal(InCommand.Changelist);
FilesToAdd.Add(File);
}
}
if (FilesToAdd.Num() > 0)
{
UE_LOG(LogSourceControl, Log, TEXT("CheckIn: Adding %d file(s) to source control"), FilesToAdd.Num());
if (!GetProvider().IsPartialWorkspace())
{
InCommand.bCommandSuccessful = PlasticSourceControlUtils::RunCommand(TEXT("add"), TArray<FString>(), FilesToAdd, InCommand.InfoMessages, InCommand.ErrorMessages);
}
else
{
InCommand.bCommandSuccessful = PlasticSourceControlUtils::RunCommand(TEXT("partial add"), TArray<FString>(), FilesToAdd, InCommand.InfoMessages, InCommand.ErrorMessages);
}
}

if (Description.IsEmpty())
{
Description = ChangelistState->GetDescriptionText();
}
#if ENGINE_MAJOR_VERSION == 5
if (InCommand.Changelist.IsInitialized())
{
TSharedRef<FPlasticSourceControlChangelistState, ESPMode::ThreadSafe> ChangelistState = GetProvider().GetStateInternal(InCommand.Changelist);

InChangelist = InCommand.Changelist;
if (Description.IsEmpty())
{
Description = ChangelistState->GetDescriptionText();
}

InChangelist = InCommand.Changelist;
}
#endif

UE_LOG(LogSourceControl, Verbose, TEXT("CheckIn: %d file(s) Description: '%s'"), Files.Num(), *Description.ToString());
UE_LOG(LogSourceControl, Verbose, TEXT("CheckIn: %d file(s) Description: '%s'"), Files.Num(), *Description.ToString());

// make a temp file to place our commit message in
const FScopedTempFile CommitMsgFile(Description);
if (!CommitMsgFile.GetFilename().IsEmpty())
// make a temp file to place our commit message in
const FScopedTempFile CommitMsgFile(Description);
if (!CommitMsgFile.GetFilename().IsEmpty())
{
TArray<FString> Parameters;
Parameters.Add(FString::Printf(TEXT("--commentsfile=\"%s\""), *CommitMsgFile.GetFilename()));
Parameters.Add(TEXT("--all")); // Also files Changed (not CheckedOut) and Moved/Deleted Locally
if (!GetProvider().IsPartialWorkspace())
{
TArray<FString> Parameters;
Parameters.Add(FString::Printf(TEXT("--commentsfile=\"%s\""), *CommitMsgFile.GetFilename()));
Parameters.Add(TEXT("--all")); // Also files Changed (not CheckedOut) and Moved/Deleted Locally
Parameters.Add(TEXT("--private")); // Also Private files (not in source control)
Parameters.Add(TEXT("--dependencies")); // Include all the dependent items automatically.
if (!GetProvider().IsPartialWorkspace())
{
// NOTE: --update added as #23 but removed as #32 because most assets are locked by the Unreal Editor
// Parameters.Add(TEXT("--update")); // Processes the update-merge automatically if it eventually happens.
InCommand.bCommandSuccessful = PlasticSourceControlUtils::RunCommand(TEXT("checkin"), Parameters, Files, InCommand.InfoMessages, InCommand.ErrorMessages);
}
else
{
InCommand.bCommandSuccessful = PlasticSourceControlUtils::RunCommand(TEXT("partial checkin"), Parameters, Files, InCommand.InfoMessages, InCommand.ErrorMessages);
}
if (InCommand.bCommandSuccessful)
{
Operation->SetSuccessMessage(PlasticSourceControlParsers::ParseCheckInResults(InCommand.InfoMessages));
UE_LOG(LogSourceControl, Log, TEXT("CheckIn successful"));
}
// NOTE: --update added as #23 but removed as #32 because most assets are locked by the Unreal Editor
// Parameters.Add(TEXT("--update")); // Processes the update-merge automatically if it eventually happens.
InCommand.bCommandSuccessful = PlasticSourceControlUtils::RunCommand(TEXT("checkin"), Parameters, Files, InCommand.InfoMessages, InCommand.ErrorMessages);
}
else
{
InCommand.bCommandSuccessful = PlasticSourceControlUtils::RunCommand(TEXT("partial checkin"), Parameters, Files, InCommand.InfoMessages, InCommand.ErrorMessages);
}
if (InCommand.bCommandSuccessful)
{
Operation->SetSuccessMessage(PlasticSourceControlParsers::ParseCheckInResults(InCommand.InfoMessages));
UE_LOG(LogSourceControl, Log, TEXT("CheckIn successful"));
}

#if ENGINE_MAJOR_VERSION == 5
if (InChangelist.IsInitialized() && !InChangelist.IsDefault())
{
// NOTE: we need to explicitly delete persistent changelists when we submit its content, except for the Default changelist
DeleteChangelist(GetProvider(), InChangelist, InCommand.InfoMessages, InCommand.ErrorMessages);
}
#endif
if (InChangelist.IsInitialized() && !InChangelist.IsDefault())
{
// NOTE: we need to explicitly delete persistent changelists when we submit its content, except for the Default changelist
DeleteChangelist(GetProvider(), InChangelist, InCommand.InfoMessages, InCommand.ErrorMessages);
}

// now update the status of our files
PlasticSourceControlUtils::InvalidateLocksCache();
PlasticSourceControlUtils::RunUpdateStatus(Files, PlasticSourceControlUtils::EStatusSearchType::ControlledOnly, false, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);
}
else
{
UE_LOG(LogSourceControl, Warning, TEXT("Checkin: No files provided"));
#endif
}

// now update the status of our files
PlasticSourceControlUtils::InvalidateLocksCache();
PlasticSourceControlUtils::RunUpdateStatus(Files, PlasticSourceControlUtils::EStatusSearchType::ControlledOnly, false, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);

return InCommand.bCommandSuccessful;
}

Expand Down