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

Only show meaningful changes in other branches #197

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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
33 changes: 28 additions & 5 deletions Source/GitSourceControl/Private/GitSourceControlUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1446,9 +1446,13 @@ void CheckRemote(const FString& InPathToGitBinary, const FString& InRepositoryRo

TArray<FString> ErrorMessages;

TArray<FString> Results;
TArray<FString> LogResults;
TArray<FString> DiffResults;
TArray<FString> Intersection;

TMap<FString, FString> NewerFiles;


//const TArray<FString>& RelativeFiles = RelativeFilenames(Files, InRepositoryRoot);
// Get the full remote status of the Content folder, since it's the only lockable folder we track in editor.
// This shows any new files as well.
Expand All @@ -1470,10 +1474,27 @@ void CheckRemote(const FString& InPathToGitBinary, const FString& InRepositoryRo
// .. means commits in the right that are not in the left
ParametersLog[2] = FString::Printf(TEXT("..%s"), *Branch);

const bool bResultDiff = RunCommand(TEXT("log"), InPathToGitBinary, InRepositoryRoot, ParametersLog, FilesToDiff, Results, ErrorMessages);
if (bResultDiff)
const bool bResultLog = RunCommand(TEXT("log"), InPathToGitBinary, InRepositoryRoot, ParametersLog, FilesToDiff, LogResults, ErrorMessages);
if (bResultLog)
{
for (const FString& NewerFileName : Results)
// Status Branches may not be initialized because they're not in use by the project. They can also be not initilaized in some other quirky circumstances
// eg. When running multi client / dedicated server in editor without running them under the same process, those game instances will run as an editor instance
// which means editor plugins are enabled and running, but they don't run UnrealEdEngine, so the status branches are not initialized.
if (StatusBranches.Num() > 0)
{
// Check if the files state in the branch in which is changed is actually different from status branch
// This opens files for edit if they were modified in another branch but have since been reverted back to state in status.
TArray<FString> DiffParametersLog{ TEXT("--pretty="), TEXT("--name-only"), FString::Printf(TEXT("%s..%s"), *StatusBranches[0], *Branch), TEXT(""), TEXT("--") };
const bool bResultDiff = RunCommand(TEXT("diff"), InPathToGitBinary, InRepositoryRoot, DiffParametersLog, FilesToDiff, DiffResults, ErrorMessages);
// Get the intersection of the 2 containers
Intersection = DiffResults.FilterByPredicate([&LogResults](const FString& ChangedFile) { return LogResults.Contains(ChangedFile); });
}
else
{
Intersection = LogResults;
}

for (const FString& NewerFileName : Intersection)
{
// Don't care about mergeable files (.collection, .ini, .uproject, etc)
if (!IsFileLFSLockable(NewerFileName))
Expand All @@ -1493,7 +1514,9 @@ void CheckRemote(const FString& InPathToGitBinary, const FString& InRepositoryRo
}
}
}
Results.Reset();
LogResults.Reset();
DiffResults.Reset();
Intersection.Reset();
}

for (const auto& NewFile : NewerFiles)
Expand Down