diff --git a/Source/GitSourceControl/Private/GitSourceControlOperations.cpp b/Source/GitSourceControl/Private/GitSourceControlOperations.cpp index 3c99f28..5990804 100644 --- a/Source/GitSourceControl/Private/GitSourceControlOperations.cpp +++ b/Source/GitSourceControl/Private/GitSourceControlOperations.cpp @@ -188,7 +188,9 @@ bool FGitCheckInWorker::Execute(FGitSourceControlCommand& InCommand) UE_LOG(LogSourceControl, Log, TEXT("commit successful: %s"), *Message); // git-lfs: push and unlock files - if(InCommand.bUsingGitLfsLocking && InCommand.bCommandSuccessful) + if(InCommand.bUsingGitLfsLocking && + InCommand.bCommandSuccessful && + GitSourceControl.AccessSettings().IsPushAfterCommitEnabled()) { TArray Parameters2; // TODO Configure origin diff --git a/Source/GitSourceControl/Private/GitSourceControlSettings.cpp b/Source/GitSourceControl/Private/GitSourceControlSettings.cpp index 9408053..7c2a98c 100644 --- a/Source/GitSourceControl/Private/GitSourceControlSettings.cpp +++ b/Source/GitSourceControl/Private/GitSourceControlSettings.cpp @@ -70,6 +70,23 @@ bool FGitSourceControlSettings::SetLfsUserName(const FString& InString) return bChanged; } +bool FGitSourceControlSettings::SetIsPushAfterCommitEnabled(bool bInEnabled) +{ + FScopeLock ScopeLock(&CriticalSection); + const bool bChanged = (bIsPushAfterCommitEnabled != bInEnabled); + if (bChanged) + { + bIsPushAfterCommitEnabled = bInEnabled; + } + return bChanged; +} + +bool FGitSourceControlSettings::IsPushAfterCommitEnabled() const +{ + FScopeLock ScopeLock(&CriticalSection); + return bIsPushAfterCommitEnabled; +} + // This is called at startup nearly before anything else in our module: BinaryPath will then be used by the provider void FGitSourceControlSettings::LoadSettings() { @@ -78,6 +95,7 @@ void FGitSourceControlSettings::LoadSettings() GConfig->GetString(*GitSettingsConstants::SettingsSection, TEXT("BinaryPath"), BinaryPath, IniFile); GConfig->GetBool(*GitSettingsConstants::SettingsSection, TEXT("UsingGitLfsLocking"), bUsingGitLfsLocking, IniFile); GConfig->GetString(*GitSettingsConstants::SettingsSection, TEXT("LfsUserName"), LfsUserName, IniFile); + GConfig->GetBool(*GitSettingsConstants::SettingsSection, TEXT("IsPushAfterCommitEnabled"), bIsPushAfterCommitEnabled, IniFile); } void FGitSourceControlSettings::SaveSettings() const @@ -87,4 +105,5 @@ void FGitSourceControlSettings::SaveSettings() const GConfig->SetString(*GitSettingsConstants::SettingsSection, TEXT("BinaryPath"), *BinaryPath, IniFile); GConfig->SetBool(*GitSettingsConstants::SettingsSection, TEXT("UsingGitLfsLocking"), bUsingGitLfsLocking, IniFile); GConfig->SetString(*GitSettingsConstants::SettingsSection, TEXT("LfsUserName"), *LfsUserName, IniFile); + GConfig->SetBool(*GitSettingsConstants::SettingsSection, TEXT("IsPushAfterCommitEnabled"), bIsPushAfterCommitEnabled, IniFile); } diff --git a/Source/GitSourceControl/Private/GitSourceControlSettings.h b/Source/GitSourceControl/Private/GitSourceControlSettings.h index a87d9b1..b028351 100644 --- a/Source/GitSourceControl/Private/GitSourceControlSettings.h +++ b/Source/GitSourceControl/Private/GitSourceControlSettings.h @@ -28,6 +28,12 @@ class FGitSourceControlSettings /** Set the username used by the Git LFS 2 File Locks server */ bool SetLfsUserName(const FString& InString); + /** Set whether Submit means Commit AND push (default true) */ + bool SetIsPushAfterCommitEnabled(bool bCond); + + /** Get whether Submit means Commit AND push (default true) */ + bool IsPushAfterCommitEnabled() const; + /** Load settings from ini file */ void LoadSettings(); @@ -46,4 +52,7 @@ class FGitSourceControlSettings /** Username used by the Git LFS 2 File Locks server */ FString LfsUserName; + + /** Does Submit mean Commit AND push */ + bool bIsPushAfterCommitEnabled = true; }; diff --git a/Source/GitSourceControl/Private/SGitSourceControlSettings.cpp b/Source/GitSourceControl/Private/SGitSourceControlSettings.cpp index 13fcb5a..5d361d9 100644 --- a/Source/GitSourceControl/Private/SGitSourceControlSettings.cpp +++ b/Source/GitSourceControl/Private/SGitSourceControlSettings.cpp @@ -333,6 +333,36 @@ void SGitSourceControlSettings::Construct(const FArguments& InArgs) .Font(Font) ] ] + // Option that can be disabled to make Submit ONLY commit and not push + // This is useful in these cases: + // - To do a bunch of local commits more quickly and push in one go + // - Working disconnected + // - To combine asset changes with C++ changes in one commit; you can amend the UE commit to add the C++ changes before push + // Push can be used separately and will unlock files if using LFS locking. + +SVerticalBox::Slot() + .AutoHeight() + .Padding(2.0f) + .VAlign(VAlign_Center) + [ + SNew(SHorizontalBox) + .ToolTipText(LOCTEXT("GitPushAfterCommit_Tooltip", "Always try to Push (and unlock) after Commit on Submit when using LFS. Turning this off means you have to Push separately; Push will unlock LFS files.")) + +SHorizontalBox::Slot() + .FillWidth(0.1f) + [ + SNew(SCheckBox) + .IsChecked(SGitSourceControlSettings::IsPushAfterCommitEnabled()) + .OnCheckStateChanged(this, &SGitSourceControlSettings::OnIsPushAfterCommitEnabled) + .IsEnabled(this, &SGitSourceControlSettings::GetIsUsingGitLfsLocking) + ] + +SHorizontalBox::Slot() + .FillWidth(3.f) + .VAlign(VAlign_Center) + [ + SNew(STextBlock) + .Text(LOCTEXT("GitPushAfterCommit", "Submit means Commit AND Push")) + .Font(Font) + ] + ] // Option to Make the initial Git commit with custom message +SVerticalBox::Slot() .AutoHeight() @@ -699,6 +729,24 @@ bool SGitSourceControlSettings::GetIsUsingGitLfsLocking() const return GitSourceControl.AccessSettings().IsUsingGitLfsLocking(); } +void SGitSourceControlSettings::OnIsPushAfterCommitEnabled(ECheckBoxState NewCheckedState) +{ + FGitSourceControlModule& GitSourceControl = FModuleManager::GetModuleChecked("GitSourceControl"); + GitSourceControl.AccessSettings().SetIsPushAfterCommitEnabled(NewCheckedState == ECheckBoxState::Checked); + GitSourceControl.AccessSettings().SaveSettings(); +} + +bool SGitSourceControlSettings::GetIsPushAfterCommitEnabled() const +{ + const FGitSourceControlModule& GitSourceControl = FModuleManager::GetModuleChecked("GitSourceControl"); + return GitSourceControl.AccessSettings().IsPushAfterCommitEnabled(); +} + +ECheckBoxState SGitSourceControlSettings::IsPushAfterCommitEnabled() const +{ + return (GetIsPushAfterCommitEnabled() ? ECheckBoxState::Checked : ECheckBoxState::Unchecked); +} + ECheckBoxState SGitSourceControlSettings::IsUsingGitLfsLocking() const { return (GetIsUsingGitLfsLocking() ? ECheckBoxState::Checked : ECheckBoxState::Unchecked); diff --git a/Source/GitSourceControl/Private/SGitSourceControlSettings.h b/Source/GitSourceControl/Private/SGitSourceControlSettings.h index 1eb262b..ad787ea 100644 --- a/Source/GitSourceControl/Private/SGitSourceControlSettings.h +++ b/Source/GitSourceControl/Private/SGitSourceControlSettings.h @@ -66,6 +66,10 @@ class SGitSourceControlSettings : public SCompoundWidget void OnCheckedUseGitLfsLocking(ECheckBoxState NewCheckedState); ECheckBoxState IsUsingGitLfsLocking() const; bool GetIsUsingGitLfsLocking() const; + + void OnIsPushAfterCommitEnabled(ECheckBoxState NewCheckedState); + bool GetIsPushAfterCommitEnabled() const; + ECheckBoxState IsPushAfterCommitEnabled() const; void OnLfsUserNameCommited(const FText& InText, ETextCommit::Type InCommitType); FText GetLfsUserName() const;