-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: Restrict settings to "global" when not in a repository #11955
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: Restrict settings to "global" when not in a repository #11955
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seem to work.
Does this changes the plugin interface?
Do we really need to pass this flag to all settings pages? It does not apply to more than half of them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like a suboptimal way of implementing the flag. Is there a reason the flag can't be initialised by the base page?
It can't because we don't have access to I discovered that we can get it through I can continue the refactoring to require @RussKie I gave it a quick try in the last commit. Look if you find it better...
The constructors of all the setting pages has to be updated due to how they are instantiated.
I don't think so (and it seems to work without problem) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍, have not run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of changes, but hard to do in another way.
Have run briefly
I'm planning to review this, hopefully before the EOW. |
{ | ||
_canSaveInsideRepo = pageHost.CheckSettingsLogic.CommonLogic.Module.IsValidGitWorkingDir(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the concrete type of serviceProvider
? It's an instance of GitUICommands
, which implements IGitUICommands
and, thus, inherits from IServiceProvider
.
Which makes this possible:
if (serviceProvider is IGitUICommands uiCommands)
{
_canSaveInsideRepo = uiCommands.Module.IsValidGitWorkingDir();
}
It's a little hacky, but we some point I expect we'll have something like the following:
IGitUICommands uiCommands = serviceProvider.GetREquiredService<IGitUICommands>();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which makes this possible:
I saw that but it was (too) hacky for me that's why I have not decided to go that way.
It's you to decide...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the end, ISettingsPageHost
, that still need to be passed is now passed in the constructor to have it earlier than in a later call to do some initialization. It's indeed a lot of code changes but nothing silly...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current change introduces a hard coupling, and this I'd like to avoid.
Let's resolve from the service provider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
and so when a setting could only be saved globally. Fixes gitextensions#11907
2579834
to
698ef8c
Compare
and so that settings file can't be saved in a "not existing" local repository.
Check that repo is valid and provide the information when creating pages
Fixes #11907 (at least prevent one way to reproduce it)
Screenshots
Before
After
Test methodology
Test environment(s)
Merge strategy
I agree that the maintainer squash merge this PR (if the commit message is clear).
(Will be squashed before merging)
✒️ I contribute this code under The Developer Certificate of Origin.