Skip to content

Conversation

pmiossec
Copy link
Member

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

image

Test methodology

  • Manual

Test environment(s)

  • Git Extensions 33.33.33
  • Build c16f47d (Dirty)
  • Git 2.47.0.windows.1
  • Microsoft Windows NT 10.0.26100.0
  • .NET 8.0.12
  • DPI 96dpi (no scaling)
  • Portable: False
  • Microsoft.WindowsDesktop.App Versions
    Microsoft.WindowsDesktop.App 8.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
    Microsoft.WindowsDesktop.App 9.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

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.

@pmiossec
Copy link
Member Author

I have inverted the if (to early return) so changes seems a lot more important than what they are.
Reviewing with "Hide whitespaces" enabled could help a lot:
image

@pmiossec pmiossec force-pushed the feat/backgroundfetch_fetchOnRepoOpening branch 2 times, most recently from c65676c to b01474c Compare February 13, 2025 18:48
@@ -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);
Copy link

@PhilipMilestone PhilipMilestone Feb 14, 2025

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

Copy link
Member Author

@pmiossec pmiossec Feb 14, 2025

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.

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())

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.

Copy link
Member Author

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).

Copy link
Member

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.

Copy link
Member Author

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...

Copy link
Member

@RussKie RussKie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@pmiossec pmiossec force-pushed the feat/backgroundfetch_fetchOnRepoOpening branch from b01474c to a67b390 Compare February 14, 2025 12:39
Copy link
Member

@mstv mstv left a 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

@pmiossec pmiossec force-pushed the feat/backgroundfetch_fetchOnRepoOpening branch 5 times, most recently from 699209a to 2c06686 Compare February 19, 2025 21:42
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)
@pmiossec pmiossec force-pushed the feat/backgroundfetch_fetchOnRepoOpening branch from 2c06686 to f3c4396 Compare February 21, 2025 11:10
@pmiossec pmiossec merged commit 2a4f80a into gitextensions:master Feb 21, 2025
4 checks passed
@pmiossec pmiossec deleted the feat/backgroundfetch_fetchOnRepoOpening branch February 21, 2025 11:32
@mstv mstv added this to the v5.3 milestone Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatic fetch on opening
5 participants