Skip to content

Commit

Permalink
fix #50
Browse files Browse the repository at this point in the history
  • Loading branch information
mastercoms committed Jul 14, 2022
1 parent 1ecbcbb commit bf60598
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Source/GitSourceControl/Private/GitSourceControlMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void FGitSourceControlMenu::CommitClicked()
return;
}

FLevelEditorModule & LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
FLevelEditorModule & LevelEditorModule = FModuleManager::Get().LoadModuleChecked<FLevelEditorModule>("LevelEditor");
FSourceControlWindows::ChoosePackagesToCheckIn(nullptr);
}

Expand Down
4 changes: 2 additions & 2 deletions Source/GitSourceControl/Private/GitSourceControlModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void FGitSourceControlModule::StartupModule()
// Values here are 1 or 2 based on whether the change can be done immediately or needs to be delayed as unreal needs to work through its internal delegates first
// >> Technically you wouldn't need to use `GetOnAssetSelectionChanged` -- but it's there as a safety mechanism. States aren't forceupdated for the first path that loads
// >> Making sure we force an update on selection change that acts like a just in case other measures fail
FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
FContentBrowserModule& ContentBrowserModule = FModuleManager::Get().LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
CbdHandle_OnFilterChanged = ContentBrowserModule.GetOnFilterChanged().AddLambda( [this]( const FARFilter&, bool ) { GitSourceControlProvider.TicksUntilNextForcedUpdate = 2; } );
CbdHandle_OnSearchBoxChanged = ContentBrowserModule.GetOnSearchBoxChanged().AddLambda( [this]( const FText&, bool ){ GitSourceControlProvider.TicksUntilNextForcedUpdate = 1; } );
CbdHandle_OnAssetSelectionChanged = ContentBrowserModule.GetOnAssetSelectionChanged().AddLambda( [this]( const TArray<FAssetData>&, bool ) { GitSourceControlProvider.TicksUntilNextForcedUpdate = 1; } );
Expand All @@ -72,7 +72,7 @@ void FGitSourceControlModule::ShutdownModule()

#if ENGINE_MAJOR_VERSION >= 5
// Unregister ContentBrowserDelegate Handles
FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
FContentBrowserModule& ContentBrowserModule = FModuleManager::Get().LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
ContentBrowserModule.GetOnFilterChanged().Remove( CbdHandle_OnFilterChanged );
ContentBrowserModule.GetOnSearchBoxChanged().Remove( CbdHandle_OnSearchBoxChanged );
ContentBrowserModule.GetOnAssetSelectionChanged().Remove( CbdHandle_OnAssetSelectionChanged );
Expand Down
2 changes: 1 addition & 1 deletion Source/GitSourceControl/Private/GitSourceControlModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class FGitSourceControlModule : public IModuleInterface
*/
static inline FGitSourceControlModule& Get()
{
return FModuleManager::LoadModuleChecked< FGitSourceControlModule >("GitSourceControl");
return FModuleManager::Get().LoadModuleChecked< FGitSourceControlModule >("GitSourceControl");
}

/** Set list of error messages that occurred after last git command */
Expand Down
29 changes: 17 additions & 12 deletions Source/GitSourceControl/Private/GitSourceControlProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,28 @@ void FGitSourceControlProvider::CheckRepositoryStatus()
// Make sure our settings our up to date
UpdateSettings();

// Find the path to the root Git directory (if any, else uses the ProjectDir)
const FString PathToProjectDir = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir());
if (!GitSourceControlUtils::FindRootDirectory(PathToProjectDir, PathToRepositoryRoot))
{
UE_LOG(LogSourceControl, Error, TEXT("Failed to find valid Git root directory."));
bGitRepositoryFound = false;
return;
}
if (!GitSourceControlUtils::CheckGitAvailability(PathToGitBinary, &GitVersion))
{
UE_LOG(LogSourceControl, Error, TEXT("Failed to find valid Git executable."));
bGitRepositoryFound = false;
return;
}
// Get user name & email (of the repository, else from the global Git config)
GitSourceControlUtils::GetUserConfig(PathToGitBinary, PathToRepositoryRoot, UserName, UserEmail);

TUniqueFunction<void()> InitFunc = [this]()
{
TMap<FString, FGitSourceControlState> States;
auto ConditionalRepoInit = [this, &States]()
{
// Find the path to the root Git directory (if any, else uses the ProjectDir)
const FString PathToProjectDir = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir());
if (!GitSourceControlUtils::FindRootDirectory(PathToProjectDir, PathToRepositoryRoot))
{
return false;
}
if (!GitSourceControlUtils::CheckGitAvailability(PathToGitBinary, &GitVersion))
{
return false;
}
if (!GitSourceControlUtils::GetBranchName(PathToGitBinary, PathToRepositoryRoot, BranchName))
{
return false;
Expand All @@ -119,8 +126,6 @@ void FGitSourceControlProvider::CheckRepositoryStatus()
UE_LOG(LogSourceControl, Error, TEXT("%s"), *ErrorMessage);
}
}
// Get user name & email (of the repository, else from the global Git config)
GitSourceControlUtils::GetUserConfig(PathToGitBinary, PathToRepositoryRoot, UserName, UserEmail);
const TArray<FString> ProjectDirs{FPaths::ConvertRelativePathToFull(FPaths::ProjectContentDir()),
FPaths::ConvertRelativePathToFull(FPaths::ProjectConfigDir()),
FPaths::ConvertRelativePathToFull(FPaths::GetProjectFilePath())};
Expand Down
8 changes: 8 additions & 0 deletions Source/GitSourceControl/Private/GitSourceControlUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,10 @@ void GetUserConfig(const FString& InPathToGitBinary, const FString& InRepository
{
OutUserName = InfoMessages[0];
}
else
{
OutUserName = TEXT("");
}

Parameters.Reset(1);
Parameters.Add(TEXT("user.email"));
Expand All @@ -508,6 +512,10 @@ void GetUserConfig(const FString& InPathToGitBinary, const FString& InRepository
{
OutUserEmail = InfoMessages[0];
}
else
{
OutUserEmail = TEXT("");
}
}

bool GetBranchName(const FString& InPathToGitBinary, const FString& InRepositoryRoot, FString& OutBranchName)
Expand Down

0 comments on commit bf60598

Please sign in to comment.