-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(BackgroundFetchPlugin): Add option to fetch on repo opening #12192
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
feat(BackgroundFetchPlugin): Add option to fetch on repo opening #12192
Conversation
c65676c
to
b01474c
Compare
@@ -36,6 +36,7 @@ public BackgroundFetchPlugin() : base(true) | |||
private readonly NumberSetting<int> _fetchInterval = new("Fetch every (seconds) - set to 0 to disable", 0); | |||
private readonly BoolSetting _autoRefresh = new("Refresh view after fetch", false); | |||
private readonly BoolSetting _fetchAllSubmodules = new("Fetch all submodules", false); | |||
private readonly BoolSetting _fetchOnRepoOpening = new("Fetch on repository opening", false); |
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.
Suggestion: Change to: "Fetch on repository change"
Also call RecreateObservable when repository change. Listen for PostRepositoryChanged around line 57
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.
I prefer "on repository opening" (and not "on application opening") because it is include when opening the repository at startup and when opening a new repository.
The Register()
and so the RecreateObservable()
is already called on repositroy changed. PostSettings
is when settings are changed. So there is no other things to do to have it working on repo change.
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.
"Fetch on repository opening" sounds to me as: once when the application opens. What do you think about "Fetch on repository open or change"?
@@ -71,90 +73,95 @@ private void RecreateObservable() | |||
Validates.NotNull(_currentGitUiCommands); | |||
|
|||
IGitModule gitModule = _currentGitUiCommands.Module; | |||
if (fetchInterval > 0 && gitModule.IsValidGitWorkingDir()) | |||
if (fetchInterval <= 0 || !gitModule.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.
I like the quick return :). What if somebody want to fetch ONLY on change, and not use timed background fetch? Setting fetchInterval to 0 disables both.
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 if somebody want to fetch ONLY on change, and not use timed background fetch?
Which user will come to "Periodic background fetch" plugin to configure a one time fetch?
I don't think that it is really the purpose of this plugin to do a one time fetch (and there is no elegant way to do it).
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.
To fetch on open only is a use case.
You could set a really high number though.
Maybe disable the settings if time is 0 to not confuse users that 0+fetch is possible.
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.
You could set a really high number though.
Unfortunately, no. The maximum accepted is "relatively" low (approx. 40 days)
To fetch on open only is a use case.
Finally, I found an elegant solution for this use case. So, done...
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.
b01474c
to
a67b390
Compare
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.
Looks sensible, have not run
699209a
to
2c06686
Compare
Fixes gitextensions#6457 Note: the fetching is not "immediate" because the background fetch is waiting that no git process is running but should be triggered quickly enough so that user hardly noticed. + Reduce git running check interval (because git running should not be that long)
2c06686
to
f3c4396
Compare
Fixes #6457
Note: the fetching is not "immediate" because the background fetch is waiting that no git process is running but should be triggered quickly enough so that user hardly noticed.
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).
✒️ I contribute this code under The Developer Certificate of Origin.